For 20 samples from a panmictic population:
For a neutral model with two populations and migration:
model2a <- coal_model(c(10, 10), 100) +
feat_mutation(10) +
feat_recombination(5) +
feat_migration(0.5, symmetric = TRUE) +
sumstat_sfs(population = "all")
stats <- simulate(model2a, seed = 20)
barplot(stats$sfs / sum(stats$sfs),
names.arg = seq_along(stats$sfs),
col = 3)
And again, but now with a bottleneck in one population:
model3 <- coal_model(10, 50) +
feat_mutation(par_prior("theta", sample.int(100, 1))) +
sumstat_nucleotide_div()
stats <- simulate(model3, nsim = 40)
mean_pi <- sapply(stats, function(x) mean(x$pi))
theta <- sapply(stats, function(x) x$pars[["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!