Question: Width in IRanges objects on "+" and "-" strand
gravatar for Walter F. Baumann
7 months ago by
Walter F. Baumann 10 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 7 months ago by Michael Lawrence9.9k • written 7 months ago by Walter F. Baumann 10
gravatar for Michael Lawrence
7 months ago by
United States
Michael Lawrence9.9k 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 7 months ago by Michael Lawrence9.9k
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: 360 users visited in the last hour