I need to do operations on ranges from a circular sequence (chrM). My ranges sometimes spans the "end-start" gap, but I still would like to do overlap, unions and other operations on them.
I hoped that GenomicRanges could do this since I found a promising "isCircular"-flag. However I am not able create a GenomicRanges-object that has a range covering the end-start boundary. It is interpreted as having a negative width.
I was not able to find any examples with GenomicRanges used in this way, so I wonder if this functionality is implemented, and if so what do I do wrong?
Here is a really simple example where I try to create a GenomicRanges with one range covering the gap.
library(GenomicRanges) chrMseqinfo = Seqinfo("chrM", 16569, isCircular = TRUE, genome="GRCH38") df = data.frame(chr="chrM", start=16560, end=10, strand="+") gr = makeGRangesFromDataFrame(df=df, seqinfo=chrMseqinfo) # error, "negative widths are not allowed" sum(gr@ranges@width) # should be 20
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
attached base packages:
 parallel stats4 stats graphics grDevices utils datasets methods base
other attached packages:
 GenomicRanges_1.30.1 GenomeInfoDb_1.14.0 IRanges_2.12.0 S4Vectors_0.16.0
loaded via a namespace (and not attached):
 Rcpp_0.12.15 knitr_1.18 bindr_0.1
 XVector_0.18.0 magrittr_1.5 zlibbioc_1.24.0
 R6_2.2.2 rlang_0.1.6 dplyr_0.7.4
 tools_3.4.2 yaml_2.1.16 assertthat_0.2.0
 tibble_1.3.4 bindrcpp_0.2 GenomeInfoDbData_1.0.0
 purrr_0.2.4 tidyr_0.7.2 bitops_1.0-6
 RCurl_1.95-4.10 glue_1.2.0 compiler_3.4.2