How can I manipulate protein-interaction network graph from the String database using STRINGdb bioconductor package and R?

I have downloaded the whole graph for Homo sapiens from STRING, which has about 20.000 proteins.

  1. How do I read the file using that package?
  2. How do I filter things I don't need? Supposing that I want to keep tumor data, as an example.
  • $\begingroup$ Cross-posted on biostars...again $\endgroup$
    – Devon Ryan
    Commented May 30, 2017 at 12:17
  • 2
    $\begingroup$ I don't think it is a problem to cross-post. It would be good to post a link to the best answer on the other site when such an answer is defined. $\endgroup$
    – bli
    Commented May 30, 2017 at 15:24
  • 1
    $\begingroup$ @bli that what I'm going to do once an answer is found $\endgroup$
    – A M
    Commented May 31, 2017 at 9:52
  • $\begingroup$ That's the question how do I do to filter things I don't need I already downloaded the whole graph for homosapiens from the download section in STRING . $\endgroup$
    – A M
    Commented May 31, 2017 at 10:50

1 Answer 1


I think the easiest way is to download the graph using STRINGdb.

string_db <- STRINGdb$new(version="10", species=9606,
                          score_threshold=400, input_directory="" )
full.graph <- string_db$get_graph()

Now you can use igraph, to manipulate the graph. Let's assume you want to take 200 proteins with the highest degree, i.e. number of edges they have.


# see how many proteins do you have    

# find top 200 proteins with the highest degree
top.degree.verticies <- names(tail(sort(degree(full.graph)), 200))

# extract the relevant subgraph
top.subgraph <- induced_subgraph(full.graph, top.degree.verticies)

# count the number of proteins in it

How to get disease specific genes?

There's no GO annotation for cancer or Alzheimer's disease. It is out of scope of the GO consortium.

What you can do, you can either take KEGG Pathways annotation, or manually select list of relevant GO-terms. Or acquire the list from one of the papers. For example annotation term 05200 corresponds to the cancer KEGG pathway. You can easily retrieve proteins associated with the annotation:

cancer.pathway.proteins <-

And then perform subgraphing as described above.

Alternatively you can try to get an enrichment score for an every gene given it's neighbors (the way enrichment is shown on the string-db website). Then you can keep only those having top enrichment scores. Probably get_ppi_enrichment_full or get_ppi_enrichment functions will help you to do that.

  • $\begingroup$ If we want to keep tumor , cancer , alzheimer data , I mean filtering by disease. can we do that ? knowing that we want to keep the maximum of nodes $\endgroup$
    – A M
    Commented May 31, 2017 at 11:29
  • $\begingroup$ @I'm getting errors Error in induced_subgraph(graph, top.degree.verticies) : Not a graph object $\endgroup$
    – A M
    Commented May 31, 2017 at 12:35
  • $\begingroup$ That's probably because graph is a function in igraph package. Make sure you're using a correct variable name. $\endgroup$ Commented May 31, 2017 at 12:38
  • $\begingroup$ is there a way to export the graph is csv ? $\endgroup$
    – A M
    Commented May 31, 2017 at 12:47
  • $\begingroup$ Please, check the very good documentation of the igraph package. You can export graph using write_graph. Also, as you can notice STRINGdb downloads the full graph to your computer, therefore you probably can download it directly from the database website. $\endgroup$ Commented May 31, 2017 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.