Coalescent simulation of genealogies

Julia Palacios

October 6, 2016

Coalescent simulation of genealogies

A Genealogy (tree) consist of Topology and coalescent times.

The main function for simulation of genealogies in phylodyn is . In all our simulations, time is measured in units of \(N_{0}\) generations.

gene = coalsim(samp_times = samp_times, n_sampled = n_sampled, traj = traj, lower_bound = 1/20)

Examples

The following example generates an isochronous genealogy from a constant effective population size (Ne=1) with 10 tips.

library("phylodyn")

constant<-function(x){
  return (rep(1,length(x)))
}

simulation1<-coalsim(0,10,constant)
tree1<-generate_newick(simulation1)
plot(tree1$newick)

tree1$newick
## 
## Phylogenetic tree with 10 tips and 9 internal nodes.
## 
## Tip labels:
##  t1_0, t2_0, t3_0, t4_0, t5_0, t6_0, ...
## 
## Rooted; includes branch lengths.

In the following example we simulate a genealogy with constant effective population size with 10 tips at time 0 and 40 other tips with uniform sampling times

samp_times = c(0, sort(runif(40, 0, 8)))
n_sampled = c(10, rep(1, 40))

simulation2<-coalsim(samp_times = samp_times, n_sampled = n_sampled, traj = constant)
tree2<-generate_newick(simulation2)
plot(tree2$newick,show.tip.label = F)

tree2$newick
## 
## Phylogenetic tree with 50 tips and 49 internal nodes.
## 
## Tip labels:
##  t49_0, t50_0, t33_0, t34_0, t28_0, t26_0, ...
## 
## Rooted; includes branch lengths.

Here, we consider a more general demographic model such as bottleneck. We specify our trajectory through the function and simulate via the thinning method (see Palacios and Minin, 2013)

bottleneck_traj<-function(t){
  result=rep(0,length(t))
  result[t<=0.5]<-1
  result[t>0.5 & t<1]<-.1
  result[t>=1]<-1
  return(result)
}

simulation3<-coalsim(samp_times = samp_times, n_sampled = n_sampled, traj = bottleneck_traj,method="thin",val_upper=11)
tree3<-generate_newick((simulation3))
plot(tree3$newick,show.tip.label = F)

Note: Other R packages such as Ape and phyclust (ms) have functions that simulate isochronous genealogies under the coalescent model for specific demographic scenarios such as exponential growth and piece-wise constant functions.