Tom Kasper 820863a9c7 Complete E1-v2 workflow: stage A ladder + control + gate, stage B variants + baseline
- Snakefile: modules -> plain include: (single namespace; fixed cross-module
  helper resolution), rule all with stage-A/stage-B target sets driven by
  flat --config stage_b_arch/budget/stride switches.
- config/main.yaml: v2 run matrix (ladder 12-grid, control 1M cnn s4), store
  excludes (DCS spike-in, in-corpus escherichia trap reads), barcoding kit
  (SQK-RBK114-96 classified during dorado basecalls), removes v1 quota.
- baseline_pipeline: CUDA branch streams per-chunk dorado emit-sam through
  minimap2 (-N 10, tags preserved) and samtools view into per-batch BAMs,
  merged with samtools cat; ROCm/slorado fallback kept.
- ml_pipeline: label parquets -> signal stores (main / windows-ablation w4 /
  trap store) -> 12 ladder trainings + shuffled control -> custom_models test
  with the trap store (TP2) -> custom_models gate over the g11 runs; stage B
  adds windows ablation, holdout/core_clade(/bacillus_group) variants and the
  dorado-fast alignment baseline on the winner's identical test split.
- scripts: bam2annotation now emits source_run (barcoded -> barcodeNN from the
  dorado tags, dataset fallback); new label_qc.py (TP1 capture counts) and
  baseline_eval.py.
- custom_models submodule: bump to test_split.parquet export commit.
- README: two-stage run instructions (dev dry-run vs runner GPU).
2026-10-15 19:54:51 +01:00
2026-09-17 22:16:42 +01:00
2026-09-17 22:16:42 +01:00
2026-09-17 22:16:42 +01:00
2026-09-17 22:16:42 +01:00

eDNA_Stream_E01 — E1 (v2) squiggle-probe experiment

Scope

  • Establish whether squiggle-based taxonomy is feasible on the small computational budget that is available.
  • Design: planning/design_docs/preliminary_experiments/E1_v2_eleven_taxa_redesign.md (+ the dataset / torch-model spec docs).

Experiment (v2)

  • Fixed 11-taxa NO-MISS probe (species list in reference/species_list.yaml; genus labels with strain-exact reference assemblies in the panel) + the Escherichia false-positive trap (Paenibacillus / Aeromonas traps are deferred until read sources exist — unused_trap_species).
  • Stage A: pod5 download (1-in-12 chunk downsampling) → dorado basecall (HAC, barcodes classified via --kit-name SQK-RBK114-96) → minimap2 → labels parquet → signal store (trap reads excluded from training) → 12-point arch/param ladder ({cnn, linatt} × {1M, 5M, 20M} × stride {4, 8}) → shuffled-label control → per-run test evaluation with the trap store (custom_models test) → gate verdict (custom_models gate → ../data/ml_models/gate_verdict.json).
  • Stage B (after picking the Stage-A winner from the ladder report.json): windows ablation (store with --max-windows-per-read 4), robustness variants (barcode-level holdout_runs, core_clade 8-genera / optional bacillus_group restricted trainings) and the alignment baseline (dorado-fast + minimap2 + LCA) evaluated on the winner's identical test read set.
  • TP1 label QC (trap-capture counts) is always produced: ../data/ml_inputs/nomiss_hac_trap_capture_qc.json.

Dependencies

  • dorado >= 2.1 (host binary on PATH; conda envs only carry minimap2 + samtools)
  • aws CLI
  • conda/mamba (mamba recommended)
  • python env with: python 3.14, snakemake, python-dotenv
  • custom-models package: lives in a separate repo (git@git.tk-ai.eu:Tom/eDNA_Stream_E01_custom_models.git) included here as the custom_models git submodule; the workflow pip-installs it from that checkout (see workflow/envs/torch_*.yaml).
    • clone with: git clone --recurse-submodules ... (or git submodule update --init on an existing clone)
    • update to a newer version: git submodule update --remote custom_models, then commit the new pin
  • .env file in workflow/ with NCBI API key (copy from .env_example) — speeds up reference download only

Running

Development / dry-run (this box, no usable GPU):

cd workflow
snakemake -n --cores <cores>   # stage A only until stage_b_* is configured

Runner system (NVIDIA GPU, host dorado, aws cli):

cd workflow
snakemake --cores <cores> --resources gpu=<n_gpus> --use-conda \
    --config torch_env=../envs/torch_cuda.yaml

Stage A runs the ladder + control + tests + gate. Then pick the winner from ../data/ml_models/ladder/*/report.json (gate's gate_verdict.json picks the best run automatically) and run Stage B:

snakemake --cores <cores> --resources gpu=<n_gpus> --use-conda \
    --config torch_env=../envs/torch_cuda.yaml \
             stage_b_arch=cnn stage_b_budget=5000000 stage_b_stride=4 \
             windows_ablation=True holdout_runs=True core_clade=True

(Booleans need the True/False spelling; the values become part of the DAG.)

The ROCm branch (--config gpu_stack=rocm, slorado) is kept as a fallback; barcodes are not classified there, so labels fall back to the dataset name and the holdout variant would rely on a single source_run.

Conda envs

  • torch_cpu/torch_cuda — training/inference (probe trainings, store building, test/eval) with the custom_models package; switch via --config torch_env=...
  • minimap — minimap2 + samtools for the streaming label jobs (dorado stays on the host PATH)
  • bam2parquet — labels from BAM + TP1 QC + the baseline report (pandas/pyarrow/pysam/biopython)

Notes

  • Reads whose best alignment lands on the trap refs are excluded from the training store (--exclude-genus escherichia), and the DCS control spike-in is --exclude-ref dcsed. The in-corpus E. coli reads are the trap evidence (TP1) — counted in nomiss_hac_trap_capture_qc.json (they are stable even under stringent alignment).
  • Queues for hardware: basecall/label jobs carry resources gpu=1, so --resources gpu=N keeps at most N GPU jobs in flight (1 on a single-GPU workstation trains/labels sequentially).
  • The probe labels come from the HAC arm; the dorado-fast arm is the v2 alignment baseline and only feeds baseline_report.json in Stage B.
S
Description
No description provided
Readme
9.7 MiB
Languages
Python 100%