Skip to content

Instantly share code, notes, and snippets.

@tomsing1
Created March 24, 2022 23:34
Show Gist options
  • Save tomsing1/d00a655f5268e5563611b3361636b990 to your computer and use it in GitHub Desktop.
Save tomsing1/d00a655f5268e5563611b3361636b990 to your computer and use it in GitHub Desktop.
Listifying KEGG and GO gene sets
library(limma)
library(AnnotationDbi)
library(GO.db)
library(org.Hs.eg.db)
# KEGG
kegg.names <- getKEGGPathwayNames("hsa", remove.qualifier = TRUE)
kegg.sets <- getGeneKEGGLinks("hsa", convert = TRUE)
kegg.gsc <- with(kegg.sets, split(GeneID, PathwayID))
names(kegg.gsc) <- kegg.names[
match(names(kegg.gsc), kegg.names$PathwayID), "Description"]
# GO
go.sets <- AnnotationDbi::toTable(
org.Hs.egGO2ALLEGS)[, c("gene_id", "go_id", "Ontology")]
go.names <- AnnotationDbi::mapIds(GO.db::GO.db,
keys = unique(go.sets$go_id), keytype = "GOID", column = "TERM")
go.gsc <- with(go.sets, split(gene_id, go_id))
names(go.gsc) <- go.names[names(go.gsc)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment