25 February 2019 by Remco Bouckaert
Epoch models are models that split time into time slices and use different models in each slice. Here, we have a look at epoch substitution models (Bielejec et a, 2014). Epoch substitution models are part of the BEASTLabs package, so you need to install this package to run the model.
There is no BEAUti support for epoch substitution models yet, so we have to edit the XML directly in order to set up the analysis. However, the easiest is to set up a single epoch substitution model analysis in BEAUti first, then proceed editing the XML. Say, we want to have a separate HKY model in each of our epochs. We set up the analysis in BEAUti with a single HKY model, save the XML to file and open the file in an XML editor. Search for "substModel", and we get to this fragment:
Now, rename the substModel element to model and wrap it inside a new substModel element with spec="EpochSubstitutionModel". The EpochSubstitutionModel also needs a frequencies entry, which is otherwise ignored, but for technical reasons is still there. We can refer to the frequencies from the HKY model for example. The fragment now looks like this:
Next, we define the epochs. Add an epochdates element to the substModel, and specify the ages of the epoch-boundaries. In principle this can be dynamically estimated, but here we fix it to one boundary at 6.0 and another at 12.0. Finally, we need three substitution models, so copy the model element and we will use the same base frequencies, so we replace the frequencies with a reference to the frequencies of the first model. We have to make sure id attributes are unique, so add a 2 to each id in the second model, and a 3 to that of the third model. The XML now looks like so:
Note that the first model is for times above 12, the second model is for times between 6 and 12 and the third model is for times lower than 6. If there is a branch that crosses an epoch boundary, say from 5 to 8, it uses the third model for the part from 5 to 6, and the second model for the part from 6 to 8.
What is left is setting up the substitution model parameters, here the kappa parameter, which need to be
- part of the state
- get a prior
- have operators
- part of the trace log
The state should contain something like this:
The prior should contain something like this:
The operators should contain entries like this:
The trace logger should contain entries like this:
After running the XML in BEAST, you can tell see how different epochs have different substitution model processes by inspecting the trace log in Tracer.
Trouble shootingAt the start, BEAST may report a null-pointer exception like so: Epoch substitution models do not work with BEAGLE (yet), so you need to run without BEAGLE. However, if you do run with BEAGLE, the above error will appear, after which BEAST falls back to the java implementation of Felsenstein's pruning algorithm.
Ayres, Daniel L., et al. "BEAGLE: an application programming interface and high-performance computing library for statistical phylogenetics." Systematic biology 61.1 (2011): 170-173.
F. Bielejec, P. Lemey, G. Baele, A. Rambaut, and M. A. Suchard. Inferring heterogeneous evolutionary processes through time: from sequence substitution to phylogeography. Systematic Biology 63(4):493–504, 2014.