← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-chip-seq-peak-calling / references / usage-guide.md

Peak Calling - Usage Guide

Overview

Calls ChIP-seq peaks with MACS3/MACS2, HOMER, SPP, or Genrich. Handles narrow (TF) vs broad (histone) mode selection, fragment-size modeling vs --nomodel, effective genome size, ENCODE-style IDR (TFs) or naive overlap (histones), aligner-specific shift caveats, and hyper-ChIPable region awareness. Cross-references chipseq-qc for pre-call validation (antibody, fragment size, FRiP) and chip-seq/cut-and-run-tag for CUT&RUN/CUT&Tag protocols (which use SEACR + MACS2 rather than MACS3 alone).

Prerequisites

# Core peak callers
conda install -c bioconda macs3 macs2 homer samtools bedtools idr

# Phantompeakqualtools for SPP / cross-correlation fragment length
conda install -c bioconda phantompeakqualtools

# Optional: Genrich for joint replicate analysis
conda install -c bioconda genrich

Quick Start

Tell the agent what to do: - "Call peaks from chip.bam with input.bam control using ENCODE-compliant MACS2 parameters" - "Call broad peaks for H3K27me3 with input control and naive overlap across 3 replicates" - "Estimate fragment length via cross-correlation before peak calling" - "Run IDR on two MACS narrowPeak replicates and apply ENCODE Nself/Nt consistency rules" - "Call peaks on chr21-only data; adjust genome size accordingly" - "Find peaks at the level of high-confidence consensus across MACS3 and HOMER" - "My MACS model building failed; diagnose and rescue"

Example Prompts

ENCODE-compliant TF ChIP-seq

"Run the ENCODE TF peak-calling pipeline: per-replicate MACS2 at -p 0.01 --nomodel --shift 0 --extsize {fraglen} with fraglen from cross-correlation, then IDR at 0.05 across true replicates with the Nself/Nt consistency check."

Histone marks (broad)

"Call H3K27me3 broad peaks with --broad --broad-cutoff 0.1 for three replicates and combine via naive overlap with ≥40% reciprocal overlap."

Narrow histone marks

"Call H3K4me3 peaks. Use narrow mode in MACS3 and -style histone in HOMER (not -style factor despite the sharp signal; Omnipeak benchmark, Shpynov & Artyomov 2026)."

Subset data

"Call peaks from chr21-only ChIP-seq data with ~400k reads. Use numeric genome size, skip MACS model building, and use a narrow --extsize 147 for the H3K4me3 mark."

Diagnosing peak quality

"Why are my peaks shifted ~75bp from known motif positions? Check fragment-size modeling and shift parameters."

Hyper-ChIPable artifact suspicion

"I'm seeing strong peaks at rRNA loci and histone gene clusters. Filter against a custom blacklist of top-1% input signal regions."

Reconciliation

"MACS3 and HOMER disagree on which peaks pass. Walk through the reconciliation rules from the skill and decide what to trust."

What the Agent Will Do

  1. Pre-call validation: confirm antibody is validated (KO/KD or peptide-array); inspect fragment-size distribution via samtools view -f 0x2 sample.bam | awk '{print $9}'; verify input control matches library prep / fragmentation; check FRiP, NSC, RSC if available (see chipseq-qc)
  2. Choose narrow vs broad mode from target biology (TFs narrow; H3K27me3/H3K9me3/H3K36me3 broad; H3K4me3/H3K27ac narrow)
  3. Choose modeling strategy: full model only for whole-genome, ≥1M treatment reads; --nomodel --extsize for subsets, low-depth, or ENCODE consistency
  4. Determine effective genome size: read-length-matched value from deepTools table; numeric for subset data
  5. Call peaks per replicate at loose threshold (-p 1e-2 ENCODE pattern); generate signal tracks with -B --SPMR
  6. Replicate handling: IDR @ 0.05 for TFs with Nself/Nt consistency rule; naive overlap with ≥40% reciprocal for histones
  7. Quality sanity check: peak counts in expected range for target (e.g., 20-50k for H3K4me3); FRiP threshold met
  8. Hyper-ChIPable filter if claims are made at rRNA / tRNA / histone clusters / mitochondrial DNA
  9. Output conversion: narrowPeak/broadPeak to BED if downstream requires
  10. Document parameters in methods (genome version + size, fragment length source, IDR threshold, blacklist version)

Pipeline Quick Reference

ENCODE TF pipeline

# 1. Estimate fragment length via cross-correlation
Rscript run_spp.R -c=chip.bam -savp=chip_cc.pdf -out=chip_cc.txt
FRAGLEN=$(awk -F'\t' '{print $3}' chip_cc.txt | cut -d',' -f1)

# 2. Per-replicate (loose threshold for IDR)
for i in rep1 rep2; do
    macs2 callpeak -t ${i}.bam -c input.bam \
        -f BAM -g 2.701e9 -n ${i} \
        --nomodel --shift 0 --extsize $FRAGLEN \
        --keep-dup all -B --SPMR -p 1e-2
done

# 3. IDR across true replicates
sort -k8,8nr rep1_peaks.narrowPeak > rep1.sorted
sort -k8,8nr rep2_peaks.narrowPeak > rep2.sorted
idr --samples rep1.sorted rep2.sorted \
    --input-file-type narrowPeak --rank p.value \
    --idr-threshold 0.05 --output-file true_reps.idr --plot

ENCODE histone pipeline (broad)

# Per-replicate broad peaks
for i in rep1 rep2 rep3; do
    macs2 callpeak -t ${i}.bam -c input.bam \
        -f BAM -g 2.701e9 -n ${i} \
        --broad --broad-cutoff 0.1 \
        --nomodel --shift 0 --extsize $FRAGLEN \
        --keep-dup all -B --SPMR -p 1e-2
done

# Naive overlap (≥40% reciprocal, present in ≥2 reps)
bedtools intersect -a rep1_peaks.broadPeak -b rep2_peaks.broadPeak -f 0.40 -r -u > tmp12.bed
bedtools intersect -a tmp12.bed -b rep3_peaks.broadPeak -f 0.40 -r -u > naive_overlap.bed

Troubleshooting

Model building fails

MACS2/3 needs ≥100 paired plus/minus enrichment regions within --mfold (default [5, 50]). Causes: - Single-chromosome or targeted data -> use --nomodel - Low read count (<500k) -> use --nomodel - Sparse enrichment -> widen with --mfold 3 50 first, then fall back to --nomodel

Always inspect <sample>_model.r plot; silent model failure produces wrong fragment size.

Zero peaks called

Peak count >> 500k

Peaks shifted from motif by ~75 bp

IDR returns 0 reproducible peaks

FRiP < 1%

This is a hard fail. Re-validate the antibody (KO/KD control), check fragment-size distribution, confirm input control matches. Proceeding with low-FRiP data wastes downstream effort.

Output Files

File Description
*_peaks.narrowPeak BED6+4: chr, start, end, name, score, strand, signalValue, -log10(p), -log10(q), summit offset
*_peaks.broadPeak BED6+3: broad region coordinates without summit
*_summits.bed Per-peak summit positions (narrow only)
*_model.r R script for fragment-size model visualization (inspect this!)
*_treat_pileup.bdg Treatment signal (with -B); pileup of fragments
*_control_lambda.bdg Control signal (with -B); local lambda estimate

Convert narrowPeak to BED: cut -f1-5 peaks.narrowPeak > peaks.bed. For browser viewing: sort -k1,1 -k2,2n peaks_treat_pileup.bdg | bedGraphToBigWig - chrom.sizes peaks.bw.

Tips