I have 4 standard bed files, a large general file and three smaller files.
I'd like to run
bedtools intersect to retain the peaks in the general file that overlap with peaks in at least two of the three smaller files keeping only the peak boundary limits of the general file peaks. This is the general command I'm looking at for this:
bedtools intersect -wa -a general.bed -b file1.bed file2.bed file3.bed
However, the flags for restricting the output based on the files passed to
-b relate only to the proportion of overlap in base pairs between the files (i.e. using
-F -f -r etc.). I don't see a way to restrict the general file based on overlaps with peaks contained in a set number of files sent to
-b - I hope this makes sense.
I have considered creating a consensus peak set of the smaller files first using
Diffbind retaining peaks contained in 2/3 files, then intersecting this consensus peak file with the general file, but I fear this method may drop/miss peaks that I'd like to retain.
Any suggestions regarding whether I can do this using bedtools, or an alternative method would be greatly appreciated.
@benformatics Yes - I was hoping there was something streamlined for this but perhaps it doesn't exist. Many thanks for the suggestion.