Error with importFrom and GenomicRanges in NAMESPACE
1
0
Entering edit mode
jbendik • 0
@b2d26a33
Last seen 16 months ago
United States

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( )
GenomicRanges IRanges • 1.4k views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 3 days ago
United States

You should probably ask this at bioc-devel@r-project.org, as it's a developer question. That said, you get this error

"error in evaluating the argument 'query' in selecting a method for function 'findOverlaps':

Which may indicate that the findOverlaps function you are looking for isn't from GenomicRanges, but instead from a different package. Which depends on the query (and subject) arguments. For example

> library(GenomicRanges)
> showMethods(findOverlaps)
Function: findOverlaps (package IRanges)
query="ANY", subject="Pairs"
query="GenomicRanges", subject="GenomicRanges"
query="GenomicRanges", subject="GRangesList"
query="GRangesList", subject="GenomicRanges"
query="GRangesList", subject="GRangesList"
query="integer", subject="IntegerRanges"
query="IntegerRanges", subject="IntegerRanges"
query="IntegerRangesList", subject="IntegerRangesList"
query="Pairs", subject="ANY"
query="Pairs", subject="missing"
query="Pairs", subject="Pairs"
query="Vector", subject="missing"

> selectMethod(findOverlaps, c(query="IntegerRanges", subject="IntegerRanges"))
Method Definition:

function (query, subject, maxgap = -1L, minoverlap = 0L, type = c("any", 
    "start", "end", "within", "equal"), select = c("all", "first", 
    "last", "arbitrary"), ...) 
{
    .local <- function (query, subject, maxgap = -1L, minoverlap = 0L, 
        type = c("any", "start", "end", "within", "equal"), select = c("all", 
            "first", "last", "arbitrary")) 
    {
        if (is.integer(query)) 
            query <- IRanges(query, width = 1L)
        type <- match.arg(type)
        select <- match.arg(select)
        findOverlaps_NCList(query, subject, maxgap = maxgap, 
            minoverlap = minoverlap, type = type, select = select)
    }
    .local(query, subject, maxgap, minoverlap, type, select, 
        ...)
}
<bytecode: 0x000001ea2d25b260>
<environment: namespace:IRanges>

Signatures:
        query           subject        
target  "IntegerRanges" "IntegerRanges"
defined "IntegerRanges" "IntegerRanges"

If your query is a IntegerRanges, then you probably don't have the right findOverlaps imported from GenomicRanges.

ADD COMMENT
1
Entering edit mode

Yes, but most importantly importFrom(GenomicRanges,findOverlaps) fails because it tries to import the _generic function_ from the wrong package. The findOverlaps generic function is defined in the IRanges package:

> findOverlaps
standardGeneric for "findOverlaps" defined from package "IRanges"
...

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.

ADD REPLY
0
Entering edit mode

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 use import(GenomincRanges) instead? My query and subject are GRanges objects.

importFrom(AnnotationDbi,select)
importFrom(GenomicFeatures,exons)
importFrom(GenomicFeatures,genes)
importFrom(GenomicRanges,GRanges)
importFrom(GenomicRanges,seqnames)
importFrom(IRanges,IRanges)
importFrom(IRanges,findOverlaps)
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)
ADD REPLY
1
Entering edit mode

I think you need to import all the findOverlaps() _methods_ defined in the GenomicRanges package by using importMethodsFrom(GenomicRanges, findOverlaps). Alternatively you could also use import(GenomincRanges) to import _everything_ from the GenomicRanges package.

ADD REPLY

Login before adding your answer.

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