Quickstart¶
A 30-second tour. Build a 2-site binary map, hand it to gpgraph-v2 for the neighbor graph, then to gpvolve-v2 for the Markov state model.
from gpmap import GenotypePhenotypeMap
from gpgraph import GenotypePhenotypeGraph
from gpvolve import (
GenotypePhenotypeMSM,
forward_committor,
reactive_flux,
rate,
sample_paths,
timescales,
)
gpm = GenotypePhenotypeMap(
wildtype="00",
genotypes=["00", "01", "10", "11"],
phenotypes=[1.0, 1.5, 1.2, 2.0],
)
graph = GenotypePhenotypeGraph.from_gpm(gpm)
msm = GenotypePhenotypeMSM.from_graph(
graph, fitness_column="phenotypes", fixation="moran", population_size=100
)
msm is a dataclass with five locked attributes (see SCHEMA):
transition_matrix: row-stochasticcsr_matrix, rows sum to 1.0 within 1e-12stationary: the stationary distributiongpm,graph: the upstream containersfixation_model,fixation_params: howtransition_matrixwas built
Spectral analysis¶
Transition path theory¶
q_plus = forward_committor(msm.transition_matrix, A=0, B=3)
flux = reactive_flux(msm.transition_matrix, A=0, B=3)
k_AB = rate(msm.transition_matrix, A=0, B=3)
Stochastic path sampling with convergence¶
sample_paths keeps drawing walker chunks until the ESS and Gelman-Rubin
R-hat for each endpoint both clear their thresholds. The default
ConvergenceCheck() has ess_min=200 and rhat_max=1.01. Override either
by passing your own ConvergenceCheck. See the
Stochastic sampling guide for the full
story.