Entering edit mode
7.1 years ago
Medhat
9.8k
I have two files A.bed
chr1 100 200
chr1 800 900
B.bed
chr1 130 201
chr1 180 220
chr1 600 700
I want to intersect A with B. But also I want in the results what is in B that does not intersect with A
So If I used
bedtools intersect -a A.bed -b B.bed -r -wao
chr1 100 200 chr1 130 201 70
chr1 100 200 chr1 180 220 20
chr1 800 900 . -1 -1 0
but I will miss
chr1 600 700 . -1 -1 0
which I could get from
bedtools intersect -a B.bed -b A.bed -r -wao
chr1 130 201 chr1 100 200 70
chr1 180 220 chr1 100 200 20
chr1 600 700 . -1 -1 0
I want the end result to be something like:
chr1 100 200 chr1 130 201 70
chr1 100 200 chr1 180 220 20
chr1 800 900 . -1 -1 0
chr1 600 700 . -1 -1 0
what I can do is:
bedtools intersect -a A.bed -b B.bed -r -wao > result.bed
bedtools intersect -a B.bed -b A.bed -r -wao | awk '{if($NF == 0){print $0}}' >> result.bed
But I do not think that this is the right way
Thanks,
I tried it first but does not give the desired results:
It will give
and u can use
bedtools sort -i stdin
will do the same result assort -k1,1 -k2,2n