merge chipseq peaks with bedtools/other tool

# this should do it, concatenate peak locations in all peaks, sort them and merge

cat A B C .... | sort -k1,1 -k2,2n | mergeBed -i stdin > locations.bed

To know which files the peaks co-ordinates are merged from, you need to have an identifier in each file before merging.

Use 
awk '{print $0"t","peakFile-"NR}' A > A_id

This will add a new last column with label “peakFile-1” incremented per row, which will be nice, if you want to track later, which exact and how many peaks were used from which file for the current peak merge. I leave it you to implement a loop to label all the files automatically. Once its done, use the collapse operator from mergeBed.

cat A_id B_id C_id .... | sort -k1,1 -k2,2n | mergeBed -i stdin - o collapse -c 4

where c is the column number having the id’s we just entered before.

output:
chr1    20    65     peakFile-3, peakFile-1, peakFile-2

Enjoy!!

Read more here: Source link