Hello,

I have a BED file that has many intervals that are overlapping.

My objective is to merge the intervals to see how much of the chromosome the bed file spans.

BEDtools merge was my natural go-to method, however, there's a catch.

I only want to merge overlaps that reciprocally overlap by say, 90%. BEDtools merge as far as I know, doesn't have this feature. Does anyone know any tool that I can use that can do this?

Thanks a bunch and merry Christmas!
With [BEDOPS][1] *[bedmap][2]*:

    $ bedmap --count --echo-map-range --fraction-both 0.9 --delim '\t' intervals.bed \
        | awk '$1>1' - \
        | cut -f2- - \
        | sort-bed - \
        | uniq - \
        > answer.bed

If the intervals are unsorted or are of unknown sort state, first [sort][3] before mapping:</p>

    $ sort-bed intervals.unsorted.bed > intervals.bed

On further thought, I think you may want to filter single-overlap cases; please see discussion further in this thread.

**Edit:** Changed `--fraction-either` to `--fraction-both` to do a correct mutual overlap test.


  [1]: http://bedops.readthedocs.io/en/latest/index.html
  [2]: http://bedops.readthedocs.org/en/latest/content/reference/statistics/bedmap.html
  [3]: http://bedops.readthedocs.org/en/latest/content/reference/file-management/sorting/sort-bed.html