pub struct FragmentLengthDistribution { /* private fields */ }Expand description
Tracks the observed distribution of fragment lengths.
Implementations§
Source§impl FragmentLengthDistribution
impl FragmentLengthDistribution
Sourcepub fn new(
alpha: f64,
max_val: usize,
prior_mu: f64,
prior_sigma: f64,
kernel_n: usize,
kernel_p: f64,
bin_size: usize,
) -> Self
pub fn new( alpha: f64, max_val: usize, prior_mu: f64, prior_sigma: f64, kernel_n: usize, kernel_p: f64, bin_size: usize, ) -> Self
Construct a distribution.
alpha– total pseudo-count mass (linear space).max_val– maximum representable length.prior_mu– Gaussian prior mean; if<= 0, a uniform prior is used.prior_sigma– Gaussian prior standard deviation.kernel_n– binomial kernel trials; must be even (after binning).kernel_p– binomial kernel success probability.bin_size– internal length binning (use 1 for no binning).
Sourcepub fn default_for_paired() -> Self
pub fn default_for_paired() -> Self
salmon’s default fragment-length distribution: pseudo-count 1.0, max
length 1000, no Gaussian prior (uniform), kernel n=4, p=0.5.
pub fn max_val(&self) -> usize
pub fn min_val(&self) -> usize
Sourcepub fn add_val(&self, len: usize, mass: f64)
pub fn add_val(&self, len: usize, mass: f64)
Add mass (log space) for an observed fragment of length len,
spreading it over the smoothing kernel. Lock-free; safe to call from
multiple threads. (Must not race with cache.)
Sourcepub fn sd(&self) -> f64
pub fn sd(&self) -> f64
Standard deviation of the observed length distribution, computed from the
cached normalized PMF (call after cache).
Sourcepub fn cache(&mut self)
pub fn cache(&mut self)
Freeze the distribution and precompute normalized PMF/CMF for fast, allocation-free lookup. Call once after updates have stopped.
Sourcepub fn log_pmf(&self) -> &[f64]
pub fn log_pmf(&self) -> &[f64]
The cached, normalized log-PMF over [0, max_val]. Requires cache.
Sourcepub fn conditional_means(&self) -> Vec<f64>
pub fn conditional_means(&self) -> Vec<f64>
Cumulative conditional means E[L | L ≤ i] over [0, max_val], i.e.
salmon’s correctionFactorsFromMass (DistributionUtils.cpp):
cm[i] = (Σ_{l≤i} l·pmf[l]) / (Σ_{l≤i} pmf[l]).
These are the per-length correction factors computeSmoothedEffectiveLengths
subtracts from the reference length to get the base effective length. The
ratio is invariant to the PMF normalization, so the cached (normalized) PMF
gives the same values as salmon’s 100·exp(logPMF) mass. Requires
cache.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FragmentLengthDistribution
impl RefUnwindSafe for FragmentLengthDistribution
impl Send for FragmentLengthDistribution
impl Sync for FragmentLengthDistribution
impl Unpin for FragmentLengthDistribution
impl UnsafeUnpin for FragmentLengthDistribution
impl UnwindSafe for FragmentLengthDistribution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.