You're right. Maybe I made a typo or some other stupid mistake that caused my command to exit without any error or output.
Swapping the -a and -b solves the overall problem too, as the last field is picked from -a file by default. Thank you!
I have two bed files with 4 columns each and I'd like to intersect the bed files, then carry over the 4th column of one of the files as the 4th column of the result.
depth.bed, an output file from mosdepth, has very short intervals (from 1bp to ~200bp each).
exons.bed is a regular BED file with exon coordinates
When I tried bedtools intersect -a depth.bed -b exons.bed, there was no result as (I'm guessing) bedtools expect -a to be the file with the large intervals. I flipped the inputs and used bedtools intersect -a exons.bed -b depth.bed and this time, it worked fine.
However, the output now has the 4th column from exons.bed whereas I need the 4th column from depth.bed. I added the -wb option to get that included but what happens now is that I get the 4th column from exons.bed AND all 4 columns from depth.bed. I can use cut or awk to get just the columns I need, but is there any way to ask bedtools to give me just depth.bed's 4th column without adding a bunch of other stuff? Essentially, can I annotate my damn BED file with one column from another bed file?
This is odd. It should not matter which file is a and which is b. The overlap should always be reported.
$ cat small.bed
chr1 1 10
$ cat large.bed
chr1 1 100000
$ bedtools intersect -a small.bed -b large.bed
chr1 1 10
$ bedtools intersect -b small.bed -a large.bed
chr1 1 10
You're right. Maybe I made a typo or some other stupid mistake that caused my command to exit without any error or output.
Swapping the -a and -b solves the overall problem too, as the last field is picked from -a file by default. Thank you!
Log in to answer this question.