Biostar Beta. Not for public use.
Question: Can bedtools subtract support multiple files?
0
Entering edit mode

I have four BED files with data from different conditions (let's say A B C and D). I want to make a file (using bedtools subtract) that have those regions specific to A. Since bedtools subtract works pairwise, I should do (manual example):

bedtools subtract -a A.bed –b B.bed > temp1.bed 
bedtools subtract -a temp1.bed –b C.bed > temp2.bed
bedtools subtract -a temp2.bed –b D.bed > only_A.bed

By any chance bedtools has a way of doing it for multiple files? such as

bedtools subtract -a A.bed –b B.bed C.bed D.bed > only_A.bed

On its manual entry is not very clear, but they have done it for other tools such as intersect. Thank you !

ADD COMMENTlink 11 months ago msimmer92 • 180
2
Entering edit mode

To avoid intermediary files, you can chain the commands with pipes:

bedtools subtract -a A.bed -b B.bed \
  | bedtools subtract -a stdin -b C.bed \
  | bedtools subtract -a stdin -b D.bed > only_A.bed

Two notes:

1) I believe you meant bedtools subtract -a temp2.bed –b D.bed > only_A.bed at you third command, correct?

2) be careful with hyphens (used to indicate command-line parameters) and paragraph marks. Your command-lines above correctly use hyphens for -a, but incorrectly use paragraph dash for –b.

edit: I don't know if bedtools subtract -b accepts multiple files (I think it doesn't), but you can easily check for yourself: just try it and compare the results with the output of the multiple commands with intermediary files.

ADD COMMENTlink 11 months ago h.mon 25k
Entering edit mode
0

Thank you for your answer! Yes, I had a typo in temp2.bed, I just edited it. The hyphen and paragraph dash thing might be because I wrote this on a Word document where I keep record of what I do and then copied from there and pasted it here.. sometimes when you copy and paste stuff to programs such as Word some of these things change automatically, but I use hyphens for the parameters. I did not notice they appeared different when I posted this.. And yes, I can try it myself but I figured to write here in case there's someone that did it before and has some important observations about it. I will do it now.

ADD REPLYlink 11 months ago
msimmer92
• 180

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.0