Few months passed since the question was asked but maybe it can still help someone!
This is how I did it, since I was not able to find a function that automatically does that, too:
library("STRINGdb")
library("igraph")
#get species ID, for Mus musculus
sID <- get_STRING_species(version="10", species_name=NULL)[grep("musculus", get_STRING_species(version="10", species_name=NULL)$official_name), 1]
#10090 refers to Mus musculus
stringDB <- STRINGdb$new(version="10", species=sID, score_threshold=400, input_directory=getwd())
#originalData contains some gene names
mappedGenes <- stringDB$map(originalData, "geneNames", removeUnmappedRows=F)
#keep only those genes that were actually found
foundGenes <- mappedGenes[!is.na(mappedGenes$STRING_id), ]
#get the network
wholeNet <- stringDB$get_subnetwork(foundGenes$STRING_id)
#those edges that do not meet the requirements will be deleted
deleteThis <- which(E(wholeNet)$experiments <= 300)
#if there are any edges to delete, do it
if (length(deleteThis) > 0) {
onlyExp <- delete.edges(wholeNet, deleteThis)
}
else {
#otherwise keep the network as is
onlyExp <- wholeNet
}
#of course you can filter accordingly to your needs
#then, in case there are multiple connected components (you never know), or islands as they call it
for (expN in decompose(onlyExp)){
if (length(E(expN)>0)) {
plot(expN, vertex.label.color="black", vertex.label.cex=0.9, vertex.label=V(expN)$name, edge.color="gray28", layout=layout_nicely)
}
}
hopefully it will work!
Hi, I would like to know the codes I should run to import an excel sheet with my list of protein targets that I want analysed on the String database using R. So far I know that I have to run these codes below. From then on, I do not know how I should: 1. Load the dataset 2. Link the dataset on R in order to run it on R
install.packages("BiocManager") install.packages("STRINGdb") library("STRINGdb")
PS. I am a beginner level in programming. Thank you in advance, I hope for a favourable response.