Question: MACS2 BAMPE and BEDPE gave dramatically different "mean fragment size"
gravatar for Xinwei Han
2.7 years ago by
Xinwei Han0
Xinwei Han0 wrote:

Using the same paired-end data, MACS2 BAMPE mode gave mean fragment size of 111bp, while BEDPE mode gave mean fragment size of 259bp.

To produce bedpe files from BAM files, I followed one previous thread in the MACS2 GitHub repository:

Basically, I used "samtools view -b -f 2 -F 4 -F 8 -F 256 -F 512 -F 2048" to select reads first, and finally cut 3 columns of bedtools ouput to make the bedpe files specific to MACS2.

I also used "Picard collectinsertsizemetrics" to check insert size distribution, the median of which is very close to the "mean fragment size" in BEDPE mode. The size in BAMPE mode seemed mistakenly small.

I am using MACS2 installed with miniconda.

I also posted the same question (along with two log files) in the MACS2 repository at GitHub ( ), but have not gotten any feedback. I guess there are more MACS2 users in Biostars. So I re-post the question here, just to make sure I am using MACS2 correctly.

I noticed mcjmigdal in this thread (MACS2 produces different results using BAMPE and BEDPE) also ran into this problem. Hope we can sort this out.

Many thanks, Xinwei

chip-seq • 1.2k views
ADD COMMENTlink modified 2.6 years ago by Biostar ♦♦ 20 • written 2.7 years ago by Xinwei Han0

This appears to be a very specific issue that, possibly, the developer will have to address. Like you, I have seen others with the same issue, but there does not appear to have been a solution on any forum.

Have you tried things like re-aligning your data and only including reads that: are properly paired align uniquely in the genome ?

...basically just including the best quality data in your BAM file to see if that improves the situation. With Bowtie, you can ensure unique mapping. In fact, I always switch that on for ChIP-seq data by supplying the --best -m 1 parameters to Bowtie.

ADD REPLYlink written 2.7 years ago by Kevin Blighe61k

Thanks for sharing! I used bowtie2 for mapping these data. After mapping, I required mapping quality to be at least 5 (samtools view -q 5), in order to remove multiply mapped reads.

In this thread (, the developer mentioned the BAMPE mode implements internally something like "samtools view -b -f 2 -F 4 -F 8 -F 256 -F 512 -F 2048", so only properly mapped reads are used by MACS2. It should not matter much how read alignment is filtered in the previous steps.

Currently, I just use BEDPE mode, as the fragment size in this mode is close to "Picard collectinsertsizemetrics".

ADD REPLYlink written 2.7 years ago by Xinwei Han0

Yes, that samtools command should only include properly mapped read pairs, and also only retain primary alignments. Strange issue!

ADD REPLYlink written 2.7 years ago by Kevin Blighe61k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1458 users visited in the last hour