[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73H4MMED6WENEPDZYDW45AE":3,"skill-same:01M73H4MMED6WENEPDZYDW45AE":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73H4MMED6WENEPDZYDW45AE","macs3-peak-calling",null,"Poisson-model peak caller for ChIP-seq\u002FATAC-seq BAMs. MACS3 callpeak finds enriched regions (TF sites or histone marks) vs input\u002FIgG; outputs BED narrowPeak\u002FbroadPeak for motif analysis, annotation, and differential binding. Use narrow peaks for TF ChIP-seq and ATAC-seq; broad for H3K27me3, H3K9me3, and other broad marks.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"BSD-3-Clause","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fmacs3-peak-calling\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"macs3-peak-calling\"\ndescription: \"Poisson-model peak caller for ChIP-seq\u002FATAC-seq BAMs. MACS3 callpeak finds enriched regions (TF sites or histone marks) vs input\u002FIgG; outputs BED narrowPeak\u002FbroadPeak for motif analysis, annotation, and differential binding. Use narrow peaks for TF ChIP-seq and ATAC-seq; broad for H3K27me3, H3K9me3, and other broad marks.\"\nlicense: \"BSD-3-Clause\"\n---\n\n# MACS3 — ChIP-seq and ATAC-seq Peak Caller\n\n## Overview\n\nMACS3 (Model-based Analysis of ChIP-seq) identifies regions of significant read enrichment (peaks) from ChIP-seq, ATAC-seq, CUT&RUN, and CUT&TAG experiments. It models the fragment length distribution from paired-end data or estimates it from mono-nucleosomal read shifting in single-end data, then applies a Poisson model to identify fold-enrichment over an input\u002FIgG control. MACS3 produces BED-format narrowPeak (for transcription factors) or broadPeak (for histone marks) files with signal and q-value tracks for visualization in IGV or UCSC Genome Browser.\n\n## When to Use\n\n- Calling transcription factor binding peaks from ChIP-seq experiments (use `--nomodel --extsize 200` or let MACS3 estimate fragment length)\n- Identifying open chromatin regions from ATAC-seq experiments (use `--nomodel --shift -100 --extsize 200 -f BAMPE`)\n- Calling broad histone modification peaks (H3K27me3, H3K9me3, H3K36me3) with `--broad`\n- Generating peak signal tracks (bedGraph\u002FbigWig) for genome browser visualization with `-B --SPMR`\n- Performing differential binding analysis: MACS3 peaks as input to DiffBind or DESeq2\n- Use **HMMRATAC** (part of MACS3) for nucleosome-resolution ATAC-seq peak calling\n- Use **SPP** or **HOMER** as alternatives; MACS3 is the ENCODE-recommended standard\n\n## Prerequisites\n\n- **Python packages**: `macs3` (Python ≥ 3.8)\n- **Input**: Sorted BAM files (with index) from ChIP-seq or ATAC-seq alignment (e.g., using STAR or Bowtie2)\n- **Optional**: Input\u002FIgG control BAM for background normalization\n\n> **Check before installing**: The tool may already be available in the current environment (e.g., inside a `pixi` \u002F `conda` env). Run `command -v macs3` first and skip the install commands below if it returns a path. When running inside a pixi project, invoke the tool via `pixi run macs3` rather than bare `macs3`.\n\n```bash\n# Install with pip or conda\npip install macs3\n# or\nconda install -c bioconda macs3\n\n# Verify\nmacs3 --version\n# macs3 3.0.2\n```\n\n## Pre-flight Interview\n\nSettle these with the user before writing any analysis code.\n\n```yaml\ndecisions:\n  - id: D1\n    param: assayType\n    kind: required\n    source: user\n    ask: \"What produced these reads - a transcription-factor ChIP, a histone mark, or open-chromatin (ATAC)?\"\n    default: null\n\n  - id: D2\n    param: controlSample\n    kind: required\n    source: data\n    ask: \"Is there a matched input or IgG control for this sample?\"\n    default: \"none - background is estimated locally instead\"\n\n  - id: D3\n    param: effectiveGenomeSize\n    kind: derived\n    source: upstream\n    ask: \"Which genome were the reads aligned to?\"\n    default: \"carried from the alignment reference\"\n\n  - id: D4\n    param: peakShape\n    kind: optional\n    source: user\n    depends_on: [D1]\n    ask: \"Are the enriched regions sharp summits or broad domains?\"\n    default: \"narrow for TF and ATAC; broad for spreading histone marks\"\n\n  - id: D5\n    param: significanceThreshold\n    kind: required\n    source: user\n    ask: \"How strong must enrichment be before a region is called a peak?\"\n    default: \"q-value 0.05\"\n\n  - id: D6\n    param: fragmentModel\n    kind: optional\n    source: user\n    depends_on: [D1]\n    ask: \"Should fragment length be modelled from the data, or fixed because the assay's signal is not paired summits?\"\n    default: \"model for ChIP; fixed shift\u002Fextension for ATAC\"\n\n  - id: D7\n    param: duplicateHandling\n    kind: optional\n    source: user\n    depends_on: [D1]\n    ask: \"Are identical read positions PCR duplicates, or real independent insertions?\"\n    default: \"one per position for ChIP; keep all for ATAC\"\n\n  - id: D8\n    param: signalTracks\n    kind: optional\n    source: user\n    ask: \"Emit normalized coverage tracks alongside the peak calls?\"\n    default: \"peaks only\"\n```\n\nD1 is asked first because four later settings follow from it. ATAC in\nparticular inverts three ChIP defaults at once - no fragment model, a negative\nshift, and duplicates kept - so running ATAC through ChIP defaults produces\npeaks that look plausible and are wrong.\n\n## Quick Start\n\n```bash\n# Call peaks for TF ChIP-seq (narrow peaks, with input control)\nmacs3 callpeak \\\n    -t chip.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n sample_tf \\\n    --outdir peaks\u002F \\\n    -q 0.05\n\n# Output: peaks\u002Fsample_tf_peaks.narrowPeak\nwc -l peaks\u002Fsample_tf_peaks.narrowPeak\n```\n\n## Workflow\n\n### Step 1: Prepare Input BAM Files\n\nMACS3 requires sorted, indexed BAM files from genome alignment.\n\n```bash\n# Sort and index ChIP and control BAMs (if not already done)\nsamtools sort -@ 8 chip_raw.bam -o chip.bam\nsamtools sort -@ 8 input_raw.bam -o input.bam\nsamtools index chip.bam\nsamtools index input.bam\n\n# Check read counts\necho \"ChIP reads: $(samtools view -c -F 4 chip.bam)\"\necho \"Input reads: $(samtools view -c -F 4 input.bam)\"\n```\n\n### Step 2: Call Narrow Peaks (TF ChIP-seq)\n\nUse the default mode for transcription factor binding site identification.\n\n```bash\n# TF ChIP-seq with input control\nmacs3 callpeak \\\n    -t chip.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n tf_chip \\\n    --outdir peaks\u002F \\\n    -q 0.05 \\\n    --keep-dup auto\n\necho \"Peaks called: $(wc -l \u003C peaks\u002Ftf_chip_peaks.narrowPeak)\"\necho \"Summit file: peaks\u002Ftf_chip_summits.bed\"\n\n# Without input control (less recommended)\nmacs3 callpeak \\\n    -t chip.bam \\\n    -f BAM \\\n    -g hs \\\n    -n tf_noinput \\\n    --outdir peaks\u002F \\\n    --nolambda\n```\n\n### Step 3: Call Broad Peaks (Histone Marks)\n\nUse `--broad` for spread histone modifications like H3K27me3 or H3K36me3.\n\n```bash\n# H3K27me3 broad histone mark\nmacs3 callpeak \\\n    -t h3k27me3.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n h3k27me3 \\\n    --outdir peaks\u002F \\\n    --broad \\\n    --broad-cutoff 0.1 \\\n    -q 0.05\n\necho \"Broad peaks: $(wc -l \u003C peaks\u002Fh3k27me3_peaks.broadPeak)\"\n\n# H3K4me3 (sharp mark — use narrow peaks)\nmacs3 callpeak \\\n    -t h3k4me3.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n h3k4me3 \\\n    --outdir peaks\u002F \\\n    -q 0.05\n```\n\n### Step 4: Call ATAC-seq Peaks\n\nATAC-seq requires special handling for the Tn5 insertion site.\n\n```bash\n# ATAC-seq with paired-end BAM (recommended)\nmacs3 callpeak \\\n    -t atac.bam \\\n    -f BAMPE \\\n    -g hs \\\n    -n atac_sample \\\n    --outdir peaks\u002F \\\n    --nomodel \\\n    --nolambda \\\n    -q 0.05 \\\n    --keep-dup all\n\necho \"ATAC peaks: $(wc -l \u003C peaks\u002Fatac_sample_peaks.narrowPeak)\"\n\n# Single-end ATAC-seq: shift reads to center on Tn5 cut site\nmacs3 callpeak \\\n    -t atac_se.bam \\\n    -f BAM \\\n    -g hs \\\n    -n atac_se \\\n    --outdir peaks\u002F \\\n    --nomodel \\\n    --shift -100 \\\n    --extsize 200 \\\n    --keep-dup all\n```\n\n### Step 5: Generate Signal Tracks for Visualization\n\nProduce bedGraph and bigWig files for genome browser visualization.\n\n```bash\n# Generate bedGraph normalized to million reads (SPMR)\nmacs3 callpeak \\\n    -t chip.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n chip_track \\\n    --outdir tracks\u002F \\\n    -B \\\n    --SPMR \\\n    --keep-dup auto\n\n# Convert bedGraph to bigWig for IGV\u002FUCSC\n# Requires bedGraphToBigWig and chrom.sizes\nsort -k1,1 -k2,2n tracks\u002Fchip_track_treat_pileup.bdg > tracks\u002Fchip_sorted.bdg\nbedGraphToBigWig tracks\u002Fchip_sorted.bdg genome\u002Fhg38.chrom.sizes tracks\u002Fchip.bw\n\necho \"BigWig track: tracks\u002Fchip.bw\"\n```\n\n### Step 6: Annotate and Analyze Peaks\n\nParse narrowPeak output and annotate peaks to genomic features.\n\n```python\nimport pandas as pd\n\n# Load narrowPeak file\n# Columns: chrom, start, end, name, score, strand, signalValue, pValue, qValue, peak\ncols = [\"chrom\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n        \"signalValue\", \"pValue\", \"qValue\", \"peak\"]\npeaks = pd.read_csv(\"peaks\u002Ftf_chip_peaks.narrowPeak\", sep=\"\\t\",\n                    header=None, names=cols)\n\nprint(f\"Total peaks: {len(peaks)}\")\nprint(f\"Peaks on chr1: {(peaks['chrom'] == 'chr1').sum()}\")\nprint(f\"Median peak width: {(peaks['end'] - peaks['start']).median():.0f} bp\")\nprint(f\"Peaks with q-value \u003C 0.01: {(peaks['qValue'] > 2).sum()}\")  # -log10(q) > 2\n\n# Filter high-confidence peaks\nhigh_conf = peaks[peaks[\"qValue\"] > 2].copy()  # q \u003C 0.01\nhigh_conf[\"width\"] = high_conf[\"end\"] - high_conf[\"start\"]\nprint(f\"\\nHigh-confidence peaks: {len(high_conf)}\")\nhigh_conf.to_csv(\"high_confidence_peaks.bed\", sep=\"\\t\", index=False, header=False,\n                 columns=[\"chrom\", \"start\", \"end\", \"name\", \"score\", \"strand\"])\n```\n\n## Key Parameters\n\n| Parameter | Default | Range\u002FOptions | Effect |\n|-----------|---------|---------------|--------|\n| `-t \u002F --treatment` | required | BAM\u002FBED\u002FSAM | ChIP or ATAC treatment file |\n| `-c \u002F --control` | — | BAM\u002FBED\u002FSAM | Input\u002FIgG control; omit `--nolambda` if absent |\n| `-g \u002F --gsize` | required | `hs`, `mm`, `ce`, `dm`, or integer | Effective genome size; `hs`=2.7e9 (human), `mm`=1.87e9 (mouse) |\n| `-q \u002F --qvalue` | `0.05` | 0–1 | FDR threshold for peak calling |\n| `-p \u002F --pvalue` | — | 0–1 | P-value cutoff (use instead of q-value for strict control) |\n| `--broad` | off | flag | Call broad peaks for diffuse histone marks |\n| `--broad-cutoff` | `0.1` | 0–1 | Q-value cutoff for broad region merging |\n| `--nomodel` | off | flag | Skip fragment length modeling; required for ATAC-seq |\n| `--extsize` | `200` | 50–1000 | Fragment extension size when `--nomodel` is set |\n| `--shift` | `0` | -500–500 | Read shift in bp; use `-100` with `--extsize 200` for ATAC-seq |\n| `--keep-dup` | `1` | `auto`, `all`, integer | Duplicate handling; `auto` uses Poisson model, `all` keeps all (ATAC-seq) |\n| `-B \u002F --bdg` | off | flag | Write bedGraph signal tracks |\n| `--SPMR` | off | flag | Normalize bedGraph to signal per million reads |\n\n## Common Recipes\n\n### Recipe 1: Batch Peak Calling for Multiple Samples\n\n```bash\n#!\u002Fbin\u002Fbash\n# Call peaks for multiple ChIP-seq samples with the same input\nINPUT=\"input.bam\"\nGENOME=\"hs\"\nOUTDIR=\"peaks\"\nmkdir -p \"$OUTDIR\"\n\nSAMPLES=(H3K4me3 H3K27ac H3K27me3 CTCF)\nMODES=(narrow narrow broad narrow)\n\nfor i in \"${!SAMPLES[@]}\"; do\n    sample=\"${SAMPLES[$i]}\"\n    mode=\"${MODES[$i]}\"\n    echo \"Calling peaks: $sample ($mode)\"\n    \n    if [ \"$mode\" == \"broad\" ]; then\n        BROAD_FLAG=\"--broad --broad-cutoff 0.1\"\n    else\n        BROAD_FLAG=\"\"\n    fi\n    \n    macs3 callpeak \\\n        -t \"${sample}.bam\" \\\n        -c \"$INPUT\" \\\n        -f BAM \\\n        -g \"$GENOME\" \\\n        -n \"$sample\" \\\n        --outdir \"$OUTDIR\" \\\n        $BROAD_FLAG \\\n        -q 0.05 \\\n        --keep-dup auto\n    \n    echo \"$sample: $(wc -l \u003C $OUTDIR\u002F${sample}_peaks.*Peak) peaks\"\ndone\n```\n\n### Recipe 2: Reproducible Peaks with IDR (Irreproducible Discovery Rate)\n\n```bash\n# Call peaks on individual replicates (lenient thresholds for IDR)\nfor rep in rep1 rep2; do\n    macs3 callpeak \\\n        -t \"chip_${rep}.bam\" \\\n        -c input.bam \\\n        -f BAM \\\n        -g hs \\\n        -n \"tf_${rep}\" \\\n        --outdir peaks\u002F \\\n        -p 0.1 \\\n        --keep-dup auto\ndone\n\n# Run IDR to find reproducible peaks\n# pip install idr\nidr --samples peaks\u002Ftf_rep1_peaks.narrowPeak peaks\u002Ftf_rep2_peaks.narrowPeak \\\n    --input-file-type narrowPeak \\\n    --output-file peaks\u002Ftf_idr_peaks.txt \\\n    --idr-threshold 0.05 \\\n    --plot\n\necho \"IDR peaks: $(wc -l \u003C peaks\u002Ftf_idr_peaks.txt)\"\n```\n\n## Expected Outputs\n\n| Output | Format | Description |\n|--------|--------|-------------|\n| `*_peaks.narrowPeak` | BED6+4 | Narrow peaks with signal, p-value, q-value, summit offset |\n| `*_peaks.broadPeak` | BED6+3 | Broad peaks (when `--broad`): chrom, start, end, signal, p-val, q-val |\n| `*_summits.bed` | BED3+2 | Peak summit positions (1 bp) with score; use for motif analysis |\n| `*_treat_pileup.bdg` | bedGraph | Treatment signal track (when `-B`) |\n| `*_control_lambda.bdg` | bedGraph | Control\u002Flocal lambda track (when `-B`) |\n| `*_model.r` | R script | Fragment size model; run `Rscript *_model.r` to plot |\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| Very few peaks called | Stringent q-value or low read depth | Relax to `-p 1e-3`; check sequencing depth (≥10M aligned reads recommended) |\n| Too many peaks (>100k) | Threshold too loose or no input control | Add `--control input.bam`; use `-q 0.01`; filter on signalValue |\n| Peak calling fails with \"no reads\" | BAM file is not sorted or indexed | Run `samtools sort` and `samtools index` before MACS3 |\n| ATAC-seq peaks in mitochondria | High mtDNA content | Filter: `samtools view -h chip.bam | grep -v chrM | samtools view -bS > filtered.bam` |\n| Fragment model fails | Too few reads or unusual read length | Add `--nomodel --extsize 200` to skip modeling |\n| bedGraph output very large | High coverage data without normalization | Add `--SPMR` to normalize to signal per million reads |\n| `--broad` misses narrow peaks | Signal is actually sharp | Check ChIP target: TFs and H3K4me3 need narrow mode |\n| `gsize` mismatch | Using wrong genome size for assembly | Use `hs` for hg19\u002Fhg38, `mm` for mm9\u002Fmm10; or provide exact integer |\n\n## References\n\n- [MACS3 GitHub: macs3-project\u002FMACS](https:\u002F\u002Fgithub.com\u002Fmacs3-project\u002FMACS) — source code, documentation, and changelog\n- Zhang Y et al. (2008) \"Model-based Analysis of ChIP-Seq (MACS)\" — *Genome Biology* 9:R137. [DOI:10.1186\u002Fgb-2008-9-9-r137](https:\u002F\u002Fdoi.org\u002F10.1186\u002Fgb-2008-9-9-r137)\n- [ENCODE ATAC-seq pipeline](https:\u002F\u002Fwww.encodeproject.org\u002Fatac-seq\u002F) — ENCODE standardized ATAC-seq workflow using MACS3\n- [IDR framework](https:\u002F\u002Fgithub.com\u002Fnboley\u002Fidr) — irreproducible discovery rate for reproducible peak calls\n","# MACS3 — ChIP-seq and ATAC-seq Peak Caller\n\n## Overview\n\nMACS3 (Model-based Analysis of ChIP-seq) identifies regions of significant read enrichment (peaks) from ChIP-seq, ATAC-seq, CUT&RUN, and CUT&TAG experiments. It models the fragment length distribution from paired-end data or estimates it from mono-nucleosomal read shifting in single-end data, then applies a Poisson model to identify fold-enrichment over an input\u002FIgG control. MACS3 produces BED-format narrowPeak (for transcription factors) or broadPeak (for histone marks) files with signal and q-value tracks for visualization in IGV or UCSC Genome Browser.\n\n## When to Use\n\n- Calling transcription factor binding peaks from ChIP-seq experiments (use `--nomodel --extsize 200` or let MACS3 estimate fragment length)\n- Identifying open chromatin regions from ATAC-seq experiments (use `--nomodel --shift -100 --extsize 200 -f BAMPE`)\n- Calling broad histone modification peaks (H3K27me3, H3K9me3, H3K36me3) with `--broad`\n- Generating peak signal tracks (bedGraph\u002FbigWig) for genome browser visualization with `-B --SPMR`\n- Performing differential binding analysis: MACS3 peaks as input to DiffBind or DESeq2\n- Use **HMMRATAC** (part of MACS3) for nucleosome-resolution ATAC-seq peak calling\n- Use **SPP** or **HOMER** as alternatives; MACS3 is the ENCODE-recommended standard\n\n## Prerequisites\n\n- **Python packages**: `macs3` (Python ≥ 3.8)\n- **Input**: Sorted BAM files (with index) from ChIP-seq or ATAC-seq alignment (e.g., using STAR or Bowtie2)\n- **Optional**: Input\u002FIgG control BAM for background normalization\n\n> **Check before installing**: The tool may already be available in the current environment (e.g., inside a `pixi` \u002F `conda` env). Run `command -v macs3` first and skip the install commands below if it returns a path. When running inside a pixi project, invoke the tool via `pixi run macs3` rather than bare `macs3`.\n\n```bash\n# Install with pip or conda\npip install macs3\n# or\nconda install -c bioconda macs3\n\n# Verify\nmacs3 --version\n# macs3 3.0.2\n```\n\n## Pre-flight Interview\n\nSettle these with the user before writing any analysis code.\n\n```yaml\ndecisions:\n  - id: D1\n    param: assayType\n    kind: required\n    source: user\n    ask: \"What produced these reads - a transcription-factor ChIP, a histone mark, or open-chromatin (ATAC)?\"\n    default: null\n\n  - id: D2\n    param: controlSample\n    kind: required\n    source: data\n    ask: \"Is there a matched input or IgG control for this sample?\"\n    default: \"none - background is estimated locally instead\"\n\n  - id: D3\n    param: effectiveGenomeSize\n    kind: derived\n    source: upstream\n    ask: \"Which genome were the reads aligned to?\"\n    default: \"carried from the alignment reference\"\n\n  - id: D4\n    param: peakShape\n    kind: optional\n    source: user\n    depends_on: [D1]\n    ask: \"Are the enriched regions sharp summits or broad domains?\"\n    default: \"narrow for TF and ATAC; broad for spreading histone marks\"\n\n  - id: D5\n    param: significanceThreshold\n    kind: required\n    source: user\n    ask: \"How strong must enrichment be before a region is called a peak?\"\n    default: \"q-value 0.05\"\n\n  - id: D6\n    param: fragmentModel\n    kind: optional\n    source: user\n    depends_on: [D1]\n    ask: \"Should fragment length be modelled from the data, or fixed because the assay's signal is not paired summits?\"\n    default: \"model for ChIP; fixed shift\u002Fextension for ATAC\"\n\n  - id: D7\n    param: duplicateHandling\n    kind: optional\n    source: user\n    depends_on: [D1]\n    ask: \"Are identical read positions PCR duplicates, or real independent insertions?\"\n    default: \"one per position for ChIP; keep all for ATAC\"\n\n  - id: D8\n    param: signalTracks\n    kind: optional\n    source: user\n    ask: \"Emit normalized coverage tracks alongside the peak calls?\"\n    default: \"peaks only\"\n```\n\nD1 is asked first because four later settings follow from it. ATAC in\nparticular inverts three ChIP defaults at once - no fragment model, a negative\nshift, and duplicates kept - so running ATAC through ChIP defaults produces\npeaks that look plausible and are wrong.\n\n## Quick Start\n\n```bash\n# Call peaks for TF ChIP-seq (narrow peaks, with input control)\nmacs3 callpeak \\\n    -t chip.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n sample_tf \\\n    --outdir peaks\u002F \\\n    -q 0.05\n\n# Output: peaks\u002Fsample_tf_peaks.narrowPeak\nwc -l peaks\u002Fsample_tf_peaks.narrowPeak\n```\n\n## Workflow\n\n### Step 1: Prepare Input BAM Files\n\nMACS3 requires sorted, indexed BAM files from genome alignment.\n\n```bash\n# Sort and index ChIP and control BAMs (if not already done)\nsamtools sort -@ 8 chip_raw.bam -o chip.bam\nsamtools sort -@ 8 input_raw.bam -o input.bam\nsamtools index chip.bam\nsamtools index input.bam\n\n# Check read counts\necho \"ChIP reads: $(samtools view -c -F 4 chip.bam)\"\necho \"Input reads: $(samtools view -c -F 4 input.bam)\"\n```\n\n### Step 2: Call Narrow Peaks (TF ChIP-seq)\n\nUse the default mode for transcription factor binding site identification.\n\n```bash\n# TF ChIP-seq with input control\nmacs3 callpeak \\\n    -t chip.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n tf_chip \\\n    --outdir peaks\u002F \\\n    -q 0.05 \\\n    --keep-dup auto\n\necho \"Peaks called: $(wc -l \u003C peaks\u002Ftf_chip_peaks.narrowPeak)\"\necho \"Summit file: peaks\u002Ftf_chip_summits.bed\"\n\n# Without input control (less recommended)\nmacs3 callpeak \\\n    -t chip.bam \\\n    -f BAM \\\n    -g hs \\\n    -n tf_noinput \\\n    --outdir peaks\u002F \\\n    --nolambda\n```\n\n### Step 3: Call Broad Peaks (Histone Marks)\n\nUse `--broad` for spread histone modifications like H3K27me3 or H3K36me3.\n\n```bash\n# H3K27me3 broad histone mark\nmacs3 callpeak \\\n    -t h3k27me3.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n h3k27me3 \\\n    --outdir peaks\u002F \\\n    --broad \\\n    --broad-cutoff 0.1 \\\n    -q 0.05\n\necho \"Broad peaks: $(wc -l \u003C peaks\u002Fh3k27me3_peaks.broadPeak)\"\n\n# H3K4me3 (sharp mark — use narrow peaks)\nmacs3 callpeak \\\n    -t h3k4me3.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n h3k4me3 \\\n    --outdir peaks\u002F \\\n    -q 0.05\n```\n\n### Step 4: Call ATAC-seq Peaks\n\nATAC-seq requires special handling for the Tn5 insertion site.\n\n```bash\n# ATAC-seq with paired-end BAM (recommended)\nmacs3 callpeak \\\n    -t atac.bam \\\n    -f BAMPE \\\n    -g hs \\\n    -n atac_sample \\\n    --outdir peaks\u002F \\\n    --nomodel \\\n    --nolambda \\\n    -q 0.05 \\\n    --keep-dup all\n\necho \"ATAC peaks: $(wc -l \u003C peaks\u002Fatac_sample_peaks.narrowPeak)\"\n\n# Single-end ATAC-seq: shift reads to center on Tn5 cut site\nmacs3 callpeak \\\n    -t atac_se.bam \\\n    -f BAM \\\n    -g hs \\\n    -n atac_se \\\n    --outdir peaks\u002F \\\n    --nomodel \\\n    --shift -100 \\\n    --extsize 200 \\\n    --keep-dup all\n```\n\n### Step 5: Generate Signal Tracks for Visualization\n\nProduce bedGraph and bigWig files for genome browser visualization.\n\n```bash\n# Generate bedGraph normalized to million reads (SPMR)\nmacs3 callpeak \\\n    -t chip.bam \\\n    -c input.bam \\\n    -f BAM \\\n    -g hs \\\n    -n chip_track \\\n    --outdir tracks\u002F \\\n    -B \\\n    --SPMR \\\n    --keep-dup auto\n\n# Convert bedGraph to bigWig for IGV\u002FUCSC\n# Requires bedGraphToBigWig and chrom.sizes\nsort -k1,1 -k2,2n tracks\u002Fchip_track_treat_pileup.bdg > tracks\u002Fchip_sorted.bdg\nbedGraphToBigWig tracks\u002Fchip_sorted.bdg genome\u002Fhg38.chrom.sizes tracks\u002Fchip.bw\n\necho \"BigWig track: tracks\u002Fchip.bw\"\n```\n\n### Step 6: Annotate and Analyze Peaks\n\nParse narrowPeak output and annotate peaks to genomic features.\n\n```python\nimport pandas as pd\n\n# Load narrowPeak file\n# Columns: chrom, start, end, name, score, strand, signalValue, pValue, qValue, peak\ncols = [\"chrom\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n        \"signalValue\", \"pValue\", \"qValue\", \"peak\"]\npeaks = pd.read_csv(\"peaks\u002Ftf_chip_peaks.narrowPeak\", sep=\"\\t\",\n                    header=None, names=cols)\n\nprint(f\"Total peaks: {len(peaks)}\")\nprint(f\"Peaks on chr1: {(peaks['chrom'] == 'chr1').sum()}\")\nprint(f\"Median peak width: {(peaks['end'] - peaks['start']).median():.0f} bp\")\nprint(f\"Peaks with q-value \u003C 0.01: {(peaks['qValue'] > 2).sum()}\")  # -log10(q) > 2\n\n# Filter high-confidence peaks\nhigh_conf = peaks[peaks[\"qValue\"] > 2].copy()  # q \u003C 0.01\nhigh_conf[\"width\"] = high_conf[\"end\"] - high_conf[\"start\"]\nprint(f\"\\nHigh-confidence peaks: {len(high_conf)}\")\nhigh_conf.to_csv(\"high_confidence_peaks.bed\", sep=\"\\t\", index=False, header=False,\n                 columns=[\"chrom\", \"start\", \"end\", \"name\", \"score\", \"strand\"])\n```\n\n## Key Parameters\n\n| Parameter | Default | Range\u002FOptions | Effect |\n|-----------|---------|---------------|--------|\n| `-t \u002F --treatment` | required | BAM\u002FBED\u002FSAM | ChIP or ATAC treatment file |\n| `-c \u002F --control` | — | BAM\u002FBED\u002FSAM | Input\u002FIgG control; omit `--nolambda` if absent |\n| `-g \u002F --gsize` | required | `hs`, `mm`, `ce`, `dm`, or integer | Effective genome size; `hs`=2.7e9 (human), `mm`=1.87e9 (mouse) |\n| `-q \u002F --qvalue` | `0.05` | 0–1 | FDR threshold for peak calling |\n| `-p \u002F --pvalue` | — | 0–1 | P-value cutoff (use instead of q-value for strict control) |\n| `--broad` | off | flag | Call broad peaks for diffuse histone marks |\n| `--broad-cutoff` | `0.1` | 0–1 | Q-value cutoff for broad region merging |\n| `--nomodel` | off | flag | Skip fragment length modeling; required for ATAC-seq |\n| `--extsize` | `200` | 50–1000 | Fragment extension size when `--nomodel` is set |\n| `--shift` | `0` | -500–500 | Read shift in bp; use `-100` with `--extsize 200` for ATAC-seq |\n| `--keep-dup` | `1` | `auto`, `all`, integer | Duplicate handling; `auto` uses Poisson model, `all` keeps all (ATAC-seq) |\n| `-B \u002F --bdg` | off | flag | Write bedGraph signal tracks |\n| `--SPMR` | off | flag | Normalize bedGraph to signal per million reads |\n\n## Common Recipes\n\n### Recipe 1: Batch Peak Calling for Multiple Samples\n\n```bash\n#!\u002Fbin\u002Fbash\n# Call peaks for multiple ChIP-seq samples with the same input\nINPUT=\"input.bam\"\nGENOME=\"hs\"\nOUTDIR=\"peaks\"\nmkdir -p \"$OUTDIR\"\n\nSAMPLES=(H3K4me3 H3K27ac H3K27me3 CTCF)\nMODES=(narrow narrow broad narrow)\n\nfor i in \"${!SAMPLES[@]}\"; do\n    sample=\"${SAMPLES[$i]}\"\n    mode=\"${MODES[$i]}\"\n    echo \"Calling peaks: $sample ($mode)\"\n    \n    if [ \"$mode\" == \"broad\" ]; then\n        BROAD_FLAG=\"--broad --broad-cutoff 0.1\"\n    else\n        BROAD_FLAG=\"\"\n    fi\n    \n    macs3 callpeak \\\n        -t \"${sample}.bam\" \\\n        -c \"$INPUT\" \\\n        -f BAM \\\n        -g \"$GENOME\" \\\n        -n \"$sample\" \\\n        --outdir \"$OUTDIR\" \\\n        $BROAD_FLAG \\\n        -q 0.05 \\\n        --keep-dup auto\n    \n    echo \"$sample: $(wc -l \u003C $OUTDIR\u002F${sample}_peaks.*Peak) peaks\"\ndone\n```\n\n### Recipe 2: Reproducible Peaks with IDR (Irreproducible Discovery Rate)\n\n```bash\n# Call peaks on individual replicates (lenient thresholds for IDR)\nfor rep in rep1 rep2; do\n    macs3 callpeak \\\n        -t \"chip_${rep}.bam\" \\\n        -c input.bam \\\n        -f BAM \\\n        -g hs \\\n        -n \"tf_${rep}\" \\\n        --outdir peaks\u002F \\\n        -p 0.1 \\\n        --keep-dup auto\ndone\n\n# Run IDR to find reproducible peaks\n# pip install idr\nidr --samples peaks\u002Ftf_rep1_peaks.narrowPeak peaks\u002Ftf_rep2_peaks.narrowPeak \\\n    --input-file-type narrowPeak \\\n    --output-file peaks\u002Ftf_idr_peaks.txt \\\n    --idr-threshold 0.05 \\\n    --plot\n\necho \"IDR peaks: $(wc -l \u003C peaks\u002Ftf_idr_peaks.txt)\"\n```\n\n## Expected Outputs\n\n| Output | Format | Description |\n|--------|--------|-------------|\n| `*_peaks.narrowPeak` | BED6+4 | Narrow peaks with signal, p-value, q-value, summit offset |\n| `*_peaks.broadPeak` | BED6+3 | Broad peaks (when `--broad`): chrom, start, end, signal, p-val, q-val |\n| `*_summits.bed` | BED3+2 | Peak summit positions (1 bp) with score; use for motif analysis |\n| `*_treat_pileup.bdg` | bedGraph | Treatment signal track (when `-B`) |\n| `*_control_lambda.bdg` | bedGraph | Control\u002Flocal lambda track (when `-B`) |\n| `*_model.r` | R script | Fragment size model; run `Rscript *_model.r` to plot |\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| Very few peaks called | Stringent q-value or low read depth | Relax to `-p 1e-3`; check sequencing depth (≥10M aligned reads recommended) |\n| Too many peaks (>100k) | Threshold too loose or no input control | Add `--control input.bam`; use `-q 0.01`; filter on signalValue |\n| Peak calling fails with \"no reads\" | BAM file is not sorted or indexed | Run `samtools sort` and `samtools index` before MACS3 |\n| ATAC-seq peaks in mitochondria | High mtDNA content | Filter: `samtools view -h chip.bam | grep -v chrM | samtools view -bS > filtered.bam` |\n| Fragment model fails | Too few reads or unusual read length | Add `--nomodel --extsize 200` to skip modeling |\n| bedGraph output very large | High coverage data without normalization | Add `--SPMR` to normalize to signal per million reads |\n| `--broad` misses narrow peaks | Signal is actually sharp | Check ChIP target: TFs and H3K4me3 need narrow mode |\n| `gsize` mismatch | Using wrong genome size for assembly | Use `hs` for hg19\u002Fhg38, `mm` for mm9\u002Fmm10; or provide exact integer |\n\n## References\n\n- [MACS3 GitHub: macs3-project\u002FMACS](https:\u002F\u002Fgithub.com\u002Fmacs3-project\u002FMACS) — source code, documentation, and changelog\n- Zhang Y et al. (2008) \"Model-based Analysis of ChIP-Seq (MACS)\" — *Genome Biology* 9:R137. [DOI:10.1186\u002Fgb-2008-9-9-r137](https:\u002F\u002Fdoi.org\u002F10.1186\u002Fgb-2008-9-9-r137)\n- [ENCODE ATAC-seq pipeline](https:\u002F\u002Fwww.encodeproject.org\u002Fatac-seq\u002F) — ENCODE standardized ATAC-seq workflow using MACS3\n- [IDR framework](https:\u002F\u002Fgithub.com\u002Fnboley\u002Fidr) — irreproducible discovery rate for reproducible peak calls\n",{"name":5,"license":15,"description":7},"master","fd76f882a04e445e899d5cfb2732f2105ea054ee","skills\u002Fawesome-skills\u002Fmacs3-peak-calling",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-13 06:26:27",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill macs3-peak-calling",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill macs3-peak-calling",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill macs3-peak-calling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fmacs3-peak-calling\u002FSKILL.md",true,[],[49,59,66,73,82,90],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":54,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":58},"01M76KTXGSTXVVDC7YSBM41ZZS","wxpusher-integration","Use when（适用场景）：用户明确询问、指定或上下文已选定 WxPusher，需要了解、接入或排查通知（含微信 ClawBot\u002FiLink、appToken、UID、Topic、SPT）；仅说“微信通知”、未选服务商，或只出现通用 UID\u002FTopic 时不触发。","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fwxpusher-integration\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fwxpusher-integration\u002FSKILL.md",[],[],"2026-11-12 13:55:43",{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M748C5DS5BQBVBMG22FCGG34","branding","When the user wants to define, audit, or apply brand strategy—purpose, values, positioning, storytelling, voice, narrative (not only visuals). Also use when the user mentions \"brand strategy\", \"brand story\", \"brand storytelling\" or \"brand voice\". For typography, colors, design tokens, and frontend visuals, use brand-visual-generator.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fsuperskills\u002Fbranding\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M748C1GXJ9WRKP18X45DKP6G","brand-visual-generator","When the user wants to define, audit, or apply visual identity (typography, colors, spacing, design tokens, frontend aesthetics). Also use when the user mentions \"brand style guide\", \"visual identity\", \"design system\" or \"typography\". For brand story, positioning, and voice, use branding.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fsuperskills\u002Fbrand-visual-generator\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":78,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M747T565TFEP3RAVWM0Y899Y","mcp-builder","Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node\u002FTypeScript (MCP SDK).","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fskills\u002Fmcp-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fskills\u002Fmcp-builder\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":86,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M747RAJGMBZ2QN4563STB5SH","frontend-design","Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fskills\u002Ffrontend-design\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fskills\u002Ffrontend-design\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":94,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M747NHAY5BE9GXEB31H255R1","claude-api","Reference for the Claude API \u002F Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration.\nTRIGGER — read BEFORE opening the target file; don't skip because it \"looks like a one-liner\" — whenever: the prompt names Claude\u002FAnthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing\u002Fmodel choice\u002Flimits\u002Fcaching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent\u002FMCP\u002Ftool-definition\u002Fmulti-agent\u002FRAG\u002FLLM-judge\u002Fcomputer-use; generate\u002Fsummarize\u002Fextract\u002Fclassify\u002Frewrite\u002Fconverse over NL; debugging refusals\u002Fcutoffs\u002Fstreaming\u002Ftool-calls\u002Ftokens).\nSKIP only when another provider is being worked on (overrides all triggers): OpenAI\u002FGPT\u002FGemini\u002FLlama\u002FMistral\u002FCohere\u002FOllama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fskills\u002Fclaude-api\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fskills\u002Fclaude-api\u002FSKILL.md",[],[]]