Oshlack / missMethyl

Bioconductor package for analysis of methylation data from Illumina's Infinium HumanMethylation arrays.
10 stars 4 forks source link

Calling missMethyl::gometh from within an R package fails unless that package depends on IlluminaHumanMethylation450kanno.ilmn12.hg19 #10

Closed snowpong closed 1 year ago

snowpong commented 3 years ago

I am writing a package that is relying (imports) missMethyl. When a function in my package calls missMethyl::gometh it fails with:

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'nrow': error in evaluating the argument 'args' in selecting a method for function 'do.call': error in evaluating the argument 'envir' in selecting a method for function 'get': no item called "package:IlluminaHumanMethylation450kanno.ilmn12.hg19" on the search list

Here is some more from traceback():

26: h(simpleError(msg, call))
25: .handleSimpleError(function (cond) 
    .Internal(C_tryCatchHelper(addr, 1L, cond)), "error in evaluating the argument 'args' in selecting a method for function 'do.call': error in evaluating the argument 'envir' in selecting a method for function 'get': no item called \"package:IlluminaHumanMethylation450kanno.ilmn12.hg19\" on the search list", 
        base::quote(h(simpleError(msg, call))))
24: h(simpleError(msg, call))
23: .handleSimpleError(function (cond) 
    .Internal(C_tryCatchHelper(addr, 1L, cond)), "error in evaluating the argument 'envir' in selecting a method for function 'get': no item called \"package:IlluminaHumanMethylation450kanno.ilmn12.hg19\" on the search list", 
        base::quote(h(simpleError(msg, call))))
22: h(simpleError(msg, call))
21: .handleSimpleError(function (cond) 
    .Internal(C_tryCatchHelper(addr, 1L, cond)), "no item called \"package:IlluminaHumanMethylation450kanno.ilmn12.hg19\" on the search list", 
        base::quote(as.environment(pointer$envir)))
20: get(pointer$what, envir = as.environment(pointer$envir))
19: .annoGet(wh, envir = annoObject@data)
18: FUN(X[[i]], ...)
17: lapply(what, function(wh) {
        .annoGet(wh, envir = annoObject@data)
    })
16: lapply(what, function(wh) {
        .annoGet(wh, envir = annoObject@data)
    })
15: do.call(cbind, lapply(what, function(wh) {
        .annoGet(wh, envir = annoObject@data)
    }))
14: minfi::getAnnotation(IlluminaHumanMethylation450kanno.ilmn12.hg19::IlluminaHumanMethylation450kanno.ilmn12.hg19)
13: .getFlatAnnotation(array.type)
12: getMappedEntrezIDs(sig.cpg = sig.cpg, all.cpg = all.cpg, array.type = array.type, 
        genomic.features = genomic.features)
11: gsameth(sig.cpg = sig.cpg, all.cpg = all.cpg, collection = kegg$idList, 
        array.type = array.type, plot.bias = plot.bias, prior.prob = prior.prob, 
        anno = anno, equiv.cpg = equiv.cpg, fract.counts = fract.counts, 
        genomic.features = genomic.features, sig.genes = sig.genes)
10: missMethyl::gometh(cpgList, collection = pathway, array.type = array) at pathwayanalysis.R#24

This is all resolved if I call library(IlluminaHumanMethylation450kanno.ilmn12.hg19) before calling my package function.

My guess is that since missMethyl now Depends on IlluminaHumanMethylation450kanno.ilmn12.hg19 my package has to as well (this is implied by this comment).

What is the reason you're now depending on IlluminaHumanMethylation450kanno.ilmn12.hg19?

snowpong commented 3 years ago

This issues seems very related to this one which was resolved by this change I believe.

bphipson commented 1 year ago

We require the annotation packages to perform gene set testing within the missMethyl package.