Hi everyone,

I have used the "findOverlaps" function in R to find which positions of my two datasets overlap. I have also used "countOverlaps" to see how many overlaps I have.

What I want to do now, is to find the exact coordinates which overlapped. I was looking how to do it using findOverlaps but it has no such options and by doing a google search, I couldn't find much help.

A little help on this would be greatly appreciated.

Thank you
The `findOverlaps()` method is not the right tool for the job. Instead, you want the set intersection which can be obtained with `intersect()` on two GRanges objects.

    # create two GRanges objects for testing
    gr1 = GRanges(seqnames='chr1',ranges=IRanges(start=seq(1,1001,100),width=50))
    gr2 = GRanges(seqnames='chr1',ranges=IRanges(start=seq(25,1025,100),width=50))
    
    # and "intersect" them, finding the set of regions
    # formed by the overlaps of gr1 and gr2
    gr3 = intersect(gr1,gr2)
    
    # and the result
    gr3
    
    GRanges object with 11 ranges and 0 metadata columns:
           seqnames       ranges strand
              <Rle>    <IRanges>  <Rle>
       [1]     chr1 [  25,   50]      *
       [2]     chr1 [ 125,  150]      *
       [3]     chr1 [ 225,  250]      *
       [4]     chr1 [ 325,  350]      *
       [5]     chr1 [ 425,  450]      *
       [6]     chr1 [ 525,  550]      *
       [7]     chr1 [ 625,  650]      *
       [8]     chr1 [ 725,  750]      *
       [9]     chr1 [ 825,  850]      *
      [10]     chr1 [ 925,  950]      *
      [11]     chr1 [1025, 1050]      *
      -------
      seqinfo: 1 sequence from an unspecified genome; no seqlengths