Hi,
I have a bed file of many overlapping regions, sorted by precedence (in score column). I would like each basepair defined by the file to be present no more than once, assigned to a the lowest value score of any of the regions in the bed file that contain that basepair.
eg:
➜ cat input.bed
chr1 20 30 Region_B 1 +chr1 10 40 Region_A 2 +
chr1 35 50 Region_C 3 +
should become:
➜ cat output.bed
chr1 20 30 Region_B 1 +chr1 10 20 Region_A 2 +
chr1 30 40 Region_A 2 +chr1 40 50 Region_C 3 +
Is there a bedtools way to do this efficiently?
The 'best' solution I have found is:
touch output.bed;
while read regionline; do
echo "$regionline" \
| subtractBed -a - -b output.bed \
>> output.bed; \
done <input.bed
As you would expect, this is very slow.
Many thanks,
Luke