Bedtools intersect, order of input bed files result in different outputs?
2
1
Entering edit mode
3.5 years ago
kstangline ▴ 80

I'm curious as to why I'm getting two different values with bedtools intersect with two sorted bedfiles:

bedtools intersect -u -a test1.bed -b test2.bed | wc -l

This gives me 157,273

However, when swapping -a and -b:

bedtools intersect -u -a test2.bed -b test1.bed | wc -l

This gives me 158,095

bedtools • 1.2k views
ADD COMMENT
3
Entering edit mode
3.5 years ago
Juke34 8.9k

This is normal that order affect the result. Read carfully the help https://bedtools.readthedocs.io/en/latest/content/tools/intersect.html

First you report all sequence from A that overlap B
And secondly you report all sequence B that overlap A

The only case where both will give you the same result it is if the two files are identical

ADD COMMENT
1
Entering edit mode
3.5 years ago
gglim ▴ 210

I think -u is the keypoint. If you run intersect without -u option, the result number will be the same.

ADD COMMENT

Login before adding your answer.

Traffic: 2823 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6