Detecting Overlaps within Grange Object
1
0
Entering edit mode
g.k • 0
@gk-13275
Last seen 5.4 years ago

Hello,

I have a Grange object which contains coordinates.

I want to be able to remove the overlapping coordinates within the object following this rule :

End(B) > Start(A) & End(A) > Start(B) so  I  remove Coordinate B

For example :

          Chrom  Start    End Name Score Strand                       
  scaffold_98   8309   8313    .    .       -
  scaffold_98   8311   8327    .     .      -    
  scaffold_98   8820   8825    .     .      -    
  scaffold_98   8948   8952    .     .      -   

 

In this case I want to be able to remove the coordinate (8311,8327) because it overlaps with the previous coordinate.

 

r grange granges iranges • 1.4k views
ADD COMMENT
1
Entering edit mode
@michael-lawrence-3846
Last seen 2.4 years ago
United States

So you don't consider them overlapping if they overlap by 1 position? Or do you want end(b) >= start(a) & end(a) >= start(b)? Either way, that can be controlled via arguments to findOverlaps(). When passing a single ranges object to findOverlaps(), it will find overlaps within the set of ranges, and you can request that it ignore self and redundant hits. To always ignore the latter hit, just keep the elements where there is no matching range with a lower subscript. I think you can find the ones to exclude with pmin(queryHits(hits), subjectHits(hits)). Hopefully that is enough to get you started.

ADD COMMENT
0
Entering edit mode

Yes I do consider them overlapping  if they overlap by 1  position. Thank you I used findOverlaps() and it worked perfectly !

ADD REPLY

Login before adding your answer.

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