Hi all,
I expect that this is doable with bedtools or similar, but I haven't figured it out yet.
If I start with a file like this:
chr1 2582250 2583750 6.5558
chr1 2582625 2584125 9.03696
chr1 2583000 2584500 13.3717
chr1 2583375 2584875 19.4317
how can I generate this result, which averages the scores across regions that are redundantly covered?
chr1 2582250 2582625 $avg(6.5558)
chr1 2582625 2583000 $avg(6.5558, 9.03696)
chr1 2583000 2583375 $avg(6.5558, 9.03696, 13.3717)
chr1 2583375 2583750 $avg(6.5558, 9.03696, 13.3717, 19.4317)
chr1 2583750 2584125 $avg(9.03696, 13.3717, 19.4317)
chr1 2584125 2584500 $avg(13.3717, 19.4317)
chr1 2584500 2584875 $avg(19.4317)
Thanks Alex,
I tried your suggestion on the example input above, but got the following output:
Any ideas?
Ah. Looks like my file needed 5 columns. I added a dummy column in col 4 and the means are calculated on the fifth column.
Sorry, I meant BED5, not BED4. I've amended my answer. Need coffee.