This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Errors when extracting significant genes per GO.id from topgo data

I'm using topGO to get enriched GO terms from my data. I was able to succesful get the enriched GO terms, but, at the end of the pipeline, there are two commands throwing errors which I could not solve.

>    tgd <- new( "topGOdata", ontology="BP", allGenes = alg, nodeSize=5,
              annot=annFUN.org, mapping="org.Mm.eg.db", ID = "ensembl" )

First error, when I try to plot the distribution of the genes annotated to a GO term

> print(showGroupDensity(object = tgd, whichGO = "GO:0015980", ranks = TRUE))
Error in factor(group, labels = paste(c("complementary", whichGO), "  (",  : 
  invalid 'labels'; length 2 should be 1 or 0
>

Second error, when I try to get the genes in any GO id, I receive a error.

In the topGO manual, the chip argument is set to affyLib, but how can I use the mouse annotation instead? When I try it fails.

> gt <- printGenes(tgd, whichTerms = "GO:0015980", chip = org.Mm.eg.db, numChar = 10)
Error in as.vector(x, "character") : 
  cannot coerce type 'environment' to vector of type 'character'

Anyone with experience in using the topGO can help me out?

rna-seq bioconductor topgo r

I discovered that, in the first error, using rm.one = F, the error stop and the plot is shown. I dont know why is this though. Still would like to get an explanation. The manual does not use this after all.

Ok, in the second error, instead of org.Mm.eg.db, I should sign a variable of type character pointing to the database like:

mouse<-"org.Mm.eg"

but now, another error is shown:

Error in get(paste(chip, "ENTREZ", sep = "")) : 
  object 'org.Mm.egENTREZ' not found

This second error has to the fact that, topGO search for entrezID in the mouse.db, but I used Ensembl ID's, the question now is, I use ENTREZ_ID or change the R script for do the job?

Sorry that I am not able to help you in direct way. But I have an alternate suggestion. Since you are struggling just to perform enrichment analysis, try GeneSCF with your obtained gene list.

1 answer

Answering my own question...

The first error can be solved by simple adding rm.one = F to the command,still not sure why.

The second problem was more confusing. And then I realize that I just want the gene ID for each GO, and not that fancy table from topGO. We can get that information by using:

#####get genes/GO######

  allGO = genesInTerm(tgd) ##get all GOs and their genes from the topgo result.
  ANOTATION = lapply(allGO,function(x) x[x %in% deseq_result_DEGS_only$ensembl_gene_id] ) ##get only my Differentially expressed genes in allGO

  tableGO.genes <- ANOTATION[tab$GO.ID] ## get only the GO's located in the result of topGO
  LS.df = as.data.frame(do.call(rbind, tableGO.genes)) ## Transform it to a data frame.

Log in to answer this question.