# How are MACS2's narrow peak and broad peak algorithms different?

The peak calling tool MACS2 can call peaks in either narrow peak mode (for focused signals like transcription factor ChIPseq) or broad peak mode (for more defuse signals, like certain histone modifications).

The algorithm for narrow peak calling is well described in the MACS publication. But I don't find much documentation for how peak calling is different in broad peak mode. The manual only contains the following:

When this flag is on, MACS will try to composite broad regions in BED12 ( a gene-model-like format ) by putting nearby highly enriched regions into a broad region with loose cutoff. The broad region is controlled by another cutoff through --broad-cutoff. The maximum length of broad region length is 4 times of d from MACS

But this doesn't really describe exactly how this is performed.

So what is the algorithm MACS uses for calling broad peaks?

• I found the algorithm, but honestly I could not really get the try/except construction on line 629... – Kamil S Jaron May 20 '17 at 19:36

The key function is call_broadpeaks:

The description attached to the function says:

This function try to find enriched regions within which, scores are continuously higher than a given cutoff for level 1, and link them using the gap above level 2 cutoff with a maximum length of lvl2_max_gap.

scoring_function_s: symbols of functions to calculate score. 'p' for pscore, 'q' for qscore, 'f' for fold change, 's' for subtraction. for example: ['p', 'q']

lvl1_cutoff_s: list of cutoffs at highly enriched regions, corresponding to scoring functions.

lvl2_cutoff_s: list of cutoffs at less enriched regions, corresponding to scoring functions.

min_length :minimum peak length, default 200.

lvl1_max_gap : maximum gap to merge nearby enriched peaks, default 50.

lvl2_max_gap : maximum length of linkage regions, default 400.

Return both general PeakIO object for highly enriched regions and gapped broad regions in BroadPeakIO.

To give some basic explanation, the algorithm (briefly) appears to be as follows:

1. Two separate levels of peaks are called, level 1 (a higher pval, ie more significant) and level 2 (a lower pval). Level 1 is controlled by -p and level 2 is controlled by --broad-cutoff. When each peakset is called, they are immediately linked by the max gap parameter for each set.

2. Then, assuming that all level 1 peaks should be inside level 2 peaks (this is an explicit assumption by MACS2), the algorithm groups level 1 peaks inside level 2 peaks to output a broad peak.

...

This has a few implications:

1. The broad peak calls really come from the level 2 peaks alone (+ linking). The level 1 peak calls allow you to distinguish sub peaks (so that you can have gapped peaks).

2. Aside from the linking, the broad peak calls would be the same as narrow peak calls, if you called both with the same pval threshold (for example, if you set --broad-cutoff 0.1 in broad peak mode, and the -p 0.1 for narrow peak mode)

• Could you clarify in your answer that "higher pval" is actually "lower" or "more significant" p value and that "lower pval" is actually "higher" or "less significant" p value? I foresee someone getting confused by the wording. – Devon Ryan May 21 '17 at 12:09
• Added a clarification - thanks for the catch! – Daniel Kim May 22 '17 at 3:08
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.441047728061676, "perplexity": 4659.078753919697}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-26/segments/1560627998844.16/warc/CC-MAIN-20190618223541-20190619005541-00190.warc.gz"}