# 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`) with native alignment (`--reference` → per-batch CRAM, no merge step) → 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`) git-installed by the workflow conda envs (pinned to the submodule commit in `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`, commit it there and push, then bump the `@` after the package URL in `workflow/envs/torch_*.yaml` and recommit - `.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): ```bash cd workflow snakemake -n --cores # stage A only until stage_b_* is configured ``` Runner system (NVIDIA GPU, host dorado, aws cli): ```bash cd workflow snakemake --cores --resources gpu= --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: ```bash snakemake --cores --resources gpu= --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 dcs`ed. 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.