topGO crashes with ' argument "annotationFun" is missing, with no default'
1
0
Entering edit mode
@philip-lijnzaad-2499
Last seen 21 months ago
European Union

What am I doing wrong here?  I scoured the (incomplete and confusing) documentation, but I get stuck at the 'new' function/method (which is not documented), which says

Building most specific GOs .....
Error in .local(.Object, ...) :
  argument "annotationFun" is missing, with no default

Yet I am clearly passing it:

library(org.Hs.eg.db)
library(topGO)

## my data has HGCN symbols as ID, so let's invent some data:
gene.names <- keys(org.Hs.eg.db, keytype="SYMBOL")
genes <- rpois(n=gene.names, lambda=200)
names(genes) <- gene.names

## make Hb genes extra high:
hb.genes <- gene.names[grep('^HB', gene.names)]
genes[hb.genes] <- 2*genes[hb.genes]
head(genes)

go.obj <- new("topGOdata",
              ontology='BP',       # (docu has wrong name 'whichOnto' for this argument)
              allGenes=genes,
              geneSel=function(v){v>250},
              nodeSize=10,
              annnotationFun=annFUN.db, # clearly passing required argument here ....
              mapping="org.Hs.eg.db",
              ID="SYMBOL")

sessionInfo()

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

locale:
[1] C

attached base packages:
[1] parallel  stats4    stats     datasets  graphics  grDevices utils    
[8] methods   base     

other attached packages:
 [1] propagate_1.0-4                        
 [2] minpack.lm_1.2-1                       
 [3] ff_2.2-13                              
 [4] bit_1.1-12                             
 [5] Rcpp_0.12.8                            
 [6] tmvtnorm_1.4-10                        
 [7] gmm_1.5-2                              
 [8] sandwich_2.3-4                         
 [9] Matrix_1.2-7.1                         
[10] mvtnorm_1.0-5                          
[11] MASS_7.3-45                            
[12] topGO_2.26.0                           
[13] SparseM_1.74                           
[14] graph_1.52.0                           
[15] RSQLite_1.1                            
[16] GO.db_3.4.0                            
[17] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
[18] GenomicFeatures_1.26.0                 
[19] GenomicRanges_1.26.1                   
[20] GenomeInfoDb_1.10.1                    
[21] org.Hs.eg.db_3.4.0                     
[22] AnnotationDbi_1.36.0                   
[23] IRanges_2.8.1                          
[24] S4Vectors_0.12.0                       
[25] Biobase_2.34.0                         
[26] BiocGenerics_0.20.0                    
[27] gdata_2.17.0                           
[28] plotrix_3.6-3                          
[29] uuutils_1.40                           
[30] gplots_3.0.1                           

loaded via a namespace (and not attached):
 [1] compiler_3.3.0             XVector_0.14.0            
 [3] bitops_1.0-6               tools_3.3.0               
 [5] zlibbioc_1.20.0            biomaRt_2.30.0            
 [7] digest_0.6.10              memoise_1.0.0             
 [9] lattice_0.20-34            DBI_0.5-1                 
[11] rtracklayer_1.34.1         Biostrings_2.42.0         
[13] gtools_3.5.0               caTools_1.17.1            
[15] grid_3.3.0                 XML_3.98-1.5              
[17] BiocParallel_1.8.1         matrixStats_0.51.0        
[19] Rsamtools_1.26.1           GenomicAlignments_1.10.0  
[21] SummarizedExperiment_1.4.0 KernSmooth_2.23-15        
[23] RCurl_1.95-4.8             zoo_1.7-13                
> 

 

bug topGO • 2.1k views
ADD COMMENT
1
Entering edit mode

grmpf, you are right, thank you! (would have been nice if one were warned with an 'unused argument' here ... ). It turns out that I had another mistake (made by trying out all the possible combinations of possibilities), it must be annot = annFUN.org, rather than annot = annFUN.db.

It would be nice to have some more and more diverse examples in the vignette though ...

 

ADD REPLY
0
Entering edit mode

It's not possible to have a warning like that, as the new function is intended to be a very general thing that allows you to generate a new instance of a particular class.

> args(new)
function (Class, ...)
NULL

There is only one established argument for new, and that's the class object. The rest are encapsulated in the ellipsis argument, and are thus defined in the class structure itself. And the class structure for topGOdata includes an ellipsis as well, so you can pass arbitrary arguments and it won't really care.

But you did get a really glaring hint! You were told that your annotationFun argument was missing, and you said 'oh huh, it's right there'. That's sort of on you, no? Your computer said 'hey dude, you're missing an argument here' and you didn't believe it, thinking that your cursory glance at the function call was superior to a computer's ability to correctly determine that fact. You will be wrong like 100% of the time that you play that game.

That said, the preferred way to do this sort of thing is to create a function that calls new internally, and that checks the arguments that are passed in, and gives an more useful error or warning message when things aren't OK. A canonical example of that would be, say, the GRanges function in GenomicRanges, which does a bunch of checking and then finally calls new to generate the output. But topGO is a really old package, and I suppose it's foolhardy to expect the author to come back and make big changes to the API at this late date.

 

ADD REPLY
0
Entering edit mode

I recommend this blog post if you want to learn more about what can it make.

ADD REPLY
1
Entering edit mode
@james-w-macdonald-5106
Last seen 2 hours ago
United States

The argument is annotationFun, not annnotationFun.

ADD COMMENT

Login before adding your answer.

Traffic: 716 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