I have two bed files. I want to find the regions of non-overlap between the two; for example, I have bed A and bed B, and I want to find the subregions in A that don't overlap with B.
A
1 1 10
1 15 20
B
1 5 10
1 17 20
I want to get
1 1 5
1 15 17
I was considering bedtools intersect -v
, but I think that would just give me full regions of A that do not intersect at all with B, whereas I am also interested in the subregions that don't intersect with B, for regions that intersect partially with B.
Wouldn't this give me intervals of B that are only covered once? For example, if I had:
Wouldn't this still give the answer I posted originally? I wouldn't want this because in this case the 15 - 17 interval comes from B, whereas I just want the intervals covered only by A.
It matches exactly the example result you posted. Anyway, you can pass the
-names
option to display from which file the intervals come and then apply further filtering: