1

I have a GRange object with a large number of ranges, some of which overlap. What I want to do is, if the intervals are within a certain distance, say 10,000, then combine the two intervals.

I've tried converting it to a data frame and IRange, and fiddling the with data that way, but I haven't gotten any positive results, and I don't know how to proceed.

chrC[1]
GRangesList object of length 1:
$chr1 
GRanges object with 338 ranges and 2 metadata columns:
        seqnames              ranges strand |        name     score
           <Rle>           <IRanges>  <Rle> | <character> <numeric>
    [1]     chr1     2263697-2280639      + | chr1-153498         1
    [2]     chr1     2651953-2656424      + |  chr1-37327         1
    [3]     chr1     6054865-6102062      + | chr1-144080         1
    [4]     chr1     6305350-6315334      + | chr1-135452         1
    [5]     chr1     6316152-6361724      + | chr1-111563         1
    ...      ...                 ...    ... .         ...       ...
  [334]     chr1 246213308-246216778      + | chr1-136958         1
  [335]     chr1 246218115-246221509      + | chr1-127346         1
  [336]     chr1 246959265-246960153      + | chr1-147672         1
  [337]     chr1 247387279-247394255      + | chr1-115115         1
  [338]     chr1 248871488-248874386      + |  chr1-93112         1

-------
seqinfo: 24 sequences from an unspecified genome; no seqlengths

this would be the GRange object. I would like to merge for instance, [4] and [5] into a single interval.

Lu Charles
  • 11
  • 1
  • 2
  • 1
    Personally I've only merged overlapping time values within a date. This post might be relevant - https://stackoverflow.com/questions/19101849/overlapping-genomic-ranges – M.Viking Jun 21 '19 at 16:27
  • 1
    Maybe - https://rdrr.io/github/GabrielHoffman/tfbsDB/man/mergeOverlapping.html – M.Viking Jun 21 '19 at 16:30
  • Could you post a `dput` output of the data frame you obtained after converting? – Alexis Jun 21 '19 at 20:16

1 Answers1

2

Try reduce(chrC[1]) from here: An Introduction to the GenomicRanges Package

Avi
  • 107
  • 1
  • 8