- 1 Introduction
- 2 Protocol
- 2.1 Step 1: Load data in NEXUS format
- 2.2 Step2: Import or create traits
- 2.3 Step 4: Setting the substitution model
- 2.4 Step 5: Setting the clock model
- 2.5 Step 6: Setting Tree Priors
- 2.6 Step 7: Priors and Operators
- 2.7 Step 8: Setting the MCMC options
- 2.8 Step 9: Generating the BEAST XML file
- 2.9 Step 10: Running BEAST
- 2.10 Step 11: Analyzing the results
- 2.11 Step 12: Obtaining an estimate of the phylogenetic tree
- 2.12 Step 13: Viewing the Tree
- 2.13 Step 14: Comparing your results to the prior
Bayesian Inference of Species Trees from Multilocus Data using *BEAST, Alexei J Drummond, Walter Xie and Joseph Heled April 13, 2012
Provides joint inference of a species tree topology, divergence times, population sizes, and gene trees from multiple genes sampled from multiple individuals across a set of closely related species. It's an extension of BEAST to *BEAST (pronounced ”star beast”).
Publication: Joseph Heled and Alexei J. Drummond Bayesian Inference of Species Trees from Multilocus Data Mol. Biol. Evol. 2010 27: 570-580.
The protocol is taken from the tutorial.
You will need the following software at your disposal:
- BEAST - this package contains the BEAST program, BEAUti, TreeAnnotator and other utility programs. This tutorial is written for BEAST v1.7.x, which is
available for download from http://beast.bio.ed.ac.uk/.
- Tracer - this program is used to explore the output of BEAST (and other
Bayesian MCMC programs). It graphically and quantitively summarizes the distributions of continuous parameters and provides diagnostic information. At the time of writing, the current version is v1.5. It is available for download from http://beast.bio.ed.ac.uk/.
- FigTree - this is an application for displaying and printing molecular phylogenies,in particular those obtained using BEAST. At the time of writing, the current
version is v1.3.1. It is available for download from http://tree.bio.ed.ac.uk/.
This tutorial will guide you through the analysis of three loci sampled from 26 individuals representing nine species of pocket gophers. This is a subset of previous published data (N.M. Belfiore, L. Liu, and C. Moritz, Multilocus phylogenetics of a rapid radiation in the genus Thomomys (Rodentia: Geomyidae), Systematic Biology 57 (2008), no. 2, 294). The objective of this tutorial is to estimate the species tree that is most probable given the multi-individual multi-locus sequence data. The species tree has 9 taxa, whereas each gene tree has 26 taxa.
- BEAST will co-estimate three gene trees embedded in a shared species tree (see Heled and Drummond, 2010 for details).
Step 1: Load data in NEXUS format
The first step will be to convert a NEXUS file with a DATA or CHARACTERS block into a BEAST XML input file. This is done using the program BEAUti (Bayesian Evolutionary Analysis Utility). This is a user-friendly program for setting the evolutionary model and options for the MCMC analysis. The second step is to actually run BEAST using the input file that contains the data, model and settings. The final step is to explore the output of BEAST in order to diagnose problems and to summarize the results.
Run the BEAUti program and load a NEXUS format alignment, simply select the Import Data... option fromthe File menu.
Select three files called 26.nex, 29.nex, 47.nex by holding shift key. Each file contains an alignment of sequences of from an independent locus.
Once loaded, the three partitions are displayed in the main panel. Double click any alignment (partition) to show its detail.
Step2: Import or create traits
Import trait(s) from a mapping file to fire *BEAST To enable *BEAST in BEAST v1.7.x, simply click the check box labelled Use species tree ancestral reconstruction (*BEAST) Heled & Drummond 2010 on the top of Data Partitions panel. Then, a Create or Import Trait(s) dialog will pop up.
There are two options to be selected: 1. Import trait(s) from a mapping file; 2. Create a new trait and then guess trait value from taxa name species. Choose the first option and click OK to load the mapping file, named gopher mapping.txt. Once loaded, a message indicating the use of *BEAST will be displayed in the status at the bottom of the window, and a trait named species is created in the trait table in the Traits tab. Click it to show trait values.
A proper trait file is tab delimited. The first row is always traits followed by the keyword species in the second column and separated by tab. The rest of the rows map each individual taxon name to a species name: the taxon name in the first column and species name in the second column separated by tab. For example:
traits species taxon1 speciesA taxon2 speciesA taxon3 speciesB
For multi-locus analyses, BEAST can link or unlink substitutions models across the loci by clicking buttons on the top of Data Partitions panel. The default of *BEAST is unlinking all models: substitution model, clock model, and tree models. Note that you should only unlink the tree model across data partitions that are actually genetically unlinked. For example, in most organisms all the mitochondrial genes are effectively linked due to a lack of recombination and they should be set up to use the same tree model in a *BEAST analysis.
Alternatively: Create a species trait from taxa names The advantage of using the Traits panel is that we can extract species names from the taxa names if they already contain that information. Let’s go to Data Partitions panel and unselect the check box labelled Use species tree ancestral reconstruction (*BEAST) Heled & Drummond 2010. As we can see in the status bar on the bottom, the analysis has been reverted to a standard BEAST analysis. To enable *BEAST again, click the Use species tree ancestral reconstruction (*BEAST) Heled & Drummond 2010 on the top of Data Partitions panel, and then choose the second option in Create or Import Trait(s) dialog this time. Click OK to continue, and then we will get to Traits panel and click on the Guess trait values at the top to pop out Guess Trait Value for Taxa dialog. Choose second in the drop list of Defined by its order, and input as separator. Click OK, and *BEAST is applied again.
Step 4: Setting the substitution model
The next thing to do is to click on the Site Models tab at the top of the main window. This will reveal the evolutionary model settings for BEAST. Exactly which options appear depend on whether the data are nucleotides, or amino acids, or binary data, or general data. The settings that will appear after loading the data set will be the default values so we need to make some changes.
Most of the models should be familiar to you. For this analysis, we will select each substitution model listed on the left side in turn to make the following change: select Empirical for the Base frequencies. Remember to do this for all site models.
Step 5: Setting the clock model
Click on the Clock Models tab at the top of the main window. In this analysis, we use the Strict Clock molecular clock model as default.
The Estimate check box is unchecked for the first clock model and checked for the rest of the clock models, because we wish to estimate the mutation rate of each subsequent locus relative to the first locus whose rate is fixed to 1.0.
Step 6: Setting Tree Priors
The Trees panel allows priors to be specified for each parameter in the model, which can be defined on the top of the panel. *BEAST has a different tree prior panel where users can only configure the species tree prior not gene tree priors (which are automatically specified by the multispecies coalescent). Currently, we have two species tree priors: Yule Process and Birth-Death Process; and three population size models: Piecewise linear and constant root, Piecewise linear, and Piecewise constant. In this analysis, we use the default options.
The bottom right panel is used to configure the corresponding starting trees. The Ploidy Type menu determines the type of sequence (mitochondrial, nuclear, X, Y). This matters since different modes of inheritance give rise to different effective population sizes. The Starting Tree menu provides three options, where the user-specified starting tree has to be loaded from the data file (e.g. NEXUS file) in advance. In this analysis, we simply use a random starting tree.
Step 7: Priors and Operators
The Priors panel allows priors to be specified for each parameter in the model. The Operators panel is used to configure technical settings that affect the efficiency of the MCMC program (see Notes for details). We leave these two panels unchanged in this analysis.
Step 8: Setting the MCMC options
The next tab, MCMC, provides more general settings to control the length of the MCMC and the file names.
Firstly we have the Length of chain. This is the number of steps the MCMC will make in the chain before finishing. The appropriate length of the chain depends on the size of the data set, the complexity of the model and the accuracy of the answer required. The default value of 10,000,000 is entirely arbitrary and should be adjusted according to the size of your data set. For this data set let’s initially set the chain length to 5,000,000 as this will run reasonably quickly on most modern computers (less than 20 minutes).
The next options specify how often the parameter values in the Markov chain should be displayed on the screen and recorded in the log file. The screen output is simply for monitoring the programs progress so can be set to any value (although if set too small,
The sheer quantity of information being displayed on the screen will actually slow the program down). For the log file, the value should be set relative to the total length of the chain. Sampling too often will result in very large files with little extra benefit in terms of the precision of the analysis. Sample too infrequently and the log file will not contain much information about the distributions of the parameters. You probably want to aim to store no more than 10,000 samples so this should be set to no less than chain length / 10,000.
For this exercise we will set the screen log to 10000 and the file log to 1000. The final two options give the file names of the log files for the sampled parameters and the trees. These will be set to a default based on the name of the imported NEXUS file. If you would like to save the operator analysis into a file, you need to check Create operator analysis file which will generate a file with the suffix .ops.
Step 9: Generating the BEAST XML file
We are now ready to create the BEAST XML file. To do this, either select the Generate BEAST File... option from the File menu or click the similarly labelled button 11 at the bottom of the window. Check the default priors setting and click Continue. Save the file with an appropriate name (we usually end the filename with .xml, i.e., gopher.xml). We are now ready to run the file through BEAST.
Step 10: Running BEAST
Now run BEAST and when it asks for an input file, provide your newly created XML file as input by click Choose File ..., and then click Run.
BEAST will then run until it has finished reporting information to the screen. The actual results files are saved to the disk in the same location as your input file.
Step 11: Analyzing the results
Run the program called Tracer to analyze the output of BEAST. When the main window has opened, choose Import Trace File... from the File menu and select the file that BEAST has created called gopher.log.
Remember that MCMC is a stochastic algorithm so the actual numbers will not be exactly the same.
On the left hand side is a list of the different quantities that BEAST has logged. There are traces for the posterior (this is the log of the product of the tree likelihood and the prior probabilities), and the continuous parameters. Selecting a trace on the left brings up analyses for this trace on the right hand side depending on tab that is selected. When first opened, the ‘posterior’ trace is selected and various statistics of this trace are shown under the Estimates tab. In the top right of the window is a table of calculated statistics for the selected trace.
Tracer will plot a (marginal posterior) distribution for the selected parameter and also give you statistics such as the mean and median. The 95% HPD lower or upper stands for highest posterior density interval and represents the most compact interval on the selected parameter that contains 95% of the posterior probability. It can be thought of as a Bayesian analog to a confidence interval.
Select the treeModel.rootHeight parameter and the next three (hold shift whilst selecting). This will show a display of the age of the root and the three gene trees. If you switch the tab at the top of the window to Marginal Density then you will get a plot of the marginal posterior densities of each of these date estimates overlayed:
Step 12: Obtaining an estimate of the phylogenetic tree
BEAST also produces a sample of plausible trees. These need to be summarized using the program TreeAnnotator (see Notes for details). This will take the set of trees and identify a single tree that best represents the posterior distribution. It will then annotate this selected tree topology with the mean ages of all the nodes as well as the 95% HPD interval of divergence times for each clade in the selected tree. It will also calculate the posterior clade probability for each node.
The burnin is the number of trees to remove from the start of the sample. Unlike Tracer which specifies the number of steps as a burnin, in TreeAnnotator you need to specify the actual number of trees. For this run, we use the default setting. The Posterior probability limit option specifies a limit such that if a node is found at less than this frequency in the sample of trees (i.e., has a posterior probability less than this limit), it will not be annotated. The default of 0.5 means that only nodes seen in the majority of trees will be annotated. Set this to zero to annotate all nodes. For Target tree type you can either choose a specific tree from a file or ask TreeAnnotator to find a tree in your sample. The default option, Maximum clade credibility tree, finds the tree with the highest product of the posterior probability of all its nodes.
Choose Mean heights for node heights. This sets the heights (ages) of each node in the tree to the mean height across the entire sample of trees for that clade. For the input file, select the trees file that BEAST created (by default this will be called gopher.species.trees) and select a file for the output (here we called it gopher.species.tree). Now press Run and wait for the program to finish.
Step 13: Viewing the Tree
Finally, we can look at the tree in another program called FigTree. Run this program, and open the gopher.species.tree file by using the Open command in the File menu. The tree should appear. You can now try selecting some of the options in the control panel on the left. Try selecting Node Bars to get node age error bars. Also turn on Branch Labels and select posterior to get it to display the posterior probability for each node. Under Appearance you can also tell FigTree to colour the branches by the length.
Step 14: Comparing your results to the prior
Using BEAUti, set up the same analysis but under the MCMC options, select the Sample from prior only option. This will allow you to visualize the full prior distribution in the absence of your sequence data. Summarize the trees from the full prior distribution and compare the summary to the posterior summary tree.