Phylogenies
A state::Population
has a phylogenetic tree and metadata about the genotypes attached. Any time evolution routine should take care of maintaining this tree and metadata.
- The vertices
v
are always numbered from 1 and correspond to the genotypemeta[v]
. Useindex
(@ref) to find the id of a genotype. - Inserting a new genotype into the population via
push!(::Population, newgenotype)
will add a vertex to the phylogeny, but won't create an edge that connects it to the tree.
Use add_edge!(state, newgenotype, parent)
(preferred) or add_edge!(state.phylogeny, newgenotype_id, parent_id)
to connect the new genotype to the phylogeny.
GrowthDynamics.Phylogenies.df_traversal!
— MethodSee also df_traversal
GrowthDynamics.Phylogenies.df_traversal
— Methoddf_traversal(G::SimpleDiGraph; root=1)
Traverse a phylogenetic tree depth first, starting at vertex root
which defaults to 1
.
Return a vector of vertices.
GrowthDynamics.Phylogenies.has_children
— MethodDoes a genotype have any children?
GrowthDynamics.Phylogenies.sample_ztp
— Methodsample_ztp(lambda)
Return one sample of a zero-truncated Poisson distribution with rate λ
.
Note: Should be in Distributions.jl
.
Pruning
In the course of a simulation run, especially with large mutation rates, the phylogenetic tree and metadata can become quite extensive. They contain an entry for every genotype that ever was in existence, thus representing the full history of the population. Eventually performance will deteriorate. If the full tree is not needed, one may opt to occasionally prune the tree and metadata, that is, remove internal nodes that have died out.
See also the keyword arguments prune_period
and prune_on_exit
.
GrowthDynamics.Populations.prune_phylogeny!
— Functionprune_phylogeny!(S::Population)
Remove unpopulated genotypes from the phylogenetic tree and meta data. Any gap in the phylogeny is bridged.