title: Collapse intersecting regions
body: <p>I am trying to find a way to collapse rows with intersecting ranges, denoted by "start" and "stop" columns, and record the collapsed values into new columns. For example I have this data frame:</p>
  
  <pre><code>my.df&lt;- data.frame(chrom=c(1,1,1,1,14,16,16), name=c("a","b","c","d","e","f","g"), start=as.numeric(c(0,70001,70203,70060, 40004, 50000872, 50000872)), stop=as.numeric(c(71200,71200,80001,71051, 42004, 50000890, 51000952)))
  
  
  chrom name  start   stop
   1    a        0    71200
   1    b    70001    71200
   1    c    70203    80001
   1    d    70060    71051
  14    e    40004    42004
  16    f 50000872 50000890
  16    g 50000872 51000952
  </code></pre>
  
  <p>And I am trying to find the overlapping ranges and record the biggest range covered by the collapsed overlapping rows in "start" and "stop" and the names of the collapsed rows, so I would get this:</p>
  
  <pre><code>chrom start   stop      name
   1    70001    80001    a,b,c,d
  14    40004    42004    e
  16    50000872 51000952 f,g
  </code></pre>
  
  <p>I think I could use the packages IRanges like this:</p>
  
  <pre><code>library(IRanges)
  ranges &lt;- split(IRanges(my.df$start, my.df$stop), my.df$chrom)
  </code></pre>
  
  <p>But then I have trouble getting the collapsed columns: I have tried with findOvarlaps but this </p>
  
  <pre><code>ov &lt;- findOverlaps(ranges, ranges, type="any")
  </code></pre>
  
  <p>but I don't think this is right. </p>
  
  <p>Any help would be extremely appreciated.</p>