# #| echo: false
# #| column: margin
# from phasic.utils import download_link
# download_link(__vsc_ipynb_file__) The Coalescent
from phasic import Graph
from phasic.utils import tree_illustration
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from vscodenb import set_vscode_theme
set_vscode_theme()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 because mutations occurring on those branches produce a singleton mutation in our sample. Similarly with doubletons tripleton and so on.
We can encode the states of this Markov chain as vectors enumerating the number of live 1’tons, 2’tons, 3’tons, and 4’tons branches (Figure 1). With four samples, the Coalescent jumps starts with a state of four singletons and terminates/absorbs at the state with a single 4’ton (Figure 2).