I have a simple problem that I think could be resolved with current software; however I can't find a solution.
I am using a program that produces a bedgraph with overlapping intervals for example:
chr1 0 100 2 chr1 50 150 1 chr1 100 200 3
I would like to obtain a bedgraph that computes the maximum (or any other operation) for the overlapping regions. For example, using the maximum the output should look like:
chr1 0 50 2 chr1 50 100 2 chr1 100 150 3 chr 1 150 200 3
I tried using unionbg from bedtools which is expected to do something very similar to what I want but it requires more than one file and, if the same file is given twice, the output is not what I am looking for. merge, from bedtools is not useful because it will merge all regions into a single one.
I already wrote a simple script to solve the problem but only handles the case of two overlaps as in the previous example and I am under the impression that a faster and more powerful solution should be available.