For 20 samples from a panmictic population:
library(coala)
<- coal_model(20, 2000) +
model feat_mutation(2) +
feat_recombination(1) +
sumstat_tajimas_d()
<- simulate(model, seed = 15)
stats plot(density(stats$tajimas_d, na.rm = TRUE),
main = "Neutral Distribution of Tajiam's D")
For a neutral model with two populations and migration:
<- coal_model(c(10, 10), 100) +
model2a feat_mutation(10) +
feat_recombination(5) +
feat_migration(0.5, symmetric = TRUE) +
sumstat_sfs(population = "all")
<- simulate(model2a, seed = 20)
stats barplot(stats$sfs / sum(stats$sfs),
names.arg = seq_along(stats$sfs),
col = 3)
And again, but now with a bottleneck in one population:
<- model2a +
model2b feat_size_change(0.1, population = 2, time = 0.25) +
feat_size_change(1, population = 2, time = 0.5)
<- simulate(model2b, seed = 25)
stats barplot(stats$sfs / sum(stats$sfs),
names.arg = seq_along(stats$sfs),
col = 4)
<- coal_model(10, 50) +
model3 feat_mutation(par_prior("theta", sample.int(100, 1))) +
sumstat_nucleotide_div()
<- simulate(model3, nsim = 40)
stats <- sapply(stats, function(x) mean(x$pi))
mean_pi <- sapply(stats, function(x) x$pars[["theta"]])
theta plot(theta, mean_pi, pch = 19, col = "orange")
abline(lm(mean_pi ~ theta), col = "red2", lty = 3)
If you have a nice example for using coala, feel free to extend this vignette via a pull request on GitHub!