Simulating the coalescent with Biopython and fastsimcoal
While there is a native Python coalescent simulator called CoaSim, this is a very old application that does not run on modern Python versions. As such, if you want to do coalescent simulations with Python, Biopython offers a wrapper to fastsimcoal and the older simcoal.
Here, we will generate some configuration files for fastsimcoal with the demographic and genomic information. We will also run the coalescent simulator from Python.
Getting ready
You will need to obtain fastsimcoal from http://cmpg.unibe.ch/software/fastsimcoal2/. If you are using the Docker image, this is taken care of for you.
If you are using notebooks, this content is in 04_PopSim/Coalescent.ipynb
.
How to do it…
Take a look at the following steps:
Let's start by taking a look at the available demographic models:
import os from Bio.PopGen import SimCoal as simcoal print(simcoal.builtin_tpl_dir) print(os.listdir(simcoal.builtin_tpl_dir))
This will print a directory where templates...