Question: Retrieving overlaps inside a single dataset using foverlaps
0
gravatar for startup_biostar
4.6 years ago by
startup_biostar10 wrote:

1 chr1 58710367 58719391

2 chr1 58710476 58716325

Got a data as above in a single dataset. How to use foverlaps to perform Union ?

This should return 1 chr1 58710367 58719391.

How would I do that?

if it was

1 chr1 58710367 58719391

2 chr1 58719390 58719999

This should return 1 chr1 58710367 58719999

rna-seq foverlaps • 1.5k views
ADD COMMENTlink modified 4.6 years ago by Amirosein70 • written 4.6 years ago by startup_biostar10
2
gravatar for Amirosein
4.6 years ago by
Amirosein70
UBC, Vancouver, CA.
Amirosein70 wrote:

you can use reduce() to perform union, for example we first make a GRanges object with your coordinates:

sep = GRanges( seqnames = "chr1", ranges = IRanges(start=c(58710367,58710476),end=c(58719391, 58716325)), strand = "+")

resulting:

GRanges object with 2 ranges and 0 metadata columns:
  seqnames               ranges strand
     <Rle>            <IRanges>  <Rle>
[1]     chr1 [58710367, 58719391]      +
[2]     chr1 [58710476, 58716325]      +

and then using reduce() to perform union:

U = reduce( sep )

resulting:

GRanges object with 1 range and 0 metadata columns:
  seqnames               ranges strand
     <Rle>            <IRanges>  <Rle>
[1]     chr1 [58710367, 58719391]      +

Remember that this function is sensitive to strand direction and won't union intervals from "+" and "-" strands, but if strand sets to "*" it works

ADD COMMENTlink modified 4.6 years ago • written 4.6 years ago by Amirosein70
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: 1157 users visited in the last hour