# How to get the intersection of peaks after peak calling using MACS2?

I have following 5 narrow peak files after peak calling.

K14_peaks.narrowPeak
K15_peaks.narrowPeak
K16_peaks.narrowPeak
K3_peaks.narrowPeak
K8_peaks.narrowPeak


I need to get the intersection of peaks into a new file (The peaks that represent all these files). I used following code but I got higher number of peaks not a lower number.

bedtools intersect -a K14_peaks.narrowPeak -b K15_peaks.narrowPeak K16_peaks.narrowPeak K3_peaks.narrowPeak K8_peaks.narrowPeak -wo > intersected.bed


Can someone help me? Thank you.

bedtools intersect with multiple files after -b performs pairwise intersections between -a and each file in -b. It does not intersect all files simultaneously. See here, from the Bedtools documentation. The green section only contains intervals from -a that also intersect at least one interval in any -b file.
What I think you're looking for is bedtools multiinter (documentation here is unfortunately blank). bedtools multiinter -i input [input...] will produce a BED file that covers every position listed in your input files, followed by how many and which of your input samples overlap that given position.
• It's not wrong to do it this way, no. But it is more difficult, takes longer, and you lose a lot of information in the process. If you use multiinter, you can later select that regions supported by all samples with awk '{if (\$4 == x) print}' where x is the number of samples (5 in your case). And you haven't gotten rid of the sites that are supported by 3 or 4 samples, say. – James Hawley Mar 11 at 17:01