intersectBed - multiple intersections
2
0
Entering edit mode
7.3 years ago
mbk0asis ▴ 680

Hi, all!

I have two bed files to find common SNP's between them.

$ cat targets.bed
chr15   2462    2462    DNMT1-1
chr15   2463    2463    DNMT1-2

$ cat sample.33.bed
chr15   2461    2461    Idx.Pr.33
chr15   2462    2462    Idx.Pr.33

I expected the overlap at '2462'

chr15   2462    2462    DNMT1-1    chr15   2462    2462    Idx.Pr.33

instead I had three over laps

$ intersectBed -wa -wb -loj -a targets.bed -b sample.33.bed 
chr15   2462    2462    DNMT1-1 chr15   2461    2461    Idx.Pr.33
chr15   2462    2462    DNMT1-1 chr15   2462    2462    Idx.Pr.33
chr15   2463    2463    DNMT1-2 chr15   2462    2462    Idx.Pr.33

I think this reuslt was caused because the bedtools uses 0-based coordinate system.

How can I solve this problem?

Thank you!

bedtools intersectBed • 1.7k views
ADD COMMENT
0
Entering edit mode

BED uses coordinates in a half-open interval, so if you are using a BED file to define the position of a base in a SNP, the start position should be one less than the stop position (or the stop position one more than the start, depending on your original coordinate system).

ADD REPLY
0
Entering edit mode
7.3 years ago
Jeffin Rockey ★ 1.3k

Just like you doubted, please make both the bed files in proper bed format and then do intersect. This link may help you with the co-ordinates systems. It has nice illustrations.

Still, the result would have non overlapping entry like below since -loj option is used

chr15   2461    2462    DNMT1-1 chr15   2461    2462    Idx.Pr.33
chr15   2462    2463    DNMT1-2 .       -1      -1              .
ADD COMMENT
0
Entering edit mode
7.3 years ago
sysbiocoder ▴ 180

The following command report only those intersections where 100% of the query record is overlapped

bedtools intersect -wa -wb -a targets.bed -b sample.33.bed -sorted -f 1.0

ADD COMMENT

Login before adding your answer.

Traffic: 2426 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