SEPIA  ·  ← roadmap  ·  all docs

Rebuild from raw — the clean-slate pipeline

Rebuild from raw — the clean-slate pipeline

Decision (2026-07-23). Given the confirmed QC failures in the existing pipeline — the hg38/hg19 build mismatch (A2), the Denisova 3 contig-naming bug (A1), haploid autosomal calling (A3), the projection collapse, and the fact that the full sorted BAMs are no longer on the cluster (only wrong-region filtered_*.bam + already-called VCFs remain) — we do not trust Lily's derived data. We rebuild the pipeline from the raw, public, re-downloaded BAMs, with a QC gate at every stage. This is the scientifically defensible path: every number in the paper will trace to raw data through a re-runnable, verified pipeline.

This plan supersedes the "patch the panel from the existing VCFs" quick route in b2a_runbook.md. That VCF-only route stays available as an optional 1-hour preview to sanity-check the corrected panel while the re-download runs — but it is not the deliverable.

How this maps to the roadmap. This is Phases 0–4 of plan.md executed from raw, in order, so the QC items (Q1–Q9) are gates rather than afterthoughts, and the bug fixes (A1/A2/A3 + the projection fix) fall out of doing it right the first time.


What we keep vs. re-derive

Keep (re-fetch from source of truth) Re-derive (discard the existing copy)
The raw public archaic BAMs (re-downloaded + checksummed) Lily's sorted/filtered BAMs, ancient_pigmentation.vcf.gz, ancient_sgdp_wg.vcf.gz
The SNP panel definition (rsIDs + source), re-pulled and put on ONE build The committed snps.txt / snps.chr.bed coordinates (hg38-on-hg19)
The SGDP modern genotypes (re-fetch or re-verify sgdp.wg) pca/* eigenvec/eigenval/sscore and every downstream figure
Tool/reference provenance any hand-typed number in the thesis prose

Reuse vs. rerun — the decision, per genome

Principle. For each genome, start from the highest-quality product that already exists, and rerun only what is needed to (a) fix the confirmed bugs (build A2, contig-naming A1, haploid A3, projection collapse) and (b) harmonize the independently-produced sources onto one comparable footing. Concretely: for high-coverage genomes the authors already did careful, damage-aware genotype calling (snpAD) that we cannot improve on at 30–52× — so we reuse their published VCFs and do not re-call. For low-coverage genomes hard calls neither exist nor are appropriate — so we re-acquire the reads and compute genotype likelihoods ourselves (ANGSD). (The per-paper QC/pipeline each of these calls came from is documented in papers/PIPELINE_QC_BY_PAPER.md.)

Finalized sample subset (2026-07-23) — full justification in papers/SAMPLE_INCLUSION.md. The goal is to maximize reliably-genotyped pigmentation SNPs of interest, not genome count. Tier 1 (core): the 5 high-coverage genomes (Altai/Denisova 5, Vindija 33.19, Denisova 3, Chagyrskaya 8, Denisova 25) + SGDP — they cover all 222 panel SNPs incl. the transition loci reliably. Tier 2 (extended, with GL uncertainty): Les Cottés, Denisova 11 (hybrid), Goyet, and Mezmaiskaya 1 (its snpAD VCF). Excluded, with reasons: El Sidrón (exome-only), Vindija 87 (redundant = Vi 33.19 individual), Mezmaiskaya 2 (1.7×, no VCF), Spy 94a (1.0× + ~4% contamination), Hohlenstein-Stadel & Scladina (ultra-low ~0.02–0.05× → only ~4–11 panel SNPs, contamination-dominated). So targeted read re-acquisition is needed for just 3 genomes (Les Cottés, Denisova 11, Goyet).

Genome Take (source of truth) Re-call genotypes? What we rerun Why
Altai / Denisova 5, Vindija 33.19, Denisova 3 published snpAD genotype VCF (2017 release, hg19) + its mappability mask No build/naming lint (Q2), apply + intersect masks to a common set, allele/REF harmonization (Q4), subset to panels, PCA 52×/30× damage-aware calls; re-calling adds nothing and loses the authors' QC
Chagyrskaya 8 published snpAD VCF (.noRB) + FilterBed mask No as above (+ apply its own FilterBed before intersecting) 27–28×, own release/mask
Denisova 25 ⚠ published VCF (L35 MQ25 B30 map35_100) + FilterBed No (provisional) as above; flag preprint 24×, but preprint — mark provisional
Vindija 87 the Vindija 33.19 VCF (same individual) No none extra — use Vi 33.19 Vi 87 is the same person; the 1.3× library adds nothing for genotypes
Denisova 11 "Denny" BAM (ENA PRJEB24663) No hard call → ANGSD GLs re-acquire reads, reheader, mapDamage, max-depth cap, ANGSD GLs at panels, het-vs-depth, PCAngsd ~2.6× hybrid; too low for hard calls; no VCF exists
Goyet, Les Cottés, Spy, Mez 2 BAM (ENA, Hajdinjak 2018) No hard call → ANGSD GLs full low-cov path (as Denisova 11) 1–2.7×; BAM-only
Mezmaiskaya 1 low-cov snpAD VCF (…/Vindija/VCF/Mez1/) or BAM reuse VCF (low-cov, with care) or GLs apply FilterBed + lint; or GL path ~1.9×; a snpAD VCF does exist (correction)
Hohlenstein-Stadel, Scladina BAM (ENA PRJEB29475) No hard call → ANGSD GLs full low-cov path; expect very few usable panel sites ultra-low ~0.02–0.05× early Neanderthals
El Sidrón 1253 — Exclude (optional) check its exome VCF only for panel SNPs that fall in coding regions — most pigmentation SNPs are regulatory, so expect ~none exome-capture only; no shotgun genome
SGDP (15 moderns) existing pca/modern/sgdp.wg (hg19, 9.2 M SNPs) reuse build/allele lint (Q2/Q4); subset to panels; positive-control PCA (Q3) already on hg19 with the pigmentation SNPs by rsID; no re-acquisition
Pigmentation panel rsIDs (from skin_pigmentation.tsv / GWAS Catalog) — lift to hg19 by rsID, keep both builds; tracer lint (Q2) fixes the root bug A2

Two method notes from the per-paper QC extraction (papers/PIPELINE_QC_BY_PAPER.md):

Net rerun surface (much smaller than "redo everything"):


Genome-build decision (read first)

The raw data is hg19, and — confirmed from the thesis §2.3 — the archaic data is distributed as BAM files already mapped to GRCh37/hg19 (there is no FASTQ; Lily inherited the data producers' alignments and did no re-mapping). This makes the choice lopsided:

Default: rebuild on hg19 (lift panels to match). The BAM-only reality makes this the practical as well as the cheap choice.


Stages (each ends with a QC gate that must pass before the next)

Stage 0 — Provenance & environment · gate: every input traced (Q1, Q10a)

Stage 1 — Re-acquire the source data · gate: checksums match, headers sane

Data-form choice per sample (Tina's point — "or phased VCFs?"). Provenance search result (verified against the MPI-EVA servers, 2026-07-23): the high-coverage archaics are published by Max Planck as damage-aware diploid genotype VCFs (called with snpAD, an aDNA-damage-aware genotyper) — not statistically phased haplotype VCFs (if we ever need phased haplotypes, phasing is a separate downstream step we run ourselves). For the high-coverage genomes these published, carefully-called VCFs are a better source of truth than re-calling from reads. So:

Two read-acquisition modes for the BAM route — pick per the compute you want to spend (see §Compute):

Stage 2 — Raw-data QC · gate: authentic, correctly labelled, damage-characterized (Q6, Q7, Q8)

Stage 3 — One build + a verified, harmonized panel · gate: build lint + allele check (Q2, Q4)

Stage 4 — Genotype likelihoods (not hard calls) · gate: GLs sane, damage-aware

Design change (2026-07-23, Tina): the samples are mostly low coverage — 10 of the 14 are under ~3.2× at the panel and several are <1× (exact table in coverage_current.tsv). Hard-calling with VCF tools is the wrong tool here: forcing a definite genotype from 1–2 reads either invents a call or drops the site, and it bakes in aDNA damage as false alleles. So the primary engine is genotype likelihoods via ANGSD, which keep the per-genotype probability and propagate uncertainty; hard calls are reserved for the few high-coverage genomes and for specific per-SNP reporting (e.g. does a high-coverage archaic carry an MC1R red-hair allele).

Stage 5 — Modern reference · gate: SGDP verified or rebuilt

Stage 6 — PCA + projection (GL-based) · gate: positive control + non-degeneracy (Q3, Q5)

Stage 7 — Science on the clean base · (B3, B7)

Stage 8 — Reproducibility · (Q10)


Compute resources

The dominant cost is Stage 1 (re-acquisition); everything else is modest. You said compute isn't a constraint, so any of these is fine — the table is to set expectations and to choose targeted vs full download.

Stage Job shape Cores / Mem Walltime Disk Notes
0 provenance/env login + tiny 1 / 2 GB minutes — conda solve needs internet (login node)
1a targeted re-acquire --array=1-15 2 / 8 GB each ~1–4 h total ~10–50 GB streams only SNP-overlapping reads; recommended
1b full genomes --array=1-15 4 / 16 GB each many hours–~1 day ~0.5–1 TB whole BAMs; bandwidth-bound from MPI-EVA/ENA
2 QC (mapDamage/sex/contam) --array=1-15 4 / 16 GB each ~15 min–1 h each small mapDamage is the heaviest here
3 panel/build lint single 1 / 4 GB minutes tiny 222-site scale
4 re-call genotypes --array by sample or chr 4–8 / 16–32 GB ~1–3 h ~10 GB region-restricted mpileup
5 SGDP verify/rebuild single (verify) / array (rebuild) 8 / 32 GB minutes (verify) reuse rebuild only if provenance fails
6 PCA/projection single 4 / 16 GB minutes tiny plink2
7 score/functional single 2 / 8 GB minutes tiny
8 DAG/CI dev — — — one-time setup

Bottom line: with targeted re-acquisition (1a) the whole rebuild is roughly a half-day of mostly-download wall-clock on a single standard node + a couple of small array jobs — no GPU, no large-memory node, well within Turbo's 8.7 TB free / scratch's 300 TB. Full-genome download (1b) turns it into a ~1-day job. Recommend 1a unless you specifically need whole genomes.


What I need from you

  1. Confirm the two decisions: rebuild on hg19 (default) vs hg38; and targeted (1a) vs full (1b) re-acquisition.
  2. The 9 missing acquisition sources (Stage 0) — I'll hunt the cluster for the other acquisition scripts first; if they're not there I'll pull standard accessions from the source papers for you to confirm.
  3. Keep the authenticated Great Lakes session open (as now) so I can run the SLURM jobs, or run them and paste back the QC summaries.
  4. Nothing else — no data from Lily/Yemko; the raw archives, the SGDP data, and the reference are all public/present.

Decision points recorded