feat: opt-in base_quality feature channel from dorado per-base Q-scores
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- machine-learning
Direzione di ricerca
Read src/leech/constants.py, preparation/reader.py, and io/bam_reader.py, then inspect the existing feature-channel and backend-selection paths and the prototype on feat/478-base-quality. First review audit #157, since training is gated on finding per-position, speed-adjusted signal above the control region. Done means the stated acceptance criteria and tests pass, with the paired-seed run-held-out ablation documented; the issue says not to train before the audit gate is met.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Add the basecaller's per-base quality (dorado Q-score, BAM QUAL) as an opt-in feature channel base_quality. leech currently reads no base qualities anywhere; the only basecall-error-adjacent signals are the per-chunk junction_indel / junction_mapped metadata. The channel gives the model the basecaller's own per-base uncertainty, which is defined under both --anchor reference and --anchor basecall and needs no alignment walk.
Status and gate (2026-11-29)
A prototype implementing everything below except predict wiring exists on branch feat/478-base-quality (176 tests pass). Do not train on it yet. The pre-registered gate is an offline audit, rnabioco/2026-aa-trna-models#157 (a related offline question, the CCA-junction error signature, is #158), because the first measurement is negative:
- Qualities are present on the real ncAA-trio BAMs (
results/noncognate-22way/data_noncognate/filtered/MetRS_{met,aha,hpg}_b5/noncognate.bam, 3000/3000 reads), mean Q about 13.5 (RNA004). - Per-read mean Q over the K=6/fe=10 window (ref bases motif+8 .. +18) does not separate Met/AHA/HPG: pairwise AUC 0.491 / 0.497 / 0.506 (n=3000 per arm), identical to the AUC of a control region 40..10 bases upstream (0.491 / 0.494 / 0.504). Window Q is lower than the body (10.8 vs 15.5), but equally so in every arm.
- So at read-mean resolution the channel carries no adduct signal on the project's best-validated benchmark, and its dominant variance is run/speed. Its main risk in this project is being a nuisance channel (the bottleneck there is confounds, not capacity).
Proceed to the training ablation only if the audit finds per-position, speed-adjusted signal above the control region.
Design
base_quality is a new entry in the existing feature-channel system (#358), not a new array:
- Add
"base_quality"toKNOWN_FEATURE_CHANNELS(src/leech/constants.py). Not inDEFAULT_FEATURE_CHANNELS/ALL_FEATURE_CHANNELSdefaults: opt in via--feature-channels, so existing recipes keep their input shape. - Per-base values are indexed exactly like the dwell and level channels, i.e. one per base of
seq_to_sig_map. With--anchor basecallthat is one per base ofaln.query_sequence(pysam returnsquery_qualitiesin the same orientation asquery_sequence, so the pairing holds by construction; asserted by a test, not assumed). With--anchor reference(the default) the map is indexed by the reference slice, so the query qualities are carried across the CIGAR with the samemake_ref_to_query_mappinginterpolationcompute_ref_to_signaluses: a reference base that was deleted in the read gets the interpolated quality of its neighbours, and there is no second CIGAR walk. - Computed in
preparation/reader.pynext tocompute_signal_featuresand folded into thesignal_featuresdict, somerge_feature_channelsorders and windows it with no new plumbing. ReadInfo(io/bam_reader.py) carries the qualities (asuint8, not a Python list) to the workers.- Transform is a flag,
--quality-transform {raw,perr}(defaultraw), recorded inprepare_config.jsonand the model config sopredictreproduces it. - Missing qualities (
QUAL = *, hard-clipped regions):data prepareraises when the channel is requested and a read has none, naming the read count. No silent zero-fill.
Backend
Python-only extraction, same precedent as --mask-seq-side. _select_prepare_backend and the predict --backend auto path must route to Python when base_quality is requested; --backend rust raises. A Rust port is a non-goal here and gated on the result below.
Acceptance criteria
leech data prepare --feature-channels <default>,base_qualityproduces a corpus whose feature tensor has one extra row at the position given by the recorded list;prepare_config.jsonrecords the channel and transform.leech model trainandleech predicton that corpus build a model with the extra input channel and reproduce the same transform at predict time. Old corpora and checkpoints load unchanged.- A corpus/checkpoint channel-count mismatch raises, naming both counts.
--backend rustwith the channel raises;--backend autofalls back to Python with a warning.- Reads without qualities raise at prepare time when the channel is requested.
--standardize-featureshandles the channel;perrclips Q to [0, 60].- Evaluation protocol documented in the PR: paired seeds (6, per the CRF-port finding that 3 is too few) with and without the channel, on the run-held-out split, reporting cross-run vs within-run metrics. A gain that appears only within-run is a confound, not a result.
Expected tests
tests/test_data_prep.py::TestFeatureChannelOrderextended:base_qualityposition and name validation (validate_feature_channelsaccepts it, still rejects typos).tests/test_base_quality_feature.py(new): quality-to-base pairing on a forward and a reverse-strand fixture (value at base i belongs to base i); soft-clip and window-edge handling; missing-quality raise; transform round trip throughprepare_config.json; predict reproduces training transform.- Backend-selection tests: rust raises, auto falls back.
Non-goals
- No Rust implementation, and no change to
tests/test_backend_parity.pyfixtures. - No binary mismatch / insertion / deletion channels (possible follow-up if quality helps).
- No change to default channel lists or to any existing checkpoint's input.
- No use of read-level mean Q or MAPQ.
- No relabeling or filtering of reads by quality (that is
label_quality, #473).
Risks to report in the PR
- Leakage path: acyl modification may depress basecaller confidence near the 3' end; the model could learn basecaller-version behaviour rather than charging state. Run-held-out split is the test.
- Dorado per-base Q is a model-confidence output, not calibrated across model versions or flowcells.
- Lingua principale
- Python
- Stelle
- 0
- Fork
- 0
- Merge medio
- 11h 17m
- PR unite (30g)
- 23
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rnabioco/leech
-
load_model_from_checkpoint drops num_out/signal_in_channels for models whose __init__ takes **kwargsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 Più di una settimana Idoneità per principianti 18/100
I maintainer di solito rispondono entro 1 giorno
-
model train-many: one launcher that owns an allocation and trains a queue of configs across its GPUsAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rnabioco/leech
Issue simili
-
docs: powerpc not supportedAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
microsoft/TokenEconomizer#360 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
reasons-gate
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
benthomasson/reasons-service#190 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno