Question: Detecting Overlaps within Grange Object
0
gravatar for g.k
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
ADD COMMENTlink modified 15 months ago by Michael Lawrence11k • written 15 months ago by g.k0
Answer: Detecting Overlaps within Grange Object
1
gravatar for Michael Lawrence
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.

ADD COMMENTlink written 15 months ago by Michael Lawrence11k

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

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

Help
Access

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