Width in IRanges objects on "+" and "-" strand
1
0
Entering edit mode
@walter-f-baumann-12439
Last seen 7.0 years ago

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]      -

 

iranges granges grangeslist • 1.1k views
ADD COMMENT
1
Entering edit mode
@michael-lawrence-3846
Last seen 2.9 years ago
United States

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 COMMENT

Login before adding your answer.

Traffic: 926 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6