Filter overlapping entries in bed file Filter overlapping entries in bed file shell shell

Filter overlapping entries in bed file


OK, I worked this out:

1) Count the overlaps in the original input

bedtools merge -i IN.bed -c 1 -o count > counted

2) Filter out only those rows that do not overlap with anything

awk '/\t1$/{print}' counted > filtered

3) Intersect it with the original input and keep only those original rows that were found after filtering as well

bedtools intersect -a IN.bed -b filtered -wa > OUT.bed