Search
Question: Width in IRanges objects on "+" and "-" strand
0
gravatar for Walter F. Baumann
11 months ago by
Walter F. Baumann 10 wrote:

Hi, 

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 11 months ago by Michael Lawrence10.0k • written 11 months ago by Walter F. Baumann 10
1
gravatar for Michael Lawrence
11 months ago by
Michael Lawrence10.0k
United States
Michael Lawrence10.0k 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 11 months ago by Michael Lawrence10.0k
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 2.2.0
Traffic: 319 users visited in the last hour