Question: Width in IRanges objects on "+" and "-" strand
gravatar for Walter F. Baumann
9 weeks ago by
Walter F. Baumann 0 wrote:


I have to create some GRanges objects, which are located on the + and - strand (The features represent regions on transcripts.). Here a reproducible example: 

GRanges(seqnames = Rle(c("chr1", "chr2", "chr3", "chr4")), 
        ranges = IRanges(10:13, width=3),
        strand = Rle(c("+", "-", "+", "-")))

However, IRanges works strand independent, meaning that 10+3, 11+3... but on the "-" strand, the start should be 8 and the end 11. I looked at the vignette, but did not find any information. I know there are workarounds, but I wondered if this might be somewhere implemented? 

I want: 

seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1  [10, 12]      +
  [2]     chr2  [9, 11]      -
  [3]     chr3  [12, 14]      +
  [4]     chr4  [11, 13]      -


ADD COMMENTlink modified 9 weeks ago by Michael Lawrence9.5k • written 9 weeks ago by Walter F. Baumann 0
gravatar for Michael Lawrence
9 weeks ago by
United States
Michael Lawrence9.5k wrote:

The resize() method on GRanges is strand aware, so you could do:

gr <- GRanges(seqnames = Rle(c("chr1", "chr2", "chr3", "chr4")), 
              ranges = IRanges(10:13, width=1L),
              strand = Rle(c("+", "-", "+", "-")))
resize(gr, 3L)


ADD COMMENTlink written 9 weeks ago by Michael Lawrence9.5k
Please log in to add an answer.


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