Expand description
salmon-model: statistical models used during quantification.
§What these models are for
Sequencing is not a uniform sampler. A fragment’s chance of being observed depends on how long it is, what sequence sits at its ends, how GC-rich it is, and where in the transcript it starts. Left uncorrected, those effects are read as differences in abundance, which they are not. Each model here measures one such effect from the data itself and hands the quantifier a correction factor:
fld— the fragment-length distribution, and automatic library-type detection (libdetect);seqbias— sequence-specific bias, from primer/ligation preferences at fragment ends;gcbias— fragment GC bias, largely from PCR amplification efficiency;posbias— positional bias along the transcript body, e.g. 3’ pileup from degraded RNA;bias— combines them into a corrected effective length per transcript.
Every model is observed vs expected: count what was actually seen, count
what would have been seen under no bias, and take the ratio. That framing is
why the dump files in dumps always come in obs/exp pairs.
Re-exports§
pub use bias::build_expected_pos;pub use bias::corrected_effective_length_full;pub use bias::positional_factor;pub use bias::positional_factor_into;pub use bias::BiasInputs;pub use fld::FragLengthSource;pub use fld::ambig_frag_log_prob;pub use fld::smoothed_effective_length;pub use fld::DiscreteFld;pub use fld::FragmentLengthDistribution;pub use gcbias::build_expected_gc;pub use gcbias::gc_corrected_effective_length;pub use gcbias::gc_desc;pub use gcbias::gc_prefix;pub use gcbias::gc_ratio;pub use gcbias::GcFragModel;pub use gcbias::GcRank;pub use gcbias::GcStore;pub use gcbias::GcView;pub use gcbias::GC_SAMP_STRIDE;pub use libdetect::infer_format_from_counts;pub use libdetect::LibraryTypeDetector;pub use posbias::compute_length_quantiles;pub use posbias::length_class_index;pub use posbias::SimplePosBias;pub use posbias::NUM_LENGTH_CLASSES;pub use posbias::NUM_POS_BINS;pub use seqbias::build_expected;pub use seqbias::corrected_effective_length;pub use seqbias::LogBiasTable;pub use seqbias::SBModel;
Modules§
- bias
- Unified bias-corrected effective length: composes sequence-specific, GC, and
positional bias exactly as salmon’s
updateEffectiveLengthsdoes — a single conditional-FLD convolution whose per-fragment factor is the product of the enabled bias terms. - dumps
- Aux-output dump helpers shared by reads-mode and alignment-mode quant.
- fld
- Fragment-length distribution.
- gcbias
- Fragment-GC bias model (
GCFragModel). - libdetect
- Automatic library-type detection.
- posbias
- Positional fragment bias (
SimplePosBias) — a port of salmon’ssrc/model/SimplePosBias.cpp. - seqbias
- Sequence-specific bias model (
SBModel). - spline
- Cubic spline interpolation — a faithful port of the vendored
tk::spline(Tino Kluge) used by salmon’sSimplePosBias.
Constants§
- BIAS_
WEIGHT_ SCALE - Fixed-point scale for deterministic bias-model mass accumulation. Bias
observed models sum per-fragment posterior masses (each in
[0,1]) into bins; an f64+=is non-associative, so the accumulated model — and hence bias correction — varies with the worker-thread fragment partition (thread count). Accumulatinground_down(mass * BIAS_WEIGHT_SCALE)as integers makes the sum associative (order/thread-count independent).2^20keeps the per-contribution resolution at ~1e-6 (ample for these coarse models) while a bin total (~num_fragments × 2^20) stays far belowu64::MAX.
Functions§
- bias_
mass_ to_ fp - Quantize a bias mass (
[0,∞), typically a[0,1]posterior) to the fixed-point integer accumulator. Truncates (rounds toward zero) — cheaper thanround()and the ≤1-ULP downward bias is negligible and cancels under the model’s normalization.