Question: Detecting Overlaps within Grange Object
0
15 months ago by
g.k0
g.k0 wrote:

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.

iranges granges R grange • 327 views
modified 15 months ago by Michael Lawrence11k • written 15 months ago by g.k0
Answer: Detecting Overlaps within Grange Object
1
15 months ago by
United States
Michael Lawrence11k 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.