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
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?