Entering edit mode
Is range validity checked for when performing range operations on GenomicRanges::GRanges
?
Is range validity checked for when performing range operations on GenomicRanges::GRanges
?
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.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
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.
Thank you Herve, that's really useful to know!