Hi everyone, I was hoping someone might be able to help me with an issue I am having.
I am changing the imports in my NAMESPACE file from imports to importsFrom, and everything runs correctly when I specify import(GenomicRanges). However, when I use importFrom(GenomicRanges, GRanges) and importFrom(GenomicRanges, findOverlaps) I get the below error:
"error in evaluating the argument 'query' in selecting a method for function 'findOverlaps': each range must have an end that is greater or equal to its start minus one"
This seemed strange to me because it only appears when I don't import the full package. I have also included all of my other namespace imports below. Does anyone know why this could be? Thank you in advance!
importFrom(AnnotationDbi,select)
importFrom(GenomicFeatures,exons)
importFrom(GenomicFeatures,genes)
importFrom(GenomicRanges,GRanges)
importFrom(GenomicRanges,findOverlaps)
importFrom(IRanges,IRanges)
importFrom(IRanges,overlapsAny)
importFrom(Repitools,annoGR2DF)
importFrom(S4Vectors,Rle)
importFrom(S4Vectors,queryHits)
importFrom(S4Vectors,subjectHits)
importFrom(TxDb.Hsapiens.UCSC.hg19.knownGene,TxDb.Hsapiens.UCSC.hg19.knownGene)
importFrom(TxDb.Hsapiens.UCSC.hg38.knownGene,TxDb.Hsapiens.UCSC.hg38.knownGene)
importFrom(org.Hs.eg.db,org.Hs.eg.db)
sessionInfo( )
Yes, but most importantly
importFrom(GenomicRanges,findOverlaps)
fails because it tries to import the _generic function_ from the wrong package. ThefindOverlaps
generic function is defined in the IRanges package:It's important to keep in mind that when you call
findOverlaps()
in your code, you're calling the generic function, not a particular method. The generic function will then take care of dispatching to the appropriate method, and it's not always possible to know in advance which one it's going to be.Thanks! I do think that this is the issue. How should I best handle this in my namespace file? It seems that I get the same error when adding
findOverlaps
to the IRanges import instead. Would it be better to just useimport(GenomincRanges)
instead? My query and subject are GRanges objects.I think you need to import all the
findOverlaps()
_methods_ defined in the GenomicRanges package by usingimportMethodsFrom(GenomicRanges, findOverlaps)
. Alternatively you could also useimport(GenomincRanges)
to import _everything_ from the GenomicRanges package.