Question: bedtools intersect issue
0
gravatar for elisheva
13 months ago by
elisheva80
Israel
elisheva80 wrote:

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 file intersect bedtools • 449 views
ADD COMMENTlink modified 13 months ago by Biostar ♦♦ 20 • written 13 months ago by elisheva80

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

ADD REPLYlink written 13 months ago by finswimmer12k

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

ADD REPLYlink written 13 months ago by elisheva80

??

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 REPLYlink written 13 months ago by finswimmer12k

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 REPLYlink written 13 months ago by elisheva80

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 REPLYlink written 13 months ago by finswimmer12k

I am using version: v2.26.0

ADD REPLYlink written 13 months ago by elisheva80

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 REPLYlink modified 13 months ago • written 13 months ago by finswimmer12k

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

ADD REPLYlink written 13 months ago by elisheva80

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 REPLYlink modified 13 months ago • written 13 months ago by cpad011212k

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
ADD REPLYlink written 13 months ago by michael.ante3.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1889 users visited in the last hour