I have been generating Gene Ontology lists using HyperGTests, and would like to pull out the lists associated with particular GO terms and have been running into troubles.
In order to get GO terms I have been successfully using the code:
#get entrez ids for gene symbols entrez_object <- org.Mm.egGO mapped_genes <- mappedkeys(entrez_object) entrez_to_go <- as.list(entrez_object[mapped_genes]) universe <- mapped_genes go_object <- as.list(org.Mm.egGO2EG) geneids <- dplyr::select(grcm38, symbol, entrez) colnames(geneids) <- c("gene", "entrez") #Load in genelist and run test Xn <- read.table("~/Path/Sample_Genelist.txt", header=F, sep="\t") colnames(Xn) <- c("gene", "PeakID") dat <- merge(Xn, geneids, by= "gene") genelist <- dat$entrez genelist <- as.character(genelist) params <- new('GOHyperGParams', geneIds=genelist, universeGeneIds=universe, ontology='BP', pvalueCutoff=0.001, conditional=F, testDirection='over', annotation="org.Mm.eg.db") MmOver <- hyperGTest(params) result <- summary(MmOver)
This generates a nice and tidy GO list. However, I would like to get the genes that contribute to those GO terms. After some research, I have found and attempted this solution:
Xn[genes %in% get("GO:0007399", revmap(org.Mm.egGO2EG))]
And I get out the Error:
Error in .checkKeys(value, Lkeys(x), x@ifnotfound) : value for "GO:0007399" not found
I have tried a number of GO terms and some other permutations of this same code, as well as looked for published solutions for the error but haven't found any so far. Has anyone encountered this, or attempted to do the same?
I have found that Jax has a database of GO terms with associated genes that can be searched and downloaded for subsetting in R, but this is a very clumsy solution, and I would like to be able to pull directly, if at all possible.