Question: Is range validity checked after GRanges operations?
1
gravatar for Aditya
19 days ago by
Aditya120
Germany
Aditya120 wrote:

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

genomicranges • 75 views
ADD COMMENTlink modified 19 days ago • written 19 days ago by Aditya120
Answer: Is range validity checked during range operations on GenomicRanges::GRanges?
2
gravatar for Aditya
19 days ago by
Aditya120
Germany
Aditya120 wrote:

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 COMMENTlink modified 19 days ago • written 19 days ago by Aditya120

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 REPLYlink written 18 days ago by Hervé Pagès ♦♦ 14k

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

ADD REPLYlink written 14 days ago by Aditya120
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 253 users visited in the last hour