GRanges: remove ranges that falls in between a larger range?
1
0
Entering edit mode
4.7 years ago
simplitia ▴ 130

Hi suppose I have a grange object as such,

g <- GRanges(seqnames=c(rep("Chr1",3)), strand=rep("+",3), ranges=IRanges(start=c(10,2,2), end=c(24,27,30)))

this produces a grange that looks like this.

GRanges object with 3 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     Chr1     10-24      +
  [2]     Chr1      2-27      +
  [3]     Chr1      2-30      +

so if you look carefully, bot line 1 and line 2 ( 10-24 and 2-27) falls within line 3 ( 2-30), is there a way I can get rid of any of any ranges that falls under a larger range. So the table above, line 1 and line 2 should be removed since both fall within line 3.

thanks!

grange RNA-Seq r • 1.7k views
ADD COMMENT
2
Entering edit mode
4.7 years ago
Strand NGS ▴ 40

Hi You can try out reduce function

reduce(g) 

GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     Chr1      2-30      +
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
ADD COMMENT

Login before adding your answer.

Traffic: 1093 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