The Coalescent

# #| echo: false
# #| column: margin
# from phasic.utils import download_link
# download_link(__vsc_ipynb_file__) 

The sequence of tutorials show-cases the complete Python API of the Phasic library, a high-performance computational framework for modelling inference on waiting times in Markov jump processes. In addition to this introduction, the tutorial covers the following topics - in each as a jupyter notebook you can download and play with yourself.

Throughout the tutorials we use the Coalescent model as an example. The Coalescent is a continuous-time Markov chain that models the ancestry of a sample of individuals from a population. Lineages coalesce into fewer lineages with more descendants until only a single common ancestral lineage remains. Branches in the resulting tree represent lineages. We call those with a single sampled descendant singleton lineages. The ones with two descendants are doubletons and so on. With four samples, the Coalescent jumps with four singletons and terminates with a single quadrupleton (4’ton). We can encode the states of this Markov chain as vectors enumerating the number of of 1’tons, 2’tons, 3’tons, and 4’tons.

(a) Coalescent tree for nine samples showing the mutations giving rise to the nucleotides at a single sequence position.
(b)
Figure 1
from phasic import Graph # ALWAYS import phasic first to set jax backend correctly
import numpy as np
import seaborn as sns
from vscodenb import set_vscode_theme
set_vscode_theme()
sns.set_palette('tab10')
Figure 2: The coalescent process with four samples. The S (starting) state just signifies that the process begins in state (4,0,0,0). Edges are annotated with the coalescence rates that, in this model represents the transition rates of the model