This is a test version of Biostars. For the public version, visit https://www.biostars.org.
list in which each element is a vector of GO BP ids corresponding to an entrez gene

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

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

thank you very much! :)

0 answers

No answers yet.

Log in to answer this question.