Is range validity checked after GRanges operations?
1
1
Entering edit mode
Aditya ▴ 140
@aditya-7667
Last seen 15 days ago
Germany

Is range validity checked for when performing range operations on GenomicRanges::GRanges ?

GenomicRanges • 483 views
ADD COMMENT
2
Entering edit mode
Aditya ▴ 140
@aditya-7667
Last seen 15 days ago
Germany

Yes, it is.

Example GenomicRanges:

require(magrittr)
bsgenome <- BSgenome.Mmusculus.UCSC.mm10::BSgenome.Mmusculus.UCSC.mm10
granges <- GenomicRanges::GRanges(seqnames = 'chr1', 
                                  ranges   = IRanges::IRanges(start = 100, end = 200), 
                                  strand   = '-', 
                                  seqinfo  = BSgenome::seqinfo(bsgenome))

Coordinates < 1 warn:

GenomicRanges::start(granges) %<>% subtract(500)

Warning message:
In valid.GenomicRanges.seqinfo(x, suggest.trim = TRUE) :
GRanges object contains 1 out-of-bound range located on sequence chr1. Note that ranges located on a sequence whose length is unknown (NA) or on a circular sequence are not considered out-of-bound (use seqlengths() and isCircular() to get the lengths and  circularity flags of the underlying sequences). You can use trim() to trim these ranges. See   ?`trim,GenomicRanges-method` for more information.

coordinates > chrlength also do:

GenomicRanges::end(granges) %<>% add(1 + GenomeInfoDb::seqlengths(bsgenome)[['chr1']])

Warning message:
In valid.GenomicRanges.seqinfo(x, suggest.trim = TRUE) :
GRanges object contains 1 out-of-bound range located on sequence chr1. Note that ranges located on a sequence whose length is unknown (NA) or on a circular sequence are not considered out-of-bound (use seqlengths() and isCircular() to get the lengths and  circularity flags of the underlying sequences). You can use trim() to trim these ranges. See   ?`trim,GenomicRanges-method` for more information.
ADD COMMENT
0
Entering edit mode

Hi Aditya,

Glad you've figured this out.

FWIW note that the toy GRanges object you constructed in your example above can also conveniently be obtained with gr <- GRanges("chr1:100-200:-", seqinfo=seqinfo(bsgenome)).

Cheers,

H.

ADD REPLY
0
Entering edit mode

Thank you Herve, that's really useful to know!

ADD REPLY

Login before adding your answer.

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