bedtools intersect issue
0
0
Entering edit mode
5.8 years ago
elisheva ▴ 120

Hi everyone! I have 2 bed files:

A.bed

chr1    1090377 1090381 1       1       +
chr1    1090377 1090381 1       1       +
chr1    1090415 1090419 1       1       +
chr1    1090425 1090429 1       1       +
chr1    1090442 1090446 1       1       -
chr1    1090575 1090579 1       1       -
chr1    1090661 1090665 1       1       +
chr1    1090744 1090748 1       1       +
chr1    1090747 1090751 1       1       -
chr1    1090815 1090819 1       1       +


B.bed

chr1    1090351 1096351 1093351 1       +
chr1    1437425 1443425 1440425 1       +
chr1    1837483 1843483 1840483 1       +
chr1    6792385 6798385 6795385 1       +
chr1    6800919 6806919 6803919 1       +
chr1    8011248 8017248 8014248 1       +
chr1    8061773 8067773 8064773 1       +
chr1    8097782 8103782 8100782 1       +
chr1    8103290 8109290 8106290 1       +
chr1    8104835 8110835 8107835 1       +


and I want to find all intervals that are both in A and B. I used bedtools version v2.26.0 intersect for it:

bedtools intersect -wa -a A.bed -b B.bed


and got:

chr1    1090377 1090381 1       1       +
chr1    1090377 1090381 1       1       +
chr1    1090415 1090419 1       1       +
chr1    1090425 1090429 1       1       +
chr1    1090442 1090446 1       1       -
chr1    1090575 1090579 1       1       -
chr1    1090661 1090665 1       1       +
chr1    1090744 1090748 1       1       +
chr1    1090747 1090751 1       1       -
chr1    1090815 1090819 1       1       +


However, when I tried to force strandedness by adding -s to the command:

bedtools intersect -wa -a A.bed -b B.bed -s


I got no result.

What could be the reason for it?

bed bedtools • 2.1k views
0
Entering edit mode

Are you sure that you show us the correct content of A.bed? The coordinates are much smaller than those by B.bed.

fin swimmer

0
Entering edit mode

Yes, I know, but that what I want to get eventually.

0
Entering edit mode

??

The both files you show have no overlap. Even without having a look on the strands.

The output of $bedtools intersect -wa -a A.bed -b B.bed is also empty. ADD REPLY 0 Entering edit mode I edited the post, but those are only the first 10 lines, actually, they have overlap, as you can see in the first result. ADD REPLY 0 Entering edit mode Ok, but please show us lines that should overlap. Without it is impossible to test. BTW: Standard question: What version of bedtools are you using? ADD REPLY 0 Entering edit mode I am using version: v2.26.0 ADD REPLY 0 Entering edit mode Current version is v2.27.1. But I've tested your updated example data in both version and it works for me $ bedtools intersect -wa -a A.bed -b B.bed
chr1    1090377 1090381 1   1   +
chr1    1090377 1090381 1   1   +
chr1    1090415 1090419 1   1   +
chr1    1090425 1090429 1   1   +
chr1    1090442 1090446 1   1   -
chr1    1090575 1090579 1   1   -
chr1    1090661 1090665 1   1   +
chr1    1090744 1090748 1   1   +
chr1    1090747 1090751 1   1   -
chr1    1090815 1090819 1   1   +


and

$bedtools intersect -wa -a A.bed -b B.bed -s chr1 1090377 1090381 1 1 + chr1 1090377 1090381 1 1 + chr1 1090415 1090419 1 1 + chr1 1090425 1090429 1 1 + chr1 1090661 1090665 1 1 + chr1 1090744 1090748 1 1 + chr1 1090815 1090819 1 1 +  Do you get an output with the subset example you've posted? If so than your original bed file is corrupted somehow. ADD REPLY 0 Entering edit mode That's really weird, and yes, for the example I posted I get an output as I posted either. ADD REPLY 0 Entering edit mode can confirm finswimmer ' s observation with OP data: $ bedtools intersect -wa -a a.bed -b b.bed -s
chr1    1090377 1090381 1   1   +
chr1    1090377 1090381 1   1   +
chr1    1090415 1090419 1   1   +
chr1    1090425 1090429 1   1   +
chr1    1090661 1090665 1   1   +
chr1    1090744 1090748 1   1   +
chr1    1090815 1090819 1   1   +

$bedtools --version bedtools v2.27.1  ADD REPLY 0 Entering edit mode Even with bedtools version v2.25.0: $ bedtools intersect -wa -a A.bed -b B.bed -s
chr1    1090377 1090381 1   1   +
chr1    1090377 1090381 1   1   +
chr1    1090415 1090419 1   1   +
chr1    1090425 1090429 1   1   +
chr1    1090661 1090665 1   1   +
chr1    1090744 1090748 1   1   +
chr1    1090815 1090819 1   1   +

\$ bedtools  --version
bedtools v2.25.0