Hello,
I want to use bedtools intersect to compare multiple pairs of files. For example, I have folder1, and file1 and file2 in it and then folder2, file3 and file4 in it etc. I want to find a way that do all these comparison in a loop or with pipe '|' .
I know how to do this with one pair , like bedtools intesect -a file1 -b file2. Then how can I do this if I have 90 pairs of files and they are all different samples?
If I want to use ls | xargs bedtools intersect , it is still won't work. or how can I tell each -a -b position the correct standard input or argument from previous one?
I hope I stated my questions clearly enough and appreciate any idea. Thanks.
Thanks for the reply. However, I have the two files in dir1 which I want to compare. file1 ad file2 are in the same folder. Then I don't think this will work for my case. But it provided a solution. I will try to work more on it.
You can put any bash command in the
$()
so you canls
certain files,grep
or do whatever you like.The best choice, however, is to take the time and implement it as a nextflow or snakemake pipeline, future you will thank you when you'll have to repeat it in the future because you found a small bug, changed the input files or just wanted to publish a reproducible analysis.