Question: How to find more than 'n %' overlapping ranges using GRanges package ?
0
gravatar for Chirag Parsania
2.5 years ago by
Chirag Parsania1.7k
University of Macau
Chirag Parsania1.7k wrote:

Hi,

I have two dataframes (in R) A and B of Granges. feature mentioned in the B is within the feature of A.

> a
GRanges object with 2 ranges and 0 metadata columns:
                    seqnames           ranges strand
                       <Rle>        <IRanges>  <Rle>
  [1] ChrD_C_glabrata_CBS138 [451956, 454735]      +
  [2] ChrD_C_glabrata_CBS138 [451956, 454735]      +
  -------
  seqinfo: 14 sequences from an unspecified genome; no seqlengths

> b 
GRanges object with 2 ranges and 0 metadata columns:
                    seqnames           ranges strand
                       <Rle>        <IRanges>  <Rle>
  [1] ChrD_C_glabrata_CBS138 [452667, 454092]      +
  [2] ChrD_C_glabrata_CBS138 [452667, 454092]      +
  -------
  seqinfo: 14 sequences from an unspecified genome; no seqlengths

findOverlaps from GRanges package gives following output

> findOverlaps(a,b)
Hits object with 4 hits and 0 metadata columns:
      queryHits subjectHits
      <integer>   <integer>
  [1]         1           1
  [2]         1           2
  [3]         2           1
  [4]         2           2
  -------
  queryLength: 2 / subjectLength: 2

I want subject hits only if query covered by > 90 %. I tried minoverlap argument of findOverplaps but no success. Or In other words, for a given query feature how to find what % of the query overlapped with subject hits ?

Expected output should not contain any subject hits.

> findOverlaps(a,b)
Hits object with 0 hits and 0 metadata columns:
   queryHits subjectHits
   <integer>   <integer>
  -------
  queryLength: 2 / subjectLength: 2

~Chirag.

granges genomicranges R • 784 views
ADD COMMENTlink modified 2.5 years ago • written 2.5 years ago by Chirag Parsania1.7k
1

You can use pintersect function from IRanges package.

http://svitsrv25.epfl.ch/R-doc/library/IRanges/html/IRanges-setops.html

ADD REPLYlink written 2.5 years ago by poojasethiya80

One of the solution I found here

https://support.bioconductor.org/p/72656/

ADD REPLYlink written 2.5 years ago by Chirag Parsania1.7k
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 2.3.0
Traffic: 1833 users visited in the last hour