Skip to content

Instantly share code, notes, and snippets.

@slavailn
Created August 25, 2023 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slavailn/dcc151273d925947e47237956a46c8d1 to your computer and use it in GitHub Desktop.
Save slavailn/dcc151273d925947e47237956a46c8d1 to your computer and use it in GitHub Desktop.
Download KEGG pathways with related entrez ids
library(KEGGREST)
library(org.Rn.eg.db)
# Download entrez ids and corresponding KEGG pathways followed
# by creation of a table where one column is entrez id and another
# column is a comma separated list of KEGG pathways
# Download pathway to entrez id relationship
rno_path_eg <- keggLink("pathway", "rno")
names(rno_path_eg) <- gsub("rno:", "", names(rno_path_eg))
rno_path_eg <- gsub("path:", "", rno_path_eg)
rno_path_eg <- data.frame(entrez_id = names(rno_path_eg),
kegg_id = rno_path_eg)
head(rno_path_eg)
dim(rno_path_eg)
# Create a table, where one column is an entrez id
# and the second column are comma separated pathways
# where this gene participates
rno_path_eg <- aggregate(kegg_id~entrez_id, rno_path_eg, paste, collapse=",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment