The paired ATAC-seq dataset
Four donors provide the comparison in this section. Each contributes a resting and a stimulated naive CD4 T-cell sample, so the analysis estimates a condition effect within donors. Eight sample profiles do not mean eight independent donors.
Trace a sample from GEO to its reads
Section titled “Trace a sample from GEO to its reads”The source is GSE118189,
from Calderon and colleagues.
GEO calls the selected cell type Naive_Teffs and records donor and treatment in
each sample title. The stimulation protocol uses CD3/CD28 antibody beads and
IL-2 for 24 hours. Resting cells provide the comparator; this design does not
separate the effects of culture, beads, and cytokine exposure.
The selection retains complete pairs from donors 1001 through 1004 before any differential result. Other cell types and the unmatched stimulated sample from donor 1011 do not enter the cohort. The companion metadata joins GEO accessions to ENA runs through their SRA experiment identifiers. Both records from donor 1003 describe additional NextSeq reads merged with the original library. That merge creates neither a new donor nor an independent biological replicate.
Keep the archived and fresh matrices separate
Section titled “Keep the archived and fresh matrices separate”This page uses the deposited matrix to check provenance. Its regions came from the original study’s consensus procedure across a wider collection of samples. The original methods describe fragment counts and a limma-voom analysis with donor and TSS enrichment terms. The later lessons use a fresh nf-core/atacseq consensus and a separately specified DESeq2 model. Differences between the two matrices can arise from region definitions as well as alignment and filtering.
The preparation preserves the complete source archive hash and extracts all
regions for the eight selected columns. It does not select regions according
to treatment effects. The archive SHA-256 is
583b24da0ef1d29ca6c221cba1c3fe3ded35ca780428176de8962f91315f2d48.
That hash identifies the downloaded archive; it is not an independent checksum
provided by GEO.
The companion repository
requires access. It preserves source metadata, the extraction script, the
selected archive columns, and checksums. The examples run in its
chromatin:recovery_2026_11_01 container without network access. The public source remains
available from GEO regardless of companion access.
Check the sample order and donor design
Section titled “Check the sample order and donor design”Count columns must follow metadata order. A correct set of names with an incorrect order still assigns counts to the wrong donor or treatment. Both examples explicitly align columns, require one sample per donor and condition, and construct the same five-column design matrix. They also verify that the archive contains nonnegative integers and unique autosomal intervals.
The original experiment comes from Calderon and colleagues, deposited as GSE118189, SRP156496, and PRJNA484801. This example summarizes the deposited GEO count matrix. The source notice distinguishes this matrix from the fresh outputs used by the later lessons.
The authors’ original data resource links GSE118189 and invites research use with citation. The archive source notice records that release, NCBI’s molecular data policy, and the exact matrix identity. This lesson preserves all regions and selects eight sample columns before it derives donor summaries.
library(ggplot2)library(jsonlite)
metadata <- read.delim("/fixtures/metadata.tsv", colClasses = "character")metadata <- metadata[order(metadata$donor, metadata$condition), ]stopifnot(!anyDuplicated(metadata$sample_id))stopifnot(!anyDuplicated(metadata$geo_accession))stopifnot(!anyDuplicated(metadata$run_accession))metadata$donor <- factor(metadata$donor)metadata$condition <- factor(metadata$condition, levels = c("resting", "stimulated"))stopifnot(all(table(metadata$donor, metadata$condition) == 1L))archive <- read.delim(gzfile("/fixtures/archived_counts.tsv.gz"), check.names = FALSE)stopifnot(setequal(names(archive)[-1], metadata$geo_title))counts <- as.matrix(archive[, metadata$geo_title])stopifnot(all(is.finite(counts)), all(counts >= 0))stopifnot(all(counts == floor(counts)))stopifnot(!anyDuplicated(archive$region_id))regions <- do.call(rbind, strsplit(archive$region_id, "_", fixed = TRUE))starts <- as.integer(regions[, 2])ends <- as.integer(regions[, 3])stopifnot(all(regions[, 1] %in% paste0("chr", 1:22)))stopifnot(all(starts >= 0L), all(ends > starts))design <- model.matrix(~donor + condition, metadata)design_rank <- qr(design)$rankstopifnot(design_rank == ncol(design))metadata$assigned_counts <- colSums(counts)cat(sprintf("Samples: %d; donors: %d; archived regions: %d\n", nrow(metadata), nlevels(metadata$donor), nrow(counts)))cat(sprintf("Design rank: %d; residual degrees of freedom: %d\n", design_rank, nrow(design) - design_rank))for (i in seq_len(nrow(metadata))) { cat(sprintf("%s %s %s %s %d\n", metadata$donor[i], metadata$condition[i], metadata$geo_accession[i], metadata$run_accession[i], metadata$assigned_counts[i]))}dir.create("outputs", showWarnings = FALSE)write.table(metadata, "outputs/archive_summary_r.tsv", sep = "\t", quote = FALSE, row.names = FALSE)write.table(design, "outputs/design_r.tsv", sep = "\t", quote = FALSE, row.names = FALSE)metrics <- list(samples = nrow(metadata), donors = nlevels(metadata$donor), regions = nrow(counts), design_rank = design_rank, total = sum(counts), zero_fraction = mean(counts == 0L))write_json(metrics, "outputs/metrics_r.json", auto_unbox = TRUE, digits = 16)figure <- ggplot(metadata, aes(condition, assigned_counts / 1e6, group = donor, color = donor)) + geom_line(linewidth = 0.7) + geom_point(size = 3) + theme_bw(base_size = 12) + labs(x = "Condition", y = "Archived assigned counts, millions", color = "Donor")ggsave("outputs/archive_totals_r.png", figure, width = 7, height = 4.3, dpi = 160)Samples: 8; donors: 4; archived regions: 829942Design rank: 5; residual degrees of freedom: 31001 resting GSM3320253 SRR7650753 82699221001 stimulated GSM3320254 SRR7650754 148544891002 resting GSM3320296 SRR7650796 108027221002 stimulated GSM3320297 SRR7650797 82105111003 resting GSM3320336 SRR7650836 66791391003 stimulated GSM3320337 SRR7650837 79516531004 resting GSM3320370 SRR7650870 127528271004 stimulated GSM3320371 SRR7650871 13028718
import jsonfrom pathlib import Path
import matplotlib.pyplot as pltimport numpy as npimport pandas as pd
metadata = pd.read_csv("/fixtures/metadata.tsv", sep="\t", dtype=str)metadata = metadata.sort_values(["donor", "condition"]).reset_index(drop=True)for column in ["sample_id", "geo_accession", "run_accession"]: assert metadata[column].is_uniqueassert pd.crosstab(metadata["donor"], metadata["condition"]).eq(1).all().all()archive = pd.read_csv("/fixtures/archived_counts.tsv.gz", sep="\t")assert set(archive.columns[1:]) == set(metadata["geo_title"])counts = archive.loc[:, metadata["geo_title"]].to_numpy()assert np.isfinite(counts).all() and (counts >= 0).all()assert (counts == np.floor(counts)).all()assert archive["region_id"].is_uniqueregions = archive["region_id"].str.split("_", expand=True)starts = regions[1].astype(int)ends = regions[2].astype(int)assert regions[0].isin([f"chr{i}" for i in range(1, 23)]).all()assert (starts >= 0).all() and (ends > starts).all()donors = sorted(metadata["donor"].unique())design = np.column_stack([ np.ones(len(metadata)), *[metadata["donor"].eq(donor).to_numpy() for donor in donors[1:]], metadata["condition"].eq("stimulated").to_numpy(),])design_rank = int(np.linalg.matrix_rank(design))assert design_rank == design.shape[1]metadata["assigned_counts"] = counts.sum(axis=0)print(f"Samples: {len(metadata)}; donors: {len(donors)}; " f"archived regions: {len(counts)}")print(f"Design rank: {design_rank}; residual degrees of freedom: " f"{len(design) - design_rank}")for row in metadata.itertuples(): print(f"{row.donor} {row.condition} {row.geo_accession} " f"{row.run_accession} {row.assigned_counts}")output = Path("outputs")output.mkdir(exist_ok=True)metadata.to_csv(output / "archive_summary_python.tsv", sep="\t", index=False)pd.DataFrame(design).to_csv(output / "design_python.tsv", sep="\t", index=False)r_summary = pd.read_csv(output / "archive_summary_r.tsv", sep="\t", dtype={"donor": str, "merged_nextseq": str})pd.testing.assert_frame_equal(metadata, r_summary, check_dtype=False)r_design = pd.read_csv(output / "design_r.tsv", sep="\t").to_numpy()np.testing.assert_array_equal(design, r_design)metrics = {"samples": len(metadata), "donors": len(donors), "regions": len(counts), "design_rank": design_rank, "total": int(counts.sum()), "zero_fraction": float((counts == 0).mean())}(output / "metrics_python.json").write_text(json.dumps(metrics))figure, axis = plt.subplots(figsize=(7, 4.3))for donor in donors: rows = metadata.loc[metadata["donor"].eq(donor)] axis.plot(rows["condition"], rows["assigned_counts"] / 1e6, marker="o", label=donor)axis.set(xlabel="Condition", ylabel="Archived assigned counts, millions")axis.legend(title="Donor")figure.tight_layout()figure.savefig(output / "archive_totals_python.png", dpi=160)plt.close(figure)Samples: 8; donors: 4; archived regions: 829942Design rank: 5; residual degrees of freedom: 31001 resting GSM3320253 SRR7650753 82699221001 stimulated GSM3320254 SRR7650754 148544891002 resting GSM3320296 SRR7650796 108027221002 stimulated GSM3320297 SRR7650797 82105111003 resting GSM3320336 SRR7650836 66791391003 stimulated GSM3320337 SRR7650837 79516531004 resting GSM3320370 SRR7650870 127528271004 stimulated GSM3320371 SRR7650871 13028718
Interpret the count totals
Section titled “Interpret the count totals”Each line connects one donor’s two sample profiles. Its slope describes counts assigned to the deposited regions, not a change in absolute genome-wide accessibility. Sequencing depth, filtering, and the original region collection all affect the total. These totals cannot supply a mitochondrial fraction, duplicate rate, or fraction of unique fragments in peaks.
The rank check establishes that the donor and condition coefficients are estimable. The primary workflow supplies fresh reports for the quality review before differential inference.
Further reading
Section titled “Further reading”The GSE118189 sample metadata identifies the donors and stimulation conditions represented here. These records connect the fixture labels to their source experiment.
The nf-core/atacseq 2.1.2 usage guide describes the processing stages that produced the retained outputs. It gives context for the files used by the downstream lessons.