seqlengths is not an exported object from namespace GenomicRanges
1
1
Entering edit mode
Aditya ▴ 160
@aditya-7667
Last seen 22 months ago
Germany

?GRanges mentions the accessor function seqlengths(). Trying to use it seems to be throwing an error about that not being exported. Hmm...looks like I am overlooking something. But what? :-)

granges <- GenomicRanges::GRanges(
                seqnames = 'chr1', 
                ranges = IRanges::IRanges(start = 100, end = 200), 
                strand = '-', 
                seqlengths = c(chr1 = 1000))

GenomicRanges::seqlengths(granges)
    Error: 'seqlengths' is not an exported object from 'namespace:GenomicRanges'
GenomicRanges • 1.4k views
ADD COMMENT
4
Entering edit mode
@michael-lawrence-3846
Last seen 2.4 years ago
United States

It's defined by the GenomeInfoDb package. To find that out, you could print the seqlengths() function at the console,

> seqlengths
standardGeneric for "seqlengths" defined from package "GenomeInfoDb"

function (x) 
standardGeneric("seqlengths")
<bytecode: 0x55ef9a8508f8>
<environment: 0x55ef9a84aaf0>
Methods may be defined for arguments: x
Use  showMethods("seqlengths")  for currently available ones.

If you're developing a package, it's often a lot easier to just import namespaces into your namespace, so that there's no need to remember which package defines what. Or, when working interactively, just call library(GenomicRanges), which will attach all relevant dependencies, such as GenomeInfoDb.

ADD COMMENT
2
Entering edit mode

As a little bit of further commentary, it's worth noting that there is no method for GRanges:

> methods('seqlengths')
[1] seqlengths,ANY-method     seqlengths,Seqinfo-method
see '?methods' for accessing help and source code

and that's because of the interesting pattern where the implementation of ANY is based on reuse of the Seqinfo method:

> getMethod("seqlengths", "ANY")
Method Definition:

function (x)
seqlengths(seqinfo(x))
<bytecode: 0x7f90c8438a38>
<environment: namespace:GenomeInfoDb>

Signatures:
        x
target  "ANY"
defined "ANY"

and actually GenomicRanges (re)exports the seqinfo generic

> GenomicRanges::seqinfo
standardGeneric for "seqinfo" defined from package "GenomeInfoDb"
...

and relevant methods

> getMethod("seqinfo", "GRanges")
Method Definition:

function (x)
x@seqinfo
<bytecode: 0x7f90c32a8d98>
<environment: namespace:GenomicRanges>

Signatures:
        x
target  "GRanges"
defined "GRanges"

These would be good discussions for the bioc-devel mailing list (for package development, which I believe is what is going on here?) or the Bioconductor community slack.

ADD REPLY
0
Entering edit mode

Thankyou Martin, also for the reference to BioC community slack, which I was yet unaware of :-).

ADD REPLY
0
Entering edit mode

Thankyou Michael :-)

ADD REPLY

Login before adding your answer.

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