This is a test version of Biostars. For the public version, visit https://www.biostars.org.
StringDB get enrichment KEGG

Hello,

I do my enrichment from a list of genes using stringdb. package. It returns the pathways , the pvalue and the number of hits per pathway. How can I get which genes were mapped to each pathway? I could not find a way by looking at the stringdb manual.

This is my function:

library(STRINGdb)

##Open connection with database STRING and obtain a network as an igraph object with a threshold >400.
string_db <- STRINGdb$new( version="10", species=9606, score_threshold=400, input_directory="" )
string.network <- string_db$get_graph() 
  proteins <- string_db$get_proteins()
        p <- dplyr::select(proteins, preferred_name)
        proteins <- string_db$map(p, "preferred_name")

EnrichmentKegg<-function(list){     
        nodes.string <- (filter(proteins, preferred_name %in% list))$STRING_id
        res<-string_db$get_enrichment( nodes.string, category = "KEGG", methodMT = "fdr", iea = TRUE )

        if(nrow(res)>10){
               tst<-as.data.frame(res[1:10,])
         }else{
               tst<-as.data.frame(res)
          }
   print(tst)
}
kegg enrichment r

1 answer

Hey! I came across the same problem and found that you can use string_db$get_annotations() and string_db$get_aliases in order to find which STRING_ids map to which term_id, and then convert the STRING_ids into the conventional protein name. I use dplyr to mess around with the tables, but I'm sure any method would work.

Log in to answer this question.