How to calculate the number of peaks that are upstream/downstream of some other peaks

I have 3 histone marks,I have used Macs2 for peak calling and diffBind to analyze the peaks. I was wondering if you know any way to calculate the peak numbers of one specific histone mark that occur for example within 2kb of peaks belong to another histone mark.
Much appreciated

You can use windowBed from bedtools with -c if you just want counts. Or use -wa -wb and then use groupBy for any other operations.