Bedtools Intersect related
1
0
Entering edit mode
3.2 years ago
chaudharyc61 ▴ 70

Hello everyone

Let's say i have three files A.bed, B.bed and C.bed which are having coordinates of peaks. Using bed-tools intersect i got common peaks or i guess those are common.

My question is: Is there any other way using bed-tools by which i can find the exact common peaks from all the three files ?

Thanx

bedtools ChIP-Seq bedfiles Tool • 851 views
0
Entering edit mode
3.2 years ago
2nelly ▴ 310

Hi chaudharyc61,

Can you please define better the "exact common peaks"?

If you mean to have 100% overlap, you can do this by using the parameters -f 1 to match 100% the file1 or -F 1 to match 100% the file2. If you want to set different % of overlap just try to adjust the values between 0-1 (e.g 0.2 is 20%)

However, I have to tell you that I don t agree with this strategy, since it is practically impossible to get sooooo precise coordinates during peak calling amongst different samples

0
Entering edit mode

The thing is i have different replicates of same experiment and to get significant peaks i'm using this approach as if same peak is coming in all the three files it has more chances to be called as significant peak.

In that way i have to find same peaks through out three files and manually it is not doable. so which way should i go to filter out common peaks in three files

I tried doing A.bed vs B.bed and the result of A and B, with C.bed this is giving me some replicates in the end result file

0
Entering edit mode

But I still believe that it is impossible to get the exact start and end position in you replicates. Maybe you should try to decrease the level of strictness (50% overlap or less).

I don t know why you get those duplicates. This depends on the output file parameters you set, like -wa -wb etc. Can you post some example?

0
Entering edit mode

I havn't used any strictness and this is the command i used

bedtools intersect -a A.bed -b B.bed > Inter.bed bedtools intersect -a Inter.bed -b C.bed > Final.bed

Using this my logic is the common peaks from A and B i can get common peak from C

0
Entering edit mode

Yes that s true. In that case you report the common peaks as the fraction of overlap:

By default, if an overlap is found, bedtools intersect reports the shared interval between the two overlapping features

$cat A.bed chr1 10 20 chr1 30 40$ cat B.bed
chr1  15   20

$bedtools intersect -a A.bed -b B.bed chr1 15 20  You can also use the multiple file function $ cat query.bed
chr1  1   20
chr1  40  45
chr1  70  90
chr1  105 120
chr2  1   20
chr2  40  45
chr2  70  90
chr2  105 120
chr3  1   20
chr3  40  45
chr3  70  90
chr3  105 120
chr3  150 200
chr4  10  20

$cat d1.bed chr1 5 25 chr1 65 75 chr1 95 100 chr2 5 25 chr2 65 75 chr2 95 100 chr3 5 25 chr3 65 75 chr3 95 100$ cat d2.bed
chr1  40  50
chr1  110 125
chr2  40  50
chr2  110 125
chr3  40  50
chr3  110 125

$cat d3.bed chr1 85 115 chr2 85 115 chr3 85 115$ bedtools intersect -a query.bed \
-b d1.bed d2.bed d3.bed
chr1  5   20
chr1  40  45
chr1  70  75
chr1  85  90
chr1  110 120
chr1  105 115
chr2  5   20
chr2  40  45
chr2  70  75
chr2  85  90
chr2  110 120
chr2  105 115
chr3  5   20
chr3  40  45
chr3  70  75
chr3  85  90
chr3  110 120
chr3  105 115