This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bedtools intersect issue

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

-s parameter in the second command restricts the overlap to the same strand as described in the bedtools intersect manual pages. Are you looking for strand-specific overlaps between two .bed file?

-s  Force “strandedness”. That is, only report hits in B that overlap A on the same strand. By default, overlaps are reported without respect to strand.

I know, that exactly what I want and it doesn't seem to work.

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

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

??

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.

I edited the post, but those are only the first 10 lines, actually, they have overlap, as you can see in the first result.

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?

I am using version: v2.26.0

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.

That's really weird, and yes, for the example I posted I get an output as I posted either.

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

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

0 answers

No answers yet.

Log in to answer this question.