Question: Detecting Overlaps within Grange Object
gravatar for g.k
12 months ago by
g.k0 wrote:


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.


iranges granges R grange • 270 views
ADD COMMENTlink modified 12 months ago by Michael Lawrence10k • written 12 months ago by g.k0
Answer: Detecting Overlaps within Grange Object
gravatar for Michael Lawrence
12 months ago by
United States
Michael Lawrence10k wrote:

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 COMMENTlink written 12 months ago by Michael Lawrence10k

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

ADD REPLYlink modified 11 months ago • written 11 months ago by g.k0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 231 users visited in the last hour