Signal Processing¶
The escapepod package also exposes a few primitives from the
escapepod-signal crate: signal normalization, kmer level tables, and
signal-to-sequence map refinement (resquiggle).
Normalization¶
Both functions apply median-MAD normalization (median-centered, scaled by the MAD with the 1.4826 Gaussian factor, with a graceful fallback on constant signal). They differ only in input dtype:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Kmer level tables¶
KmerTable loads a tab-delimited kmer<TAB>level file (gzip supported) — the
expected normalized signal level for each kmer — and looks levels up per kmer or
expands them along a sequence:
1 2 3 4 5 | |
Refining a signal-to-sequence map¶
refine_signal_map refines a base-to-signal boundary assignment (a
"resquiggle") against a level model using banded dynamic programming, and
returns updated rescaling parameters.
The input signal must already be normalized (see above). expected_levels
is typically produced by KmerTable.extract_levels. seq_to_signal_map is the
current per-base signal boundary indices.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
The return value is (refined_seq_to_signal_map, scale, shift, drift). Apply
the recovered rescale to level-match the signal:
1 | |
Experimental
Resquiggle refinement is an evolving, lower-level API — the same one behind
the experimental resquiggle CLI command.
Signatures here may change.