list in which each element is a vector of GO BP ids corresponding to an entrez gene
0
0
Entering edit mode
6.8 years ago
salamandra ▴ 550

I'm trying to retrieve a list in which each element is a vector of GO BP ids corresponding to an entrez gene. Then I plan to unlist those elements and do a unique vector with all available GO ids for BP only The following code:

library(org.Hs.eg.db)
xx.GO <- as.list(org.Hs.egGO)
lapply(xx.GO, function(x) unlist(lapply(x, function(y) if(y[["Ontology"]]=="BP") {y[["GOID"]]})))

gives the error:

Error in unlist(lapply(x, function(y) if (y[["Ontology"]] == "BP") { : 
error in evaluating the argument 'x' in selecting a method for function 'unlist': Error in y[["Ontology"]] : subscript out of bounds

What am I doing wrong?

R org.Hs.eg.db lapply • 1.8k views
ADD COMMENT
1
Entering edit mode

Following is not the solution to your issue. However, easier way may be:

library(org.Hs.eg.db)
goeg=as.data.frame(org.Hs.egGO2EG)
goegbp=goeg[goeg$Ontology=="BP",]

First few lines from the output:

> head(goegbp)
  gene_id      go_id Evidence Ontology
1       1 GO:0008150       ND       BP
2       2 GO:0001869      IDA       BP
3       2 GO:0002576      TAS       BP
4       2 GO:0007264      TAS       BP
5       2 GO:0007596      TAS       BP
6       2 GO:0007597      TAS       BP
ADD REPLY
0
Entering edit mode

thank you very much! :)

ADD REPLY

Login before adding your answer.

Traffic: 1692 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6