title: How to export overlapped GRanges object as new bed file in R?
body: <p>I have used findOverlaps(bed.1, bed.2) to get overlapped regions, now I want to export the result into new bed files such as "xx.bed". How can I do that in R ? </p>
  
  <pre><code>overlapped GRanges object with 6 ranges and 3 metadata columns: (example)
  
        seqnames           ranges strand |         name     score    pvalue
           &lt;Rle&gt;        &lt;IRanges&gt;  &lt;Rle&gt; |  &lt;character&gt; &lt;numeric&gt; &lt;numeric&gt;
    [1]     chr1 [ 32726,  32784]      * |  MACS_peak_7      2.06 0.3138672
    [2]     chr1 [ 52473,  52531]      * | MACS_peak_11      2.06 0.3138672
    [3]     chr1 [136387, 136469]      * | MACS_peak_32      3.40 0.5314789
    [4]     chr1 [235352, 235410]      * | MACS_peak_41      2.06 0.3138672
    [5]     chr1 [540756, 540833]      * | MACS_peak_71      6.42 0.8075350
    [6]     chr1 [636637, 636718]      * | MACS_peak_90      4.86 0.6866363
  </code></pre>
  
  <p>Now I want to export these into new bed files. Which R function can do this ? Is there any simple R code to do this? Thanks</p>