{"slug":"pipeline-atacseq-2","title":"pipeline-atacseq","summary":"Execute ENCODE ATAC-seq processing pipeline from FASTQ to peaks and signal tracks. Child of pipeline-guide. Provides stage-by-stage Nextflow execution with Docker containers and cloud deployment. Handles Tn5 transposase offset correction, mitochondrial read removal, and nucleosom","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-22T13:25:43.723921Z","repo":{"url":"https://github.com/ammawla/encode-toolkit","stars":21,"forks":5,"license":"AGPL-3.0","updatedAt":"2026-09-27T01:22:42Z"},"bodyHtml":"<hr>\n<h2>name: pipeline-atacseq\ndescription: \"Execute ENCODE ATAC-seq processing pipeline from FASTQ to peaks and signal tracks. Child of pipeline-guide. Provides stage-by-stage Nextflow execution with Docker containers and cloud deployment. Handles Tn5 transposase offset correction, mitochondrial read removal, and nucleosome-free fragment selection. Use when users need to process ATAC-seq data following ENCODE standards. Trigger on: ATAC-seq pipeline, run ATAC-seq, process ATAC-seq, chromatin accessibility, open chromatin, Tn5 shift, TSS enrichment.\"</h2>\n<h1>ENCODE ATAC-seq Pipeline</h1>\n<h2>When to Use</h2>\n<ul>\n<li>User wants to run an ATAC-seq processing pipeline from FASTQ to peaks and signal tracks</li>\n<li>User asks about \"ATAC-seq pipeline\", \"Tn5 shift\", \"chromatin accessibility pipeline\", or \"Bowtie2 for ATAC\"</li>\n<li>User needs to process ATAC-seq data with proper Tn5 insertion site correction</li>\n<li>Example queries: \"process my ATAC-seq FASTQs\", \"run ENCODE ATAC-seq pipeline\", \"call accessibility peaks from ATAC-seq\"</li>\n</ul>\n<p>Execute the ENCODE ATAC-seq processing pipeline from raw FASTQ files through Tn5 offset\ncorrection, peak calling, IDR analysis, and signal track generation. This skill provides\na Nextflow DSL2 implementation following ENCODE uniform analysis standards.</p>\n<p>TSS enrichment scoring is a <strong>manual post-processing step</strong>; the workflow does not compute\nit (see \"Manual QC steps\" below and <code>references/05-qc-metrics.md</code>).</p>\n<h2>Overview</h2>\n<p>ATAC-seq (Assay for Transposase-Accessible Chromatin using sequencing) uses the Tn5\ntransposase to probe open chromatin regions. This pipeline processes ATAC-seq data\nthrough quality control, alignment with Bowtie2, mitochondrial read removal, duplicate\nremoval, Tn5 insertion site correction (+4/-5 bp offset), blacklist filtering,\nnucleosome-free fragment selection, MACS2 peak calling, FRiP calculation, and an IDR\ncomparison for every pair of replicates.</p>\n<p>Key differences from ChIP-seq: Bowtie2 aligner (optimized for short fragments), Tn5\ntransposase shift correction, mitochondrial read filtering (chrM can be 30-80% of reads),\nand no input control.</p>\n<p>The workflow is <strong>paired-end only</strong>. Passing <code>--single_end</code> stops the run with an error,\nbecause Tn5 shifting, nucleosome-free selection and BAMPE peak calling all depend on\nfragment length.</p>\n<h2>Key Literature</h2>\n<table>\n<thead>\n<tr>\n<th>Reference</th>\n<th>Journal</th>\n<th>Year</th>\n<th>DOI</th>\n<th>Relevance</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Buenrostro et al. \"Transposition of native chromatin (ATAC-seq)\"</td>\n<td>Nature Methods</td>\n<td>2013</td>\n<td>10.1038/nmeth.2688</td>\n<td>Original ATAC-seq method (~5,000 citations)</td>\n</tr>\n<tr>\n<td>Corces et al. \"An improved ATAC-seq protocol\"</td>\n<td>Nature Methods</td>\n<td>2017</td>\n<td>10.1038/nmeth.4396</td>\n<td>Omni-ATAC improvements (~2,500 citations)</td>\n</tr>\n<tr>\n<td>ENCODE Project Consortium \"Expanded encyclopaedias\"</td>\n<td>Nature</td>\n<td>2020</td>\n<td>10.1038/s41586-020-2493-4</td>\n<td>ENCODE Phase 3 standards</td>\n</tr>\n<tr>\n<td>Amemiya et al. \"ENCODE Blacklist\"</td>\n<td>Scientific Reports</td>\n<td>2019</td>\n<td>10.1038/s41598-019-45839-z</td>\n<td>Artifact regions (~1,372 citations)</td>\n</tr>\n<tr>\n<td>Langmead &amp; Salzberg \"Fast gapped-read alignment with Bowtie 2\"</td>\n<td>Nature Methods</td>\n<td>2012</td>\n<td>10.1038/nmeth.1923</td>\n<td>Aligner (~30,000 citations)</td>\n</tr>\n<tr>\n<td>Yan et al. \"From reads to insight: ATAC-seq analysis\"</td>\n<td>Genome Biology</td>\n<td>2020</td>\n<td>10.1186/s13059-020-1929-3</td>\n<td>Analysis best practices</td>\n</tr>\n</tbody>\n</table>\n<h2>Pipeline Stages</h2>\n<pre><code>FASTQ ──&gt; FastQC / Trim Galore ──&gt; Bowtie2 ──&gt; Mito Removal ──&gt; Picard MarkDuplicates\n  │                                            (chrM dropped)   (duplicates REMOVED)\n  │                                                                       │\n  │           ┌───────────────────────────────────────────────────────────┘\n  │           v\n  │     Tn5 Shift (alignmentSieve --ATACshift) ──&gt; Blacklist Filter ──&gt; Size Selection\n  │                                                       │                    │\n  │                                                       │        ┌───────────┴────────┐\n  │                                                       v        v                    v\n  │                                               Signal Track   NFR (&lt;150 bp)   Mono-nucleosome\n  │                                                (all frags)      │              (150-300 bp)\n  │                                                                 v\n  │                                                   MACS2 Peak Calling ──&gt; IDR (every pair)\n  │                                                                 │\n  │                                                                 v\n  │                                                   FRiP (NFR peaks vs final BAM)\n  v\n QC reports ────────────────────────────────────────────────────────────────&gt; MultiQC\n</code></pre>\n<p>The Tn5 shift runs <strong>after</strong> duplicate removal, and peaks are called on the\nnucleosome-free BAM only. The signal track is built from all fragments in the\nblacklist-filtered BAM, not from the NFR BAM.</p>\n<h3>Stage Summary</h3>\n<table>\n<thead>\n<tr>\n<th>Stage</th>\n<th>Tool</th>\n<th>Input</th>\n<th>Output</th>\n<th>Reference</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>1. QC &amp; Trimming</td>\n<td>FastQC, Trim Galore</td>\n<td>Raw FASTQ</td>\n<td>Trimmed FASTQ, FastQC reports</td>\n<td>references/01-qc-trimming.md</td>\n</tr>\n<tr>\n<td>2. Alignment</td>\n<td>Bowtie2, samtools</td>\n<td>Trimmed FASTQ</td>\n<td>Sorted BAM, flagstat, bowtie2 log</td>\n<td>references/02-alignment.md</td>\n</tr>\n<tr>\n<td>3. Filtering &amp; Tn5 shift</td>\n<td>samtools, Picard, deeptools <code>alignmentSieve</code>, bedtools</td>\n<td>Sorted BAM</td>\n<td>Shifted, filtered, size-selected BAMs</td>\n<td>references/03-tn5-filtering.md</td>\n</tr>\n<tr>\n<td>4. Peak Calling &amp; IDR</td>\n<td>MACS2, IDR</td>\n<td>NFR BAM</td>\n<td>narrowPeak, one <code>&lt;sampleA&gt;_vs_&lt;sampleB&gt;.idr_peaks.txt</code> per replicate pair</td>\n<td>references/04-peak-calling.md</td>\n</tr>\n<tr>\n<td>5. Signal, FRiP &amp; QC report</td>\n<td>deeptools <code>bamCoverage</code>, bedtools, samtools, MultiQC</td>\n<td>Filtered BAM, NFR peaks, QC logs</td>\n<td>bigWig, <code>&lt;sample&gt;.frip_mqc.tsv</code>, multiqc_report.html</td>\n<td>references/05-qc-metrics.md</td>\n</tr>\n</tbody>\n</table>\n<h2>Input Requirements</h2>\n<h3>Required</h3>\n<ul>\n<li><strong>ATAC-seq FASTQ</strong> (<code>--reads</code>): paired-end reads, gzipped. A Nextflow file-pair glob,\ne.g. <code>'fastq/*_R{1,2}.fq.gz'</code>.</li>\n<li><strong>Bowtie2 index directory</strong> (<code>--bowtie2_index</code>): Bowtie2 is invoked as\n<code>bowtie2 ... -x &lt;dir&gt;/&lt;genome&gt;</code>, so the directory must hold index files named after the\ngenome:</li>\n</ul>\n<pre><code>GRCh38_bowtie2_index/\n  GRCh38.1.bt2  GRCh38.2.bt2  GRCh38.3.bt2  GRCh38.4.bt2\n  GRCh38.rev.1.bt2  GRCh38.rev.2.bt2\n</code></pre>\n<p>Build it once with <code>bowtie2-build GRCh38.fa GRCh38_bowtie2_index/GRCh38</code>. If the flag is\nomitted, the workflow looks for <code>./&lt;genome&gt;_bowtie2_index</code> in the launch directory. The\nworkflow does not build or download the index.</p>\n<h3>Optional</h3>\n<ul>\n<li><strong>Blacklist</strong> (<code>--blacklist</code>): defaults to the ENCODE Blacklist v2 URL for <code>--genome</code>.</li>\n</ul>\n<p>There is no sample sheet and no input control. Inputs are globs, and every sample in a run\nshares one <code>--genome</code>. Unlike ChIP-seq, ATAC-seq does not need a separate input or IgG\ncontrol; MACS2 calls peaks against a local background model.</p>\n<h2>Tn5 Transposase Offset Correction</h2>\n<p>The Tn5 transposase inserts sequencing adapters with a 9-bp duplication. To center\nreads on the actual cut site:</p>\n<ul>\n<li><strong>Forward strand (+)</strong>: shift +4 bp</li>\n<li><strong>Reverse strand (-)</strong>: shift -5 bp</li>\n</ul>\n<p>The workflow applies this with <code>alignmentSieve --ATACshift</code> (deeptools) after duplicate\nremoval and before blacklist filtering. The correction is essential for footprinting and\nmotif analysis.</p>\n<h2>Fragment Size Distribution</h2>\n<p>ATAC-seq produces a characteristic nucleosomal ladder pattern:</p>\n<table>\n<thead>\n<tr>\n<th>Fragment Class</th>\n<th>Size Range</th>\n<th>Biological Meaning</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Nucleosome-free (NFR)</td>\n<td>&lt;150 bp</td>\n<td>Open chromatin / TF binding</td>\n</tr>\n<tr>\n<td>Mono-nucleosome</td>\n<td>150-300 bp</td>\n<td>Single nucleosome wrapping</td>\n</tr>\n<tr>\n<td>Di-nucleosome</td>\n<td>300-500 bp</td>\n<td>Two nucleosomes</td>\n</tr>\n<tr>\n<td>Tri-nucleosome</td>\n<td>500-700 bp</td>\n<td>Three nucleosomes</td>\n</tr>\n</tbody>\n</table>\n<p>The workflow calls peaks on the nucleosome-free BAM. The NFR/mono-nucleosome boundary is\n<code>--nfr_max</code> (default 150); the mono-nucleosome selection is <code>--nfr_max</code> to 300 bp. The\nworkflow does not plot the fragment size distribution.</p>\n<h2>Parameters</h2>\n<h3>Pipeline parameters (<code>main.nf</code>)</h3>\n<table>\n<thead>\n<tr>\n<th>Parameter</th>\n<th>Default</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>--reads</code></td>\n<td>none (required)</td>\n<td>Glob for the paired-end FASTQ file pairs</td>\n</tr>\n<tr>\n<td><code>--bowtie2_index</code></td>\n<td><code>./&lt;genome&gt;_bowtie2_index</code></td>\n<td>Directory holding the Bowtie2 index files named <code>&lt;genome&gt;.*.bt2</code></td>\n</tr>\n<tr>\n<td><code>--genome</code></td>\n<td><code>GRCh38</code></td>\n<td><code>GRCh38</code> or <code>mm10</code>; sets the MACS2 genome size, the default index directory and the default blacklist</td>\n</tr>\n<tr>\n<td><code>--blacklist</code></td>\n<td>ENCODE Blacklist v2 URL for <code>--genome</code></td>\n<td>BED (or <code>.bed.gz</code>) of artifact regions removed from the BAM</td>\n</tr>\n<tr>\n<td><code>--mito_name</code></td>\n<td><code>chrM</code></td>\n<td>Name of the mitochondrial contig to drop</td>\n</tr>\n<tr>\n<td><code>--nfr_max</code></td>\n<td><code>150</code></td>\n<td>Maximum nucleosome-free fragment length, and the lower bound of the mono-nucleosome selection</td>\n</tr>\n<tr>\n<td><code>--skip_idr</code></td>\n<td><code>false</code></td>\n<td>Skip the IDR step</td>\n</tr>\n<tr>\n<td><code>--single_end</code></td>\n<td><code>false</code></td>\n<td>Accepted but always rejected: the workflow stops with an error because it is paired-end only</td>\n</tr>\n<tr>\n<td><code>--outdir</code></td>\n<td><code>results</code></td>\n<td>Where results are published</td>\n</tr>\n</tbody>\n</table>\n<h3>Infrastructure parameters (<code>nextflow.config</code>)</h3>\n<table>\n<thead>\n<tr>\n<th>Parameter</th>\n<th>Default</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>--container</code></td>\n<td><code>encode-toolkit/pipeline-atacseq:1.0.0</code></td>\n<td>Image built from <code>scripts/Dockerfile</code>. Pass a registry image for <code>gcp</code>/<code>aws</code>, or a <code>.sif</code> file for <code>slurm</code></td>\n</tr>\n<tr>\n<td><code>--max_cpus</code>, <code>--max_memory</code>, <code>--max_time</code></td>\n<td><code>16</code>, <code>64.GB</code>, <code>24.h</code></td>\n<td>Upper bounds applied to every process</td>\n</tr>\n<tr>\n<td><code>--slurm_queue</code>, <code>--slurm_account</code></td>\n<td><code>normal</code>, none</td>\n<td>SLURM partition and account</td>\n</tr>\n<tr>\n<td><code>--gcp_project</code>, <code>--gcp_workdir</code></td>\n<td>none (both required for <code>-profile gcp</code>)</td>\n<td>Google Cloud project and <code>gs://</code> work directory</td>\n</tr>\n<tr>\n<td><code>--gcp_location</code>, <code>--gcp_disk</code></td>\n<td><code>us-central1</code>, <code>200.GB</code></td>\n<td>Google Batch region and per-task disk</td>\n</tr>\n<tr>\n<td><code>--aws_queue</code>, <code>--aws_workdir</code></td>\n<td>none (both required for <code>-profile aws</code>)</td>\n<td>AWS Batch job queue and <code>s3://</code> work directory</td>\n</tr>\n<tr>\n<td><code>--aws_region</code>, <code>--aws_cli_path</code></td>\n<td><code>us-east-1</code>, <code>/home/ec2-user/miniconda/bin/aws</code></td>\n<td>AWS region, and the AWS CLI path inside the Batch AMI</td>\n</tr>\n</tbody>\n</table>\n<p>Profiles are <code>local</code>, <code>slurm</code>, <code>gcp</code> and <code>aws</code>.</p>\n<h2>QC Thresholds</h2>\n<p><strong>The workflow computes only the metrics marked \"workflow\" below.</strong> TSS enrichment,\nNRF/PBC, fragment-size plots and ataqv are manual post-processing steps documented in\n<code>references/05-qc-metrics.md</code>.</p>\n<table>\n<thead>\n<tr>\n<th>Metric</th>\n<th>Threshold</th>\n<th>Computed by</th>\n<th>Source</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Total sequenced reads</td>\n<td>&gt;=50M (recommended)</td>\n<td>workflow (FastQC, flagstat)</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>Mapping rate</td>\n<td>&gt;80%</td>\n<td>workflow (bowtie2 log, <code>samtools flagstat</code>)</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>Mitochondrial fraction</td>\n<td>&lt;20% (ideal &lt;5%)</td>\n<td>workflow (<code>qc/&lt;sample&gt;.idxstats.txt</code>)</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>Duplication rate</td>\n<td>&lt;30%</td>\n<td>workflow (Picard <code>dup_metrics.txt</code>)</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>IDR peaks at 0.05</td>\n<td>&gt;50,000</td>\n<td>workflow (<code>peaks/idr/&lt;sampleA&gt;_vs_&lt;sampleB&gt;.idr_peaks.txt</code>)</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>NRF (non-redundant fraction)</td>\n<td>&gt;=0.8</td>\n<td>manual</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>PBC1</td>\n<td>&gt;=0.8</td>\n<td>manual</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>TSS enrichment score</td>\n<td>&gt;=5 (GRCh38), &gt;=6 (hg19), &gt;=10 (mm10)</td>\n<td>manual (deeptools + a TSS BED)</td>\n<td>ENCODE standard</td>\n</tr>\n<tr>\n<td>FRiP</td>\n<td>&gt;=0.3</td>\n<td>workflow (<code>qc/&lt;sample&gt;.frip_mqc.tsv</code>)</td>\n<td>ENCODE</td>\n</tr>\n<tr>\n<td>NFR fraction</td>\n<td>&gt;0.4 of fragments &lt;150bp</td>\n<td>manual</td>\n<td>Buenrostro 2013</td>\n</tr>\n</tbody>\n</table>\n<p><code>qc/&lt;sample&gt;.idxstats.txt</code> is <code>samtools idxstats</code> of the BAM before mitochondrial reads are\nremoved (contig, length, mapped, unmapped): the mitochondrial fraction is the mapped count\non the <code>--mito_name</code> row divided by the sum of the mapped column. MultiQC's samtools module\nreads the same file and reports that fraction.</p>\n<h3>TSS Enrichment Score (manual)</h3>\n<p>The TSS enrichment score measures the fold enrichment of ATAC-seq signal at\ntranscription start sites compared to flanking regions. It is the single most\ninformative QC metric for ATAC-seq, but <strong>this workflow does not compute it</strong>: there is no\nTSS BED input and no <code>computeMatrix</code>/<code>plotProfile</code> step. Run it manually against\n<code>signal/&lt;sample&gt;.signal.bw</code> with a TSS BED for your assembly; the commands are in\n<code>references/05-qc-metrics.md</code>.</p>\n<table>\n<thead>\n<tr>\n<th>Score</th>\n<th>Quality</th>\n<th>Interpretation</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>&gt;=7</td>\n<td>Excellent</td>\n<td>High signal-to-noise</td>\n</tr>\n<tr>\n<td>5-7</td>\n<td>Good</td>\n<td>Acceptable for most analyses</td>\n</tr>\n<tr>\n<td>3-5</td>\n<td>Marginal</td>\n<td>Review other metrics carefully</td>\n</tr>\n<tr>\n<td>&lt;3</td>\n<td>Poor</td>\n<td>Likely failed; consider re-doing</td>\n</tr>\n</tbody>\n</table>\n<h2>Execution</h2>\n<h3>Quick Start (Local Docker)</h3>\n<pre><code>nextflow run scripts/main.nf \\\n  -profile local \\\n  --reads 'fastq/*_R{1,2}.fq.gz' \\\n  --genome GRCh38 \\\n  --bowtie2_index GRCh38_bowtie2_index \\\n  --blacklist hg38-blacklist.v2.bed.gz \\\n  --outdir results/\n</code></pre>\n<p><code>--blacklist</code> is optional; without it the workflow downloads the ENCODE Blacklist v2 for\n<code>--genome</code>. Give the glob at least two replicates if you want the IDR step to run.</p>\n<h3>SLURM HPC</h3>\n<p>The <code>slurm</code> profile runs through Singularity, so pass a local image file rather than the\ndefault Docker image name:</p>\n<pre><code>singularity build pipeline-atacseq.sif docker-daemon://encode-toolkit/pipeline-atacseq:1.0.0\n\nnextflow run scripts/main.nf \\\n  -profile slurm \\\n  --container /path/to/pipeline-atacseq.sif \\\n  --slurm_queue normal \\\n  --reads 'fastq/*_R{1,2}.fq.gz' \\\n  --genome GRCh38 \\\n  --bowtie2_index GRCh38_bowtie2_index \\\n  --outdir results/\n</code></pre>\n<h3>Cloud</h3>\n<pre><code># Google Cloud Batch\nnextflow run scripts/main.nf -profile gcp \\\n    --container us-docker.pkg.dev/&lt;project&gt;/&lt;repo&gt;/pipeline-atacseq:1.0.0 \\\n    --gcp_project &lt;project&gt; \\\n    --gcp_workdir gs://&lt;bucket&gt;/work \\\n    --reads 'gs://&lt;bucket&gt;/fastq/*_R{1,2}.fq.gz' \\\n    --genome GRCh38 \\\n    --bowtie2_index gs://&lt;bucket&gt;/reference/GRCh38_bowtie2_index \\\n    --outdir gs://&lt;bucket&gt;/results\n\n# AWS Batch\nnextflow run scripts/main.nf -profile aws \\\n    --container &lt;account&gt;.dkr.ecr.&lt;region&gt;.amazonaws.com/pipeline-atacseq:1.0.0 \\\n    --aws_queue &lt;job-queue&gt; \\\n    --aws_workdir s3://&lt;bucket&gt;/work \\\n    --reads 's3://&lt;bucket&gt;/fastq/*_R{1,2}.fq.gz' \\\n    --genome GRCh38 \\\n    --bowtie2_index s3://&lt;bucket&gt;/reference/GRCh38_bowtie2_index \\\n    --outdir s3://&lt;bucket&gt;/results\n</code></pre>\n<p><code>--outdir</code> only sets where results are published; Google Batch and AWS Batch stage every\ntask through the work directory, and the workflow stops with an error if it or the\nproject/queue is missing.</p>\n<h2>Cloud Cost Estimates</h2>\n<table>\n<thead>\n<tr>\n<th>Platform</th>\n<th>Instance</th>\n<th>Cost/Sample</th>\n<th>Time/Sample</th>\n<th>Notes</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>GCP</td>\n<td>n1-standard-8</td>\n<td>~$2-4</td>\n<td>2-3 hours</td>\n<td>Spot VMs enabled in the <code>gcp</code> profile</td>\n</tr>\n<tr>\n<td>AWS</td>\n<td>m5.2xlarge</td>\n<td>~$2-4</td>\n<td>2-3 hours</td>\n<td>Spot instances recommended</td>\n</tr>\n<tr>\n<td>Local</td>\n<td>8 cores, 32GB</td>\n<td>$0</td>\n<td>3-5 hours</td>\n<td>Docker required</td>\n</tr>\n<tr>\n<td>SLURM</td>\n<td>8 cores, 32GB</td>\n<td>Varies</td>\n<td>2-3 hours</td>\n<td>Singularity image required</td>\n</tr>\n</tbody>\n</table>\n<h2>Output Directory Structure</h2>\n<pre><code>results/\n  fastqc/                   # FastQC reports for raw and trimmed reads (.html, .zip)\n  trimmed/                  # Trimmed FASTQ (*_val_1.fq.gz / *_val_2.fq.gz) + trimming reports\n  aligned/                  # &lt;sample&gt;.bam, .bam.bai, &lt;sample&gt;.flagstat.txt,\n                            #   &lt;sample&gt;.bowtie2.log\n  filtered/                 # &lt;sample&gt;.dup_metrics.txt, &lt;sample&gt;.final.bam(.bai),\n                            #   &lt;sample&gt;.final.flagstat.txt\n    shifted/                # &lt;sample&gt;.shifted.bam(.bai) -- Tn5-corrected, pre-blacklist\n    nfr/                    # &lt;sample&gt;.nfr.bam(.bai) and &lt;sample&gt;.mononuc.bam\n  peaks/\n    narrow/                 # &lt;sample&gt;_peaks.narrowPeak, _summits.bed, _peaks.xls,\n                            #   _treat_pileup.bdg, _control_lambda.bdg\n    idr/                    # &lt;sampleA&gt;_vs_&lt;sampleB&gt;.idr_peaks.txt (+ .png), one file per\n                            #   replicate pair\n  signal/                   # &lt;sample&gt;.signal.bw (all fragments, RPKM)\n  qc/\n    &lt;sample&gt;.idxstats.txt   # samtools idxstats before chrM removal:\n                            #   contig / length / mapped / unmapped\n    &lt;sample&gt;.frip_mqc.tsv   # Peak set / FRiP / reads_in_peaks / total_reads\n    multiqc/                # multiqc_report.html, multiqc_data/\n  pipeline_info/            # timeline.html, report.html, trace.txt\n</code></pre>\n<p>The nucleosome-free and mono-nucleosome BAMs are both written to <code>filtered/nfr/</code>; there is\nno <code>filtered/mononuc/</code> directory, and <code>mononuc.bam</code> has no index.</p>\n<h2>Common Pitfalls</h2>\n<h3>1. High Mitochondrial Read Fraction</h3>\n<p>Mitochondrial DNA lacks chromatin and is highly accessible, often capturing 30-80%\nof reads. This is the most common ATAC-seq quality issue. The workflow removes <code>--mito_name</code>\nreads and publishes the per-contig counts it used, <code>qc/&lt;sample&gt;.idxstats.txt</code>: divide the\nmapped count on the <code>--mito_name</code> row by the sum of the mapped column to get the fraction,\nor read it from the samtools section of the MultiQC report. If &gt;50% mito, consider\noptimizing the cell lysis step.</p>\n<h3>2. Wrong mitochondrial contig name</h3>\n<p><code>--mito_name</code> defaults to <code>chrM</code>. Assemblies that call the contig <code>MT</code> need\n<code>--mito_name MT</code>. Confirm the name with <code>samtools idxstats</code> on a BAM from your index\nbefore running.</p>\n<h3>3. Using BWA Instead of Bowtie2</h3>\n<p>Bowtie2 handles the short fragments from ATAC-seq (especially NFR &lt;150bp) better\nthan BWA-MEM. The workflow uses Bowtie2 with <code>--very-sensitive</code>.</p>\n<h3>4. Only one replicate in the <code>--reads</code> glob</h3>\n<p>IDR needs a pair of samples. With one sample there is no pair, so IDR is skipped silently\nand <code>peaks/idr/</code> is never created. Every sample matched by <code>--reads</code> is treated as a\nreplicate of the same experiment, so unrelated samples in one glob produce meaningless\npairwise comparisons.</p>\n<h3>5. TSS enrichment is not in the output</h3>\n<p>TSS enrichment is the most informative single metric for ATAC-seq, but the workflow does\nnot compute it. Run the manual <code>computeMatrix</code>/<code>plotProfile</code> step in\n<code>references/05-qc-metrics.md</code> before judging a library.</p>\n<h2>Pipeline Scripts</h2>\n<table>\n<thead>\n<tr>\n<th>File</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>scripts/main.nf</code></td>\n<td>Nextflow DSL2 pipeline</td>\n</tr>\n<tr>\n<td><code>scripts/nextflow.config</code></td>\n<td>Execution profiles (local/slurm/gcp/aws)</td>\n</tr>\n<tr>\n<td><code>scripts/Dockerfile</code></td>\n<td>Docker image with all pipeline tools</td>\n</tr>\n</tbody>\n</table>\n<p>The image is pinned to <code>linux/amd64</code>; on an arm64 host it runs under emulation.</p>\n<p>Tool versions in the image: Bowtie2 2.5.4, samtools 1.19, bedtools 2.31.0, Picard 3.1.1\n(Java 17), Trim Galore 0.6.10 with cutadapt 4.6, FastQC 0.12.1, MACS2 2.2.9.1,\nIDR 2.0.4.2, deepTools 3.5.5, MultiQC 1.21. The conda environment\n<code>bioinformatics-installer/environments/atacseq-env.yml</code> pins the same versions of the\ntools it lists.</p>\n<h2>ENCODE Data Integration</h2>\n<p>After running on your own data, compare with ENCODE reference:</p>\n<pre><code># Find matching ENCODE ATAC-seq experiments\nencode_search_experiments(\n    assay_title=\"ATAC-seq\",\n    organ=\"pancreas\",\n    biosample_type=\"tissue\"\n)\n\n# Download ENCODE peaks for comparison\nencode_batch_download(\n    download_dir=\"/data/encode_reference/\",\n    output_type=\"IDR thresholded peaks\",\n    assay_title=\"ATAC-seq\",\n    organ=\"pancreas\",\n    assembly=\"GRCh38\"\n)\n</code></pre>\n<h2>Pitfalls &amp; Edge Cases</h2>\n<ul>\n<li><strong>Tn5 shift is critical</strong>: ATAC-seq reads must be shifted +4/-5 bp to center on the Tn5\ninsertion site. The workflow does this with <code>alignmentSieve --ATACshift</code> after duplicate\nremoval. Without the correction, footprinting is offset by ~5 bp.</li>\n<li><strong>Mitochondrial reads dominate</strong>: Expect 30-80% mitochondrial reads. The workflow drops\nthem right after alignment, before duplicate removal and peak calling. &gt;80% chrM\nindicates dead/dying cells or poor nuclei isolation.</li>\n<li><strong>Fragment size distribution is diagnostic</strong>: a nucleosomal ladder (sub-nucleosomal\n&lt;150bp, mono-nucleosomal ~200bp, di-nucleosomal ~400bp) confirms successful\ntransposition. The workflow does not plot it; use <code>bamPEFragmentSize</code> manually.</li>\n<li><strong>TSS enrichment threshold</strong>: ENCODE requires TSS enrichment &gt;=5 (GRCh38), &gt;=6 (hg19), or\n<blockquote>\n<p>=10 (mm10) for ATAC-seq (ENCODE data standards). Values below 4 indicate poor\nsignal-to-noise. Computed manually, not by this workflow.</p>\n</blockquote>\n</li>\n<li><strong>MACS2 <code>--shift</code>/<code>--extsize</code> do not apply here</strong>: the workflow calls peaks in <code>-f BAMPE</code>\nmode, where MACS2 takes fragment coordinates from read pairs, forces <code>--nomodel</code> and\nneutralises <code>--shift</code> internally. Shift/extension values only matter when calling peaks\non BED or single-end input. See <code>references/04-peak-calling.md</code>.</li>\n<li><strong>Paired-end only</strong>: <code>--single_end</code> is rejected with an error. Single-end ATAC-seq cannot\ndistinguish nucleosome-free from nucleosomal fragments.</li>\n</ul>\n<h2>Walkthrough: Processing ENCODE ATAC-seq from FASTQ to Accessible Chromatin Peaks</h2>\n<p><strong>Goal</strong>: Process raw ATAC-seq FASTQ files through this pipeline to generate\nnucleosome-free region peaks and a signal track.\n<strong>Context</strong>: Bowtie2 alignment, chrM removal, duplicate removal, Tn5 shift (+4/-5),\nblacklist filtering, NFR selection and MACS2 peak calling.</p>\n<h3>Step 1: Find ATAC-seq experiment</h3>\n<pre><code>encode_get_experiment(accession=\"ENCSR637ENO\")\n</code></pre>\n<p>Expected output (fields abridged):</p>\n<pre><code>{\n  \"accession\": \"ENCSR637ENO\",\n  \"assay_title\": \"ATAC-seq\",\n  \"biosample_summary\": \"GM12878\",\n  \"assembly\": [\"GRCh38\"],\n  \"bio_replicate_count\": 2,\n  \"tech_replicate_count\": 2,\n  \"status\": \"released\"\n}\n</code></pre>\n<h3>Step 2: List FASTQ files</h3>\n<pre><code>encode_list_files(experiment_accession=\"ENCSR637ENO\", file_format=\"fastq\")\n</code></pre>\n<p>Expected output (a JSON array of files; fields abridged):</p>\n<pre><code>[\n  {\"accession\": \"ENCFF100ATQ\", \"file_format\": \"fastq\", \"output_type\": \"reads\", \"biological_replicates\": [1], \"file_size_human\": \"1.8 GB\"},\n  {\"accession\": \"ENCFF101ATQ\", \"file_format\": \"fastq\", \"output_type\": \"reads\", \"biological_replicates\": [1], \"file_size_human\": \"1.9 GB\"},\n  {\"accession\": \"ENCFF102ATQ\", \"file_format\": \"fastq\", \"output_type\": \"reads\", \"biological_replicates\": [2], \"file_size_human\": \"1.7 GB\"},\n  {\"accession\": \"ENCFF103ATQ\", \"file_format\": \"fastq\", \"output_type\": \"reads\", \"biological_replicates\": [2], \"file_size_human\": \"1.8 GB\"}\n]\n</code></pre>\n<p>The listing does not say which file of a pair is read 1 and which is read 2 -- no\n<code>encode_*</code> tool reports that. Open each file's page on encodeproject.org, where\n<code>paired_end</code> is 1 or 2 and <code>paired_with</code> names the other accession. Both replicates are\nneeded for the IDR step.</p>\n<h3>Step 3: Download and name the FASTQs so a read-pair glob can find them</h3>\n<pre><code>encode_download_files(file_accessions=[\"ENCFF100ATQ\", \"ENCFF101ATQ\", \"ENCFF102ATQ\", \"ENCFF103ATQ\"], download_dir=\"/data/atacseq/fastq\")\n</code></pre>\n<p>ENCODE FASTQs are named by accession (<code>ENCFF123ABC.fastq.gz</code>) with no <code>_R1</code>/<code>_R2</code> in the\nname, so the <code>--reads</code> glob (<code>*_R{1,2}.fq.gz</code>) cannot pair them. Take the mate assignment\nfrom each file's page on encodeproject.org (<code>paired_end</code> is 1 or 2, <code>paired_with</code> names the\nother accession), then link them into the shape the glob expects:</p>\n<pre><code>cd /data/atacseq/fastq\nln -s ENCFF100ATQ.fastq.gz gm12878_rep1_R1.fq.gz\nln -s ENCFF101ATQ.fastq.gz gm12878_rep1_R2.fq.gz\nln -s ENCFF102ATQ.fastq.gz gm12878_rep2_R1.fq.gz\nln -s ENCFF103ATQ.fastq.gz gm12878_rep2_R2.fq.gz\n</code></pre>\n<h3>Step 4: Run the ATAC-seq pipeline</h3>\n<pre><code>nextflow run scripts/main.nf \\\n  -profile local \\\n  --reads '/data/atacseq/fastq/gm12878_*_R{1,2}.fq.gz' \\\n  --genome GRCh38 \\\n  --bowtie2_index /data/reference/GRCh38_bowtie2_index \\\n  --blacklist /data/reference/hg38-blacklist.v2.bed.gz \\\n  --mito_name chrM \\\n  --outdir /data/atacseq/results\n</code></pre>\n<p>Pipeline steps, in the order the workflow runs them:</p>\n<ol>\n<li>FastQC on raw reads</li>\n<li>Adapter trimming with Trim Galore (<code>--nextera</code>), plus FastQC on the trimmed reads</li>\n<li>Alignment (Bowtie2 <code>--very-sensitive</code>, MAPQ 30, properly paired only)</li>\n<li>Mitochondrial read removal, with <code>samtools idxstats</code> of the pre-removal BAM published as <code>qc/&lt;sample&gt;.idxstats.txt</code></li>\n<li>Duplicate removal (Picard <code>REMOVE_DUPLICATES=true</code>)</li>\n<li>Tn5 shift correction (+4/-5, <code>alignmentSieve --ATACshift</code>)</li>\n<li>Blacklist filtering of the BAM</li>\n<li>Nucleosome-free (&lt;150 bp) and mono-nucleosome (150-300 bp) selection</li>\n<li>Peak calling on the NFR BAM (MACS2 <code>-f BAMPE --nomodel --keep-dup all --call-summits --qvalue 0.05 -B</code>)</li>\n<li>IDR on every pair of replicates, signal track from all fragments, FRiP, MultiQC</li>\n</ol>\n<h3>Step 5: Validate output quality</h3>\n<p>From the workflow:</p>\n<table>\n<thead>\n<tr>\n<th>Output</th>\n<th>What to check</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>qc/multiqc/multiqc_report.html</code></td>\n<td>Mapping rate (&gt;80%), adapter content, duplication rate, mitochondrial fraction, FRiP</td>\n</tr>\n<tr>\n<td><code>qc/&lt;sample&gt;.idxstats.txt</code></td>\n<td>Mitochondrial fraction (&lt;20%, ideal &lt;5%): mapped reads on the <code>chrM</code> row over the sum of the mapped column</td>\n</tr>\n<tr>\n<td><code>qc/&lt;sample&gt;.frip_mqc.tsv</code></td>\n<td>FRiP (&gt;=0.3 for ATAC-seq)</td>\n</tr>\n<tr>\n<td><code>peaks/narrow/&lt;sample&gt;_peaks.narrowPeak</code></td>\n<td>Peak count per replicate</td>\n</tr>\n<tr>\n<td><code>peaks/idr/gm12878_rep1_vs_gm12878_rep2.idr_peaks.txt</code></td>\n<td>IDR peaks at 0.05 (&gt;50,000)</td>\n</tr>\n</tbody>\n</table>\n<p>With the two replicates above there is one IDR file; a third replicate would add\n<code>gm12878_rep1_vs_gm12878_rep3</code> and <code>gm12878_rep2_vs_gm12878_rep3</code>.</p>\n<p>Manual follow-ups (not run by this workflow): TSS enrichment, fragment-size distribution\nplots, NRF/PBC and ataqv. Commands are in <code>references/05-qc-metrics.md</code>.</p>\n<h3>Step 6: Track and log provenance</h3>\n<pre><code>encode_track_experiment(accession=\"ENCSR637ENO\", notes=\"GM12878 ATAC-seq processed through the pipeline-atacseq skill\")\n</code></pre>\n<h3>Integration with downstream skills</h3>\n<ul>\n<li>Accessible chromatin peaks feed into -&gt; <strong>accessibility-aggregation</strong> for cross-experiment union merge</li>\n<li>Peak regions feed into -&gt; <strong>motif-analysis</strong> for TF motif enrichment</li>\n<li>Signal tracks feed into -&gt; <strong>visualization-workflow</strong> for browser display</li>\n<li>Peaks feed into -&gt; <strong>regulatory-elements</strong> for cCRE classification</li>\n<li>QC metrics validated by -&gt; <strong>quality-assessment</strong></li>\n</ul>\n<h2>Code Examples</h2>\n<h3>1. Find ATAC-seq data for processing</h3>\n<pre><code>encode_search_experiments(\n  assay_title=\"ATAC-seq\",\n  organ=\"pancreas\"\n)\n</code></pre>\n<p>Expected output:</p>\n<pre><code>{\n  \"results\": [\n    {\n      \"accession\": \"ENCSR789PAN\",\n      \"assay_title\": \"ATAC-seq\",\n      \"biosample_summary\": \"pancreas tissue male adult (44 years)\",\n      \"status\": \"released\"\n    }\n  ],\n  \"total\": 8,\n  \"limit\": 25,\n  \"offset\": 0,\n  \"has_more\": false,\n  \"next_offset\": null\n}\n</code></pre>\n<h3>2. Check file details before download</h3>\n<pre><code>encode_list_files(\n  experiment_accession=\"ENCSR789PAN\",\n  file_format=\"fastq\"\n)\n</code></pre>\n<p>Expected output:</p>\n<pre><code>[\n  {\n    \"accession\": \"ENCFF100ATQ\",\n    \"file_format\": \"fastq\",\n    \"output_type\": \"reads\",\n    \"biological_replicates\": [1],\n    \"file_size_human\": \"3.1 GB\",\n    \"status\": \"released\"\n  }\n]\n</code></pre>\n<h2>Integration</h2>\n<table>\n<thead>\n<tr>\n<th>This skill produces...</th>\n<th>Feed into...</th>\n<th>Purpose</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Accessible chromatin peaks</td>\n<td><strong>accessibility-aggregation</strong></td>\n<td>Cross-experiment union merge</td>\n</tr>\n<tr>\n<td>Peak regions (BED)</td>\n<td><strong>motif-analysis</strong></td>\n<td>TF motif enrichment in open chromatin</td>\n</tr>\n<tr>\n<td>Signal tracks (bigWig)</td>\n<td><strong>visualization-workflow</strong></td>\n<td>Genome browser accessibility display</td>\n</tr>\n<tr>\n<td>Nucleosome-free peaks</td>\n<td><strong>regulatory-elements</strong></td>\n<td>Classify accessible regions as enhancers/promoters</td>\n</tr>\n<tr>\n<td>Peak coordinates</td>\n<td><strong>variant-annotation</strong></td>\n<td>Identify variants in accessible chromatin</td>\n</tr>\n<tr>\n<td>QC outputs (<code>idxstats.txt</code>, <code>frip_mqc.tsv</code>, MultiQC)</td>\n<td><strong>quality-assessment</strong></td>\n<td>Validate against ENCODE ATAC-seq standards</td>\n</tr>\n<tr>\n<td><code>pipeline_info/</code> reports</td>\n<td><strong>data-provenance</strong></td>\n<td>Record Tn5 shift, fragment filters, tool versions</td>\n</tr>\n<tr>\n<td>Peak files</td>\n<td><strong>jaspar-motifs</strong></td>\n<td>Scan accessible regions for known TF motifs</td>\n</tr>\n</tbody>\n</table>\n<h2>Related Skills</h2>\n<ul>\n<li><strong>pipeline-guide</strong> (parent): General pipeline selection and resource assessment</li>\n<li><strong>accessibility-aggregation</strong>: Merge ATAC-seq peaks across samples</li>\n<li><strong>quality-assessment</strong>: Deep-dive QC analysis beyond basic metrics</li>\n<li><strong>regulatory-elements</strong>: Annotate peaks with regulatory element classifications</li>\n<li><strong>compare-biosamples</strong>: Compare accessibility profiles across cell types</li>\n<li><strong>pipeline-chipseq</strong>: Sibling pipeline for ChIP-seq data</li>\n<li><strong>publication-trust</strong>: Verify literature claims backing analytical decisions</li>\n</ul>\n<h2>Presenting Results</h2>\n<p>When reporting ATAC-seq pipeline results:</p>\n<ul>\n<li><strong>Mitochondrial fraction</strong>: Report it from <code>qc/&lt;sample&gt;.idxstats.txt</code> -- mapped reads on\nthe <code>--mito_name</code> row over the sum of the mapped column -- or from the samtools section\nof the MultiQC report (ideal &lt;5%, acceptable &lt;20%)</li>\n<li><strong>Key QC metrics from the run</strong>: mapping rate (bowtie2 log, <code>samtools flagstat</code>),\nduplication rate (Picard <code>dup_metrics.txt</code>), and read counts, all aggregated in\n<code>qc/multiqc/multiqc_report.html</code></li>\n<li><strong>Peak counts</strong>: Report the per-replicate MACS2 peak count and, for every replicate pair,\nthe IDR peak count at the 0.05 threshold. IDR is skipped when only one sample was\nprocessed</li>\n<li><strong>TSS enrichment</strong>: State plainly that the workflow does not compute it. Report it only\nif the user ran the manual step, with the quality tier (Excellent &gt;=7, Good 5-7,\nMarginal 3-5, Poor &lt;3)</li>\n<li><strong>FRiP</strong>: Report the value from <code>qc/&lt;sample&gt;.frip_mqc.tsv</code> (&gt;=0.3 for ATAC-seq). It is\ncomputed from the blacklist-filtered BAM (all fragments) against the peaks called on the\nnucleosome-free fragments</li>\n<li><strong>Fragment size distribution / NFR fraction / ataqv</strong>: also manual; do not report values\nthe run did not produce</li>\n<li><strong>Output paths</strong>: List key outputs (<code>peaks/narrow/</code>, <code>peaks/idr/</code>, <code>signal/</code>,\n<code>filtered/nfr/</code>, <code>qc/</code>, <code>pipeline_info/</code>)</li>\n<li><strong>Next steps</strong>: Suggest <code>motif-analysis</code> for TF footprinting and de novo motif discovery,\nor <code>visualization-workflow</code> for genome browser session generation</li>\n</ul>\n<h2>For the request: \"$ARGUMENTS\"</h2>\n","files":[{"path":"references/01-qc-trimming.md","sizeBytes":2480,"isText":true},{"path":"references/02-alignment.md","sizeBytes":3798,"isText":true},{"path":"references/03-tn5-filtering.md","sizeBytes":4978,"isText":true},{"path":"references/04-peak-calling.md","sizeBytes":4701,"isText":true},{"path":"references/05-qc-metrics.md","sizeBytes":5668,"isText":true},{"path":"references/literature.md","sizeBytes":15844,"isText":true},{"path":"scripts/Dockerfile","sizeBytes":3242,"isText":false},{"path":"scripts/main.nf","sizeBytes":13624,"isText":false},{"path":"scripts/nextflow.config","sizeBytes":4972,"isText":false},{"path":"SKILL.md","sizeBytes":29249,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-22T13:27:27.422375Z","sha256":"DB9BCB41908A9BE240758DA50ED53C5ECA632871013037D7D63E3AF6E2BBAE9C","sizeBytes":34245},"review":null,"source":{"repositoryUrl":"https://github.com/ammawla/encode-toolkit","path":"skills/pipeline-atacseq","license":"AGPL-3.0","commit":"36836c8725fd4d20d9c851ce314f5151aea5f57c","subtreeSha":"ACAFF4F3C4B8A699A3E7845A827F4236EF7BDA1D7DBB324B8527E9024545F09F","lastSyncedAt":"2026-09-29T20:56:54.045383Z"},"reviewedAt":"2026-09-22T13:30:30.326283Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/ammawla/encode-toolkit/tree/main/skills/pipeline-atacseq"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install ammawla-encode-toolkit@llmmart"},{"target":"git","command":"git clone https://github.com/ammawla/encode-toolkit.git"}]}