This page works through the mathematical model implemented by
inst/multirates_positive_s.stan, and lays each quantity
next to the R argument, table or column that supplies it. Read this
before vignette("Multirates_inference") if you want to know
why the input tables are shaped the way they are, rather than
just how to build them.
Two epigenetic states, growth and switching
Cells exist in one of two epigenetic states, written -
and +. A population’s size in each state is a vector
,
and every lineage in the model (the wild-type background, a driver
clade, a driver+clade combo, …) is governed by the same linear ODE, just
with its own rate parameters:
-
is the division rate of
-cells. -
is the division rate of
+cells, written relative to via a fitness coefficient (so means+cells divide faster). - and are the rates at which cells switch epigenetic state.
Because does not depend on , the population at any later time is an exact matrix-exponential solution:
This is the Stan model’s own Z() function.
The groups: wt, drivers, driver-only clades, driver+clade combos
The population is not a single lineage: it is the wild-type background plus any number of sub-lineages, each founded at its own time from a single cell and governed by the ODE above with its own rate parameters.
| Genotype | Founded at | s_g |
Switch rates | Confined to one state? |
|---|---|---|---|---|
| wt (background) | — | no | ||
| clade_wt (wt sub-lineage) | — | (shared with wt) | no | |
| driver | (own) | (own) | no | |
| driver_n | (own) | none (no switching) | yes, - only |
|
| driver_p | (own) | none (no switching) | yes, + only |
|
| dc driver leg | (own) | (own) | no | |
| dc clade leg | (shared with its driver leg) | (shared with its driver leg) | no |
whereas s_g is genotype specific fitness advantage with
respect to the wild type. driver_n,driver_p
are the simplest cases: with no switching, the ODE collapses to plain
exponential growth,
.
A dc (driver+clade) entity is a nested pair: its
driver leg is founded first with a single cell, and its clade leg is a
further sub-lineage founded later within the driver leg,
sharing the same growth/switch rates - modelling a clade defined by a
further epimutation switch event that occurred after the driver
mutation.
At each sampling time, the total population in each state is the sum
of the wt background and every additive group (driver,
driver_n, driver_p, and the dc
driver leg - clade_wt and the dc clade leg are
nested inside their parent lineage’s mass, not counted
again):
and analogously for .
The observation model
Cancer cell fractions (CCF) and mutation-arm fractions
For genotypes that occupy both epigenetic states, the CCF of the
- phenotype at a sampling time is the fraction of that
genotype’s cells that are in the - state:
This is observed (as data) or predicted (as a posterior draw) with Beta noise of concentration :
This CCF is defined only for genotypes g with both
- and + compartments such as wt
and driver; genotypes confined to a single epigenetic
state, such as driver_n, driver_p do not have
a phenotypic CCF split.
kappa is the same idea as bayesplot’s
neff_ratio - it controls how tightly the observed fraction
is expected to hug its predicted mean; high
means a very peaked, low-noise likelihood (see
vignette("Convergence_diagnostics") for why a very high
kappa can make Stan’s sampler harder to initialize).
Population sizes
Total population sizes for each genotype at sampling times
(zminus, zplus) and at any additional
intermediate times (ztot) are observed with lognormal noise
of scale
:
Mutation counts
Every branch event (the trunk, a driver acquisition, a clade split, …) accumulates mutations as a Poisson process while cells divide. For a branch with growth rate (its own or once a fitness effect has taken hold) spanning an elapsed time :
where
(mu) is the per-division, per-bp mutation rate and
(l) is the genome length. The trunk uses
;
a driver or driver_n acquisition uses
;
a dc combo’s clade leg uses the post-driver rate
over
.
Priors
| Parameter | Prior | Set via |
|---|---|---|
(lambda_n) |
alpha_lambda, beta_lambda
|
|
(s_epi) |
ms_epi, sigma_epi
|
|
alpha_n_wt/beta_n_wt,
alpha_p_wt/beta_p_wt
|
||
t_min (t_max is the latest sampling
time) |
||
| , one prior per entity |
ms_driver/sigma_driver columns (etc.) in
the entity’s _muts table |
|
(and _dc) |
, one prior per entity |
alpha_n_driver/beta_n_driver columns
(etc.) |
min_kappa, max_kappa
|
||
min_sigma_count, max_sigma_count
|
Global priors are arguments to fit_multirates().
Per-entity priors (driver/driver_n/driver_p/dc fitness and switch-rate
hyperparameters) are supplied per row in the corresponding
_muts table, since a well-studied oncogene and a novel
candidate driver may legitimately warrant different priors within the
same fit.
Notation table
The table below is the authoritative map from math to code: the Stan
parameter/generated-quantity name (as it appears in
get_posterior_multirates()’s tidy output), and the R-facing
input that supplies it.
| Symbol | Stan / getter name | R input |
|---|---|---|
lambda_n |
fit_multirates(alpha_lambda=, beta_lambda=) |
|
| () | s_epi |
fit_multirates(ms_epi=, sigma_epi=) |
omega_p_wt |
fit_multirates(alpha_p_wt=, beta_p_wt=) |
|
omega_n_wt |
fit_multirates(alpha_n_wt=, beta_n_wt=) |
|
tmrca |
inferred (bounded by t_min and the latest
sampling time) |
|
t_min |
fit_multirates(t_min=) |
|
s_driver |
driver_muts$ms_driver,
sigma_driver
|
|
| , |
omega_p_driver,
omega_n_driver
|
driver_muts$alpha_n_driver, … (per
row) |
t_driver |
inferred (bounded by tmrca and
t_max) |
|
| (observed) | m_driver |
driver_muts$m_driver |
| / |
s_driver_n / s_driver_p
|
driver_n_muts/driver_p_muts$ms_driver_n/_p
|
| / |
t_driver_n / t_driver_p
|
inferred |
s_dc |
dc_muts$ms_dc, sigma_dc
|
|
delta_t_dc[,1],
delta_t_dc[,2]
|
inferred | |
| (wt sub-lineage) | t_clade_wt |
inferred |
| (observed) |
ccf (family "ccf") |
driver_ccf/clades_wt_ccf/dc_ccf/wt_ccf$ccf
|
kappa |
fit_multirates(min_kappa=, max_kappa=) |
|
| (observed) |
zminus, zplus
|
population_sizes$zminus,
zplus
|
sigma_count |
fit_multirates(min_sigma_count=, max_sigma_count=) |
|
| (mutation rate) | mu |
fit_multirates(mu=) |
| (genome length) | l |
fit_multirates(l=) |
For the full input table schemas (columns required per group), see
?init_multirates and ?check_input_multirates,
or the worked example in
vignette("Multirates_inference").
