ATAC-seq processing and peak calling

From raw reads to Tn5 insertion sites, peaks, replicate agreement and a consensus peak set

Epigenetics

About this lecture

In ATAC-seq: Tn5, fragment sizes, nucleosome ladder you saw what the assay measures. This lecture turns the reads into the things every downstream analysis starts from: peaks and a consensus peak set.

  • Reads to a clean BAM: trimming Nextera adapters, alignment with long fragments allowed, and five filters, each with a reason.
  • Tn5 insertion sites: the +4/−5 shift, and when to think in fragments or in cut sites.
  • Peak calling: what MACS3 computes (a local Poisson background), and the two ways to run it on ATAC-seq.
  • Replicates: naive overlap vs rank consistency (IDR) and pseudoreplicates.
  • Consensus peaks across samples, FRiP, comparison with ENCODE, and where the peaks sit.

The ATAC-seq pipeline, end to end

  • Ten steps; each one answers a specific problem with the raw data. We go through them in order.
  • Production pipelines do exactly this: nf-core/atacseq (Nextflow) and the ENCODE ATAC-seq pipeline (WDL). Learn the steps on one sample by hand, then run the pipeline on all of them.

Trim the adapters first

  • Tn5 loads the Nextera adapters. Both reads of a short fragment run into the adapter: CTGTCTCTTATACACATCT….
  • ATAC-seq is made of short fragments: in our data fastp trimmed adapter bases from 38% of the reads.
  • Untrimmed, these reads fail to align end to end or align with mismatches at the ends; trim with fastp, cutadapt or Trim Galore.

Align with room for long fragments

bowtie2 -p 8 --very-sensitive -X 2000 -x hg38_chr21_chrM \
        -1 rep1_R1.trim.fq.gz -2 rep1_R2.trim.fq.gz 2> rep1.bowtie2.log \
  | samtools fixmate -m -u - - | samtools sort -o rep1.raw.bam
  • -X 2000: pairs up to 2 kb count as concordant. The default (500) makes di- and tri-nucleosome fragments “improper”.
  • fixmate -m adds the mate tags that samtools markdup needs later.
  • Reference: chr21 + chrM only, an honest shortcut (see notes).

Five filters, five reasons

  • Keep a pair only if both mates pass: unique (MAPQ ≥ 30), properly paired, not chrM, not a duplicate.
  • Blacklisted regions (Amemiya et al. 2019) are removed from the insertion sites and from the peaks.

Real data: reads through the pipeline

  • GM12878 replicate 1: 6.1 M read pairs in, 0.25 M usable fragments on chr21 out.
  • Biggest losses: chrM (91% of our pairs; 14% of the whole library), MAPQ (43% of the chr21 pairs) and duplicates (20%).

Tn5 cuts the two strands 9 bp apart

  • The Tn5 dimer joins adapters to the two strands 9 bp apart. Gap filling copies those 9 bp, so both fragments carry them.
  • The insertion “point” is the centre of the 9-bp duplication: +4 from a + read’s start, −5 from a − read’s end (BED coordinates).

From a read pair to two insertion sites

  • Every properly paired fragment gives two insertion sites, one at each end.
  • In BED: + read start + 4, − read end − 5. Tools: awk on a BEDPE file, or alignmentSieve --ATACshift (deepTools).

Fragments or insertion sites?

  • Fragment coverage counts the DNA between two cuts: smooth, but fragments that span a nucleosome fill it in.
  • Insertion sites count only where Tn5 cut: sharper, closer to “accessibility” in the strict sense.
  • Peaks, signal tracks and counts can use either. Be explicit about which.

Real data: insertions vs fragment coverage

  • GM12878 replicate 1 at the SOD1 promoter (chr21). Same reads, two tracks, both CPM.
  • Insertions concentrate at the open sites; fragment coverage is broader and also covers the flanking nucleosomes.

Signal tracks for the browser

# insertion sites (one line per cut), sorted, as bedGraph -> bigWig, CPM-scaled
sort -k1,1 -k2,2n rep1.ins.bed > rep1.ins.sorted.bed
n=$(wc -l < rep1.ins.sorted.bed)
bedtools genomecov -i rep1.ins.sorted.bed -g chrom.sizes -bg -scale $(echo "1000000 / $n" | bc -l) \
  > rep1.ins.cpm.bedGraph
bedGraphToBigWig rep1.ins.cpm.bedGraph chrom.sizes rep1.ins.cpm.bw

# or from the BAM with deepTools: fragment coverage, CPM
bamCoverage -b rep1.dedup.bam -o rep1.frag.cpm.bw --extendReads --normalizeUsing CPM -bs 10
  • CPM (counts per million) makes samples of different depth comparable on screen. It is a display normalisation, not the one for differential tests.

What a peak caller does

  • Pile up the reads (or insertion windows) along the genome.
  • At each position compare the pileup k with the expected count \lambda under background: p = P(X \ge k), X \sim \text{Poisson}(\lambda).
  • A peak is a run of positions below the cutoff; its summit is the highest point.

The local λ: background is not uniform

  • \lambda_\text{BG} = total reads × window / genome size. But open domains, copy-number gains and mappability make background vary.
  • With a control, MACS2/3 use \lambda_\text{local} = \max(\lambda_\text{BG}, \lambda_d, \lambda_\text{1k}, \lambda_\text{10k}), the windows measured in the control: the largest estimate, the conservative choice. (The 2008 paper used 1, 5 and 10 kb.)
  • Without a control (ATAC-seq), MACS3 uses \lambda_\text{BG} and the sample’s own 10-kb window.

From counts to p-values and q-values

  • The same 25 reads are extremely surprising against \lambda = 3 and much less so against \lambda = 8.
  • Millions of positions are tested, so MACS converts p to q-values (Benjamini–Hochberg FDR). -q 0.01: expect about 1% of called peaks to be false.

Two ways to run MACS3 on ATAC-seq

  • A. -f BAMPE: the pileup is the real fragments, no model, no shift. Simple; nucleosome-spanning fragments widen the peaks.
  • B. Insertion sites as BED, --nomodel --shift -75 --extsize 150: every cut becomes a 150-bp window centred on it. Used by ENCODE and Corces et al. 2018.

MACS3 in practice

# A: fragments
macs3 callpeak -t rep1.dedup.bam -f BAMPE -g 4.0e7 --keep-dup all -q 0.01 -n rep1_frag
# B: insertion sites
macs3 callpeak -t rep1.ins.bed -f BED --nomodel --shift -75 --extsize 150 \
               -g 4.0e7 --keep-dup all -q 0.01 -n rep1_cuts
  • -g: effective genome size, sets λBG (hs ≈ 2.7e9; here chr21 only, 4.0e7).
  • -q / -p: the cutoff; a lenient -p 0.01 when IDR chooses the final set.
  • --keep-dup all: duplicates were already removed. --call-summits: several summits per broad peak.

Real data: how many peaks?

  • Replicate 1, chr21, q < 0.01: 685 peaks with fragments (BAMPE), 1262 with insertion sites. ENCODE’s IDR set has 1784.
  • The number of peaks depends smoothly on the cutoff: there is no natural threshold. Weak peaks are a continuum, not a separate class.

Replicates: overlap vs rank consistency

  • Naive: call peaks in each replicate, keep those found in both. The answer depends on the cutoff, and a lax cutoff lets noise in.
  • IDR (Li et al. 2011) uses the ranks: real peaks rank similarly in both replicates, noise does not. It finds where the agreement breaks down.

Pseudoreplicates and ENCODE’s peak sets

  • Pool the replicates, shuffle the reads, split in two: pseudoreplicates differ only by sampling.
  • If true replicates agree much less than pseudoreplicates (ratio > 2), the replicates differ in biology or quality, not just depth.

Real data: do the replicates agree?

  • Left: −log10 p of matched peaks in replicate 1 vs 2. Right: of the top N peaks of replicate 1, the fraction also found in replicate 2.
  • The top 750 peaks: 99% found in replicate 2. Agreement stays ≥ 90% up to about 1450 peaks, then falls (82% for all 1739).

Real data: our peaks and ENCODE’s

  • 74% of our 1262 replicate-1 peaks are in ENCODE’s set; 89% of ENCODE’s 1784 chr21 peaks are in ours.
  • Left: 1680 read pairs but only 7 with MAPQ ≥ 30 (sequence present twice). We drop them; ENCODE keeps multi-mappers.

A consensus peak set across samples

  • To count reads per peak in many samples (Differential accessibility), every sample needs the same regions.
  • Merge (bedtools merge): simple, but overlaps chain into wide regions of very different widths.
  • Fixed width: summit ± 250 bp, overlaps resolved by significance. Every region is 500 bp, centred on a summit.

Iterative overlap removal

  • Sort the 500-bp peaks by significance; keep the best; drop the peaks that overlap it; repeat with the next best that is left.
  • Across samples, first make the scores comparable (e.g. −log10 p divided by the sample’s total, “score per million”), then run the same procedure on all peaks together.

FRiP: fraction of reads in peaks

  • FRiP = insertions (or reads) in peaks / all. A signal-to-noise measure: how much of the library is in accessible sites?
  • Ours: 0.57 (replicate 1) and 0.48 (replicate 2), insertions in own q < 0.01 peaks. ENCODE standard for ATAC-seq: > 0.3, > 0.2 acceptable.

Where are the peaks?

  • Fraction of peaks within 1 kb of a protein-coding TSS, by peak strength (Genomic intervals).
  • Strongest 10% of consensus peaks: 70% at a promoter; the other deciles: 5–25%. Overall 17% (ours) and 26% (ENCODE).
  • Most peaks are distal: candidate enhancers and insulators.

Pitfalls

pitfall what happens fix
chrM left in 8 peaks on the 16.6-kb chrM; 91% of the reads; fewer real peaks drop chrM reads
no blacklist peaks in satellite repeats, also in “differential” lists remove blacklisted peaks and insertions
wrong -g λBG wrong by orders of magnitude effective size of what you aligned to
--keep-dup 1 on insertions independent cuts at the same base collapsed --keep-dup all after deduplication
too lax a cutoff many peaks, low reproducibility, inflated FRiP IDR or rank consistency to choose
−strand read not shifted from its end insertions off by a read length shift BED end, not start

Summary

step key idea
trim Nextera adapter CTGTCTCTTATACACATCT; short fragments read through
align -X 2000 so nucleosome-spanning pairs stay proper
filter MAPQ, proper pairs, chrM, duplicates (same both ends), blacklist
shift insertion = centre of the 9-bp duplication: + start +4, − end −5 (BED)
represent fragments (smooth) or insertion sites (where Tn5 cut)
peaks Poisson test against \lambda_\text{local} = the largest background estimate (with no control: \max(\lambda_\text{BG}, \lambda_\text{10k})); q-values by BH
MACS3 for ATAC BAMPE, or insertions with --nomodel --shift -75 --extsize 150
replicates rank consistency (IDR) beats naive overlap; pseudoreplicates for depth
consensus fixed 500-bp summit peaks, iterative overlap removal
QC FRiP > 0.3; promoter fraction; agreement with a reference set

Key papers (optional further reading)

Not required reading and not examined. For those who want the primary literature.