ML Search Lab

Modified from Derrick Zwickl's Garli Lab activity and from Alexis Stamatakis's RAxML tutorial by Emily Jane McTavish,

table of contents

getting started

  • Download the package of files used in this activity: MLsearch.WH2017.zip
    Login to the cluster and type

    wget https://mctavishlab.github.io/assets/MLsearch.WH2017.zip

  • Uncompress the zip file using "unzip MLsearch.WH2017.zip"
    You will need to make edits to the configuration file and command line arguments in most cases.
    In order to compete these exercises you will need to have a tree viewer and a text editor installed, and be able to access the cluster and move files to and from the cluster.

Example data set
We will be using a small 29 taxon by 1218 nucleotide mammal data set that was taken from a much larger data set (44 taxa, 17kb over 20 genes) presented in (Murphy 2001). The genes included here are RAG1 and RAG2 (Recombination Activating Gene). This is a difficult data set because the internal branches are quite short, and the terminals quite long. This is a hard phylogenetic problem, and phylogenetic estimates are less repeatable on this data set than on many others of similar size, so consider this a "worst case" data set. There are definitely local topological optima. The trees inferred using this gene also do not match our understanding of the relationships of these taxa in many places, but that is not really important for our purposes here.

We will run several analyses using two different software tools for estimating Maximum Likelihood phylogenies, Garli and RAxML

ON THE MERCED CLUSTER: Don't try interactive analyses unless you are using 'srun', e.g. 'srun --pty /bin/bash' to login to a node. You can try running these examples either interactively or by submitting as jobs to fastq.

Garli
Garli is not under active development, and does not make sense for running analyses on large-size current data sets, but it tracks a lot of information about the tree search process, that make it very helpful for understanding maximum likelihood tree searching. GARLI reads all of its settings from a configuration file. By default it looks for a file named garli.conf, but other configuration files can be specified as a command line argument after the executable (e.g., if the executable were named garli, you would type "garli myconfig.conf"). Note that most of the settings typically do not need to be changed from their default values, at least for exploratory runs. We will only experiment with some of the interesting settings in this demo, but detailed discussions of all settings can be found on the support web site.

The config file is divided into two parts: [general] and [master]. The [general] section specifies settings such as the data set to be read, starting conditions, model settings, and output files. To start running a new data set, the only setting that must be specified is the datafname, which specifies the file containing the data matrix in Nexus, PHYLIP, or FASTA format. The [master] section specifies settings that control the functioning of the genetic algorithm itself, and typically the default settings can be used. Basic template configuration files are included with any download of the program.

Run garli by calling the software and telling it the name of the configuration file to use. To run:
garli ‹garli config file›

RAxML
RAxML reads its configuration information from command line flags. We will walk through a few commonly used arguments in this lab, but there are many potential options, which are described in the RAxML Manual. The command line flags required for every raxml run are
raxmlHPC -m ‹model of evolution› -p ‹random number seed› -s ‹alignment file (in fasta or phylip format)› -n ‹output_name›
These flags can be used in any order, but it makes things much less confusing if you keep them in the same order when you run different analyses. I like to keep the model of evolution first, and data file and the output file name last. You can type in a number after -p for the random number seed, or use $RANDOM, which will choose a random number for you. Using a seed allows you to re-run analyses and get the same results. But if you want to compare different results, be sure to change the random seed!
NOTE: RAxML will not automatically overwrite files form previous runs with the same name. Sometimes this is convenient, sometimes it is annoying. If you get the error message RAxML output files with the run ID ‹output_name› already exist" either delete those files, or use a new name for your output. We will set up several analyses in both RAxML and Garli for comparison and to explore tree searching, likelihood calculations, models of evolution and bootstrapping.

exercise 1: start a basic nucleotide run

  • Change to the MLSearchLab directory
  • Open the garli_ex1.conf file in a text editor.

Garli
There is not much that needs to be changed in the config file to start a preliminary run. In this example config file, a number of changes from the defaults have been made so that the example is more instructive and a bit faster (therefore, do NOT use the settings in this file as defaults for any serious analyses). You will still need to change a few things yourself. Note that the configuration file specifies that the program perform two independent search replicates (searchreps = 2). Also note that taxon 1 (Opossum) is set as the outgroup (outgroup = 1).

Make the necessary changes:

  • Set datafname = datafiles/murphy29.rag1rag2.nex
  • Set ofprefix = garli_run1. This will tell the program to begin the name of all output files with "garli_run1...".
  • We are going to use a GTR+I+G model of sequence evolution. This the default model set in the configuration file, so you don't need to change anything, but look at the section that sets up the evolutionary model:
    datatype = dna
    ratematrix = 6rate
    statefrequencies = empirical
    ratehetmodel = gamma
    numratecats = 4
    invariantsites = estimates
    
  • Save the file
  • Submit a job on fastq to run Garli using that configuration file. The command to run garli garli_ex1.conf

If you are running interactively, you will see a bunch of text scroll by, informing you about the data set and the run that is starting. If you have submitted a job this information will be writted to JOBNAME.log. Most of this information is not very important, but if the program stops be sure to read it for any error messages. The output will also contain information about the progress of the initial optimization phase, and as the program runs it will continue to log information to the screen. This output contains the current generation number, current best lnL score, optimization precision and the generation at which the last change in topology occurred. All of the screen output is also written to a log file that in this case will be named garli_run1.screen.log, so you can come back and look at it later.

Monitoring an ongoing run

(These are not things that you would normally need to do with your own analyses)

We will do this just in Garli, because it is more straightforward than monitoring a run in RAxML

  • Look in the MLSearchLab directory, and note the files that have been created by the run.
  • Open garli_run1.log00.log in a text editor.

    This file logs the current best lnL, runtime, and optimization precision over the course of the run. It is useful for plotting the lnL over time. Next, we will look at the file that logs all of the information that is output to the screen.

  • Open garli_run1.screen.log in a text editor.

    This file contains an exact copy of the screen output of the program. It can be useful when you go back later and want to know what you did. In particular, check the "Model Report" near the start to ensure that the program is using the correct model.

    Now let's look at the current best topology. This is contained in a file called garli_run1.best.current.tre. This file is updated every saveevery generations, so it is always easy to see the current best tree during a search. (Do not use this as a stopping criterion and kill the run when you like the tree though!)

  • Open garli_run1.best.current.tre in Figtree or another tree viewer and examine the tree. (You may be able to double-click the file and associate .tre files with Figtree.)
RAxML
Now lets run the same analysis in RAxML.

Instead of using a config file, you will provide the same (or similar) information via command line flags. We will used the required flags and add '-# 2', to tell RAxML to run 2 search replicates, like we did in Garli.
We are using same dataset as we used for Garli, but in fasta file format, rather than nexus. (Take a look at the files in MLsearchLab/datafiles to familiarize yourself.)

To set the evolutionary model to GTR+I+G, as we did in the Garli run, we will use '-m GTRGAMMAI'. RAxML also implements a similar, faster model, GTRCAT, that uses a different approximation to capture rate heterogeneity across sites. GTRCAT is faster and can yield trees with slightly better likelihood values (see Stamatakis 2006). It is not a good idea to use the CAT approximation of rate heterogeneity on datasets with less than 50 taxa. In general there will not be enough data per alignment column available to reliably estimate the per-site rate parameters. We only have 29 taxa here, so we will stick with GTRGAMMA.
We will compare the likelihoods of our trees from our RAxML and Garli searches in Exercise 3
Set up a submission script, and submit this job to the fastq.

  • raxmlHPC -m GTRGAMMAI -p ‹choose a random number seed› -# 2 -s datafiles/murphy29.rag1rag2.fasta -n rax01
RAxML will output a bunch of files - we will examine the key ones in exercise 2.

exercise 2: inspect the final results of a run

Garli

Here are a few things that you wouldn't normally need to look at, but that might help understand how Garli tree search works:

We can examine how the topology and branch lengths changed over the entire run. The garli_run1.rep1.treelog00.tre file contains each successively better scoring topology encountered during the first search replicate. Note that this file can be interesting to look at, but in general will not be very useful to you. The default is for this file to not be created at all.

  • Open garli_run1.rep1.treelog00.tre in Figtree. (This will require transferring the file to your computer)
  • Click through all of the trees (using the arrows on the upper right).

    Note how the tree slowly changes over the run. We can also get other information from the treelog file.

  • Open the garli_run1.rep1.treelog00.tre file in a text editor.

    You will see a normal Nexus trees block. Each tree line includes comments in square brackets containing the lnL of that individual, the type of topological mutation that created it (mut = 1 is NNI, 2 and 4 are SPR, 8 and 16 are local SPR) and the model parameters of that individual. (The "M1" in the model string indicates that this is the first model.) For example:

    tree gen1= [&U] [-10286.10914 mut=8][ M1 r 1 4 1 1 4 e 0.25 0.25 0.25 0.25 a 0.922 p 0.394 ]

    If you scroll through and look at the mutation types, you will probably notice that a mix of all three topological mutation types were creating better trees early on, but the very local NNI mutations dominate at the end of the run. The model parameters that were associated with each tree during the run appear within a comment. They are specified with a simple code, and this model string is in exactly the same format that you would use to provide GARLI starting model parameter values. The parameter codes are:

    r = relative rate matrix 
    e = equilibrium frequencies 
    a = alpha shape parameter of gamma rate heterogeneity distribution 
    p = proportion of invariable sites 
    

The config files used here are set up to use a feature of the program that collapses internal branches that have an MLE length of zero. This may result in final trees that have polytomies. This is generally the behavior that one would want. Note that the likelihoods of the trees will be identical whether or not the branches are collapsed. However, this will affect Robinson Foulds distances!

Things that you should examine with your own analyses: (Garli and RAxML)

The information that you really want from the program are the best trees found in each search replicate and the globally best across all replicates. In Garli after each individual replicate finishes, the best trees from all of the replicates completed thus far are written to the .best.all.tre file. When all replicates have finished, the best tree across all replicates is written to the .best.tre file. In RAxML the best trees from the each replicate are saved to RAxML_result.rax01.RUN.0 and RAxML_result.rax01.RUN.1. and the best tree is saved to the RAxML.bestree. file.

  • Lets more closely examine our results.

  • First, take a look at the end of the Garli .screen.log file. You will see a report of the scores of the final tree from each search replicate, an indication of whether they are the same topology, and a table comparing the parameter values estimated on each final tree.

    For RAxML, examine the likelihoods for your two different tree searches at the end of your RAxML.info file.

    Within each of your analyses, are two possibilities:

    • The search replicates found the same best tree. You should see essentially identical lnL values and parameter estimates. The screen.log file should indicate that the trees are identical.
    • The search replicates found two different trees. This is almost certainly because one or both were trapped in local topological optima. You will notice that the lnL values are somewhat different and the parameter estimates will be similar but not identical. The search settings may influence whether searches are entrapped in local optima, but generally the default settings are appropriate.
Comparing outputs
  • HW 1 Did your two Garli replicates find the same tree?
  • HW 2 Did your two RAxML replicates find the same tree?
  • Transfer the best tree from each analysis to your computer, and open them using Figtree. (RAxML_bestTree.rax01 and garli_run1.best.tre)
  • Are the topologies the same? Are the branch lengths?

It isn't easy (or reasonable) to check by eye! And because of different choices made in the likelihood computation, the likelihoods are not directly comparable.

  • On the cluster, use the 'treecompare.py' script to compare the differences between the two ML tree estimates. This script relies on Dendropy, by Sukumaran and Holder to perform tree comparisons.
  • Check out the Robinson Foulds distances between the Garli and RAxML estimates using this "treecompare" script.
    First you will need to load the python modules for tree comparison using
    source /home/ejmctavish/courses/qsb244/venv-244/bin/activate
    python treecompare.py RAxML_bestTree.rax01 ‹treefile format› garli_run1.best.tre ‹treefile format›,
    (open the tree files in your text editor to figure out what the tree file formats are for these two trees. For a reminder about formats, see Tree formats and terms
  • HW 3 What are the RF and weighted RF distances between your two best tree estimates?

We can also more thoroughly evaluate and compare the results of our two different searches in PAUP*. Being able to open the results of one program in another for further analysis is a good skill to have.

PAUP* is a phylogenetics software package that can perfom many analyses, and is a gold standard for likelihood calculations. We will be using it later in the course for species tree inference using SVD quartets. For more PAUP experience, see, Holder/Lewis PAUP lab

  • In the MLSearchLab directory, execute the datafiles/murphy29.rag1rag2.nex file in PAUP*. (At the command line, type "paup datafiles/murphy29.rag1rag2.nex".)
  • Read your tree estimate from Garli into PAUP. To read the file into PAUP*, type "gettrees file=garli_run1.best.tre".)
  • Read your tree estimate from RAxML into PAUP. Using 'mode=7' will keep your tree from Garli in memory as well. To read the file into PAUP*, type "gettrees unrooted mode=7 file=RAxML_bestTree.rax01".)
  • Set your model of evolution to GTR+I+G in PAUP by running "lsc/nst=6 rmat=estimate basefreq=empirical shape=estimate rates=gamma pinv=est"
  • In PAUP*, score your two trees by running "lscore".

    This tells PAUP* to use the two trees you have imported but to optimize all the parameter values. After a bit you will see the optimized lnL score and parameter values for each tree as estimated by PAUP*.

  • How do the scores for the two trees compare with each other? (these scores were calculated in the same way, and are therefore directly comparable)
  • How do they compare to the likelihood estimates from Garli and RAxML?
  • HW 4 What are the likelihood scores for each tree?

    Since we've already loaded the trees into PAUP*, we can also use PAUP* to compare the two trees and see if they differ (and by how much).

  • In PAUP*, type "treedist".

    This will show what is termed the "Symmetric Tree Distance" between the trees. It is a measure of how similar they are, and is the number of branches that appear in only one of the trees. If the trees are identical, the distance will be zero. The maximal distance between two fully resolved trees is 2*(# sequences - 3).

    If the trees are different, we can calculate a consensus tree in PAUP* and see exactly where they agree. Note that in general you should choose the best scoring tree as your ML estimate instead of a consensus.

  • In PAUP*, type "contree /strict=yes majrule=yes LE50=yes".

    This will show a strict consensus and a majority rule consensus. The strict consensus completely collapses branches that conflict, but since GARLI already collapsed zero length branches it is hard to tell where the conflict is. The majority rule consensus will show 50% support for branches that were only found in one tree, but it is not possible to show them all in a single tree.

  • To quit paup type "quit".

exercise 3: constrain a search

If you looked carefully at any of the trees you've inferred (and know something about mammals), you may have noticed that the relationships are somewhat strange (and definitely wrong) in places. One relationship that this small data set apparently resolves correctly is the sister relationship of Whale and Hippo. This relationship (often termed the "Whippo" hypothesis) was once controversial, but is now fairly well accepted. If we are particularly interested in this relationship we might want to know how strongly the data support it. One way of doing this would be simply by looking at the bootstrap support for it, but we might be interested in a more rigorous hypothesis test such as a simulation based parametric bootstrap test, a Shimodaira-Hasegawa (SH) test or an Approximately Unbiased (AU) test.

The first step in applying one of the topological hypothesis tests is to find the best topology that does NOT contain the Whippo relationship. This is done by using a constrained topology search. In this case we want a negative (also called converse) constraint that searches through tree space while avoiding any tree that places Whale and Hippo as sisters.

It is possible to set positive constraints in RAxML, but it is not possible to set negative constraints, so this section we will only use GARLI. GARLI allows constraints to be specified in a number of ways. We will do it by specifying inputing a multifurcating tree, with only the bipartition being constrained.

  • Use a text editor to open a new text file.

    Constraints can either be positive (MUST be in the inferred tree) or converse (also called negative, CANNOT be in the inferred tree). The constraint type is specified to GARLI by putting a + or - at the start of the constraint string in the constraint file.

  • On the first line, type a '-' for a negative constraint, and then the string specifying the (Whale, Hippo) grouping -(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,22,23,24,25,26,27,28,29,(20,21)) Rather than having to count the lines in the input nexus file, you can look at your garli_run01.best.tre output from the previous exercise to see that Whale and Hippo are 20 and 21. Take a look at this constraint tree in Figtree.

  • Save the file as whippoNegative.txt.

    Now we need to tell GARLI to use the constraint. The garli_constrained.conf file has already been set up to be similar to the one we used during the unconstrained search earlier, so we only need to make minimal changes.

    Edit the garli_constraint.conf file and set constraintfile = whippoNegative.txt.
  • Set ofprefix = constrainedRun1.
  • Save the config file.
  • Run GARLI: garli garli_constrained.conf

Constrained searches can make searching through treespace more difficult (you can think of it as walls being erected in treespace that make getting from tree X to tree Y more difficult), so you may see that the two constrained search replicates result in very different lnL scores. When the run finishes, note the difference in lnL between the best tree that you found earlier and the best constrained tree. This difference is a measure of how strongly the data support the presence of the (Whale, Hippo) group relative to its absence.
HW 5 What is the difference in lnL between the constrained and unconstrained trees?
Unfortunately we can't simply do a likelihood ratio test here to test for the significance of the difference because we have no expectation for how this test statistic should be distributed under the null hypothesis. That is what the parametric bootstrap, SH or AU test would tell us, but is well beyond the scope of this demo.

exercise 4: bootstrap analyses

One way to check if your phylogenetic estimates are resilient to sampling error is to use bootstrapping, or re-sampling from your alignment and re-estimating your tree. This can be an important way to assess uncertainty due to data sampling. However! with large data sets, and any form of systematic error, you will get 100% even for the wrong relationships. THEREFORE: low bootstrap support may be a signal of unreliable relationships, but the converse is not true. High bootstrap support suggests that the inferred relationships are not sensitive to your data sampling (very common with genomic data), but not that they are correct!

  • In RAxML we can use the flags '-# ‹number of bootstrap replicates›', and '-b' ‹bootstrap random number seed›
    raxmlHPC -m GTRGAMMAI -p ‹choose a random number seed› -# 100 -b ‹bootstrap random number seed› -s datafiles/murphy29.rag1rag2.fasta -n rax_boot
    However, this will take too long to run! Kill this run using Ctrl-C.
  • A pre-baked bootstrap run is in the folder 'bootstrap_results'. We will use this one instead. We can then apply those bootstrap proportions to our best scoring tree from our first analysis, by using the '-f' flag to select an algorithim. We will use '-f b' to draw bipartition information on a tree, which we provide with the '-t' flag
    raxmlHPC -m GTRGAMMAI -p ‹choose a random number seed› -f b -t RAxML_bestTree.rax01 -z bootstrap_results/RAxML_bootstrap.rax_boot -n boot_bipart
  • Look at the file RAxML_bipartitions.boot_bipart You can open it in figtree - it will ask you what the labels represent. They represent bootstrap proportions. In the view menu on the left in figtree, set the node labels to display bootstrap proportions.
  • HW 6 What clade has the lowest bootstrap support (list two taxa for which that is the most recent common ancestor)?

    Other external program can also be used to map bootstrap replicates onto biparitions or estimate consensus trees. Good options are PAUP*, and a nice program called Sumtrees (it requires a Python installation, and is available at http://pythonhosted.org/DendroPy/programs/sumtrees.html).

Alternatively, can post-process our bootstrap results using PAUP*. These instructions are listed for your reference, but in the interest of time, skip this section for now.

  • Execute the datafiles/murphy29.rag1rag2.nex data in PAUP (type "paup datafiles/murphy29.rag1rag2.nex").
  • In PAUP*, clear any existing trees in memory using "cleartrees"
  • Load the bootstrap trees with the command "gettrees unrooted file=bootstrap_results/RAxML_bootstrap.rax_boot".
  • In PAUP*, make the majority rule consensus tree with the command "contree /strict=no majrule=yes LE50=yes grpfreq=no".

This will display the majority-rule bootstrap consensus tree, including branches appearing in less than 50% of the trees (LE50). You will notice that some parts of the tree are very poorly supported, while others have high support. It is somewhat comforting that the parts of the tree that we know are resolved incorrectly receive low support. This is precisely why phylogenetic estimates MUST be evaluated in light of some measure of confidence, be it bootstrap values or posterior probabilities.

exercise 5: Ascertainment bias and bootstrapping

Simulated data can be a great way to investigate model misspecification and biases. This exercise uses a data set simulated on a Felsenstein Zone tree. Data was simulated using seq-gen

  • Many datasets are enriched for variable sites, or include exclusively alignment columns with variable sites, i.e. Single nucleotide polymorphism (SNP) data. This is an example of 'ascertainment bias'. The data that you have 'ascertained' and included in your alignment are not a random subset of the genome. This does not include invariant sites, or sites at which repeated mutations have resulted in the same base at the tips (homoplasy).
  • Lets take a simulated data set that has not been subject to any ascertainment bias sim_noasc.phy, and estimate a tree:

    raxmlHPC -m GTRGAMMA -p 2 -s datafiles/sim_noasc.phy -n no_asc_bias

    Use the treecompare.py script to compare the best tree estimate to the true tree, the tree that the data was simulated on datafiles/sim.tre
    HW 7Did you get the correct tree?
  • Now lets run that same analysis on only the variable sites from that alignment, sim_variablesites.phy. This is the exact same alignment, but with the invariant columns removed.

    raxmlHPC -m GTRGAMMA -p 2 -s datafiles/sim_variablesites.phy -n asc_uncorrected

    HW 8Did you get the correct tree?
    How do the branch lengths differ from the true tree?
  • Lets bootstrap it!

    raxmlHPC -m GTRGAMMA -p 123 -# 100 -b 123 -s datafiles/sim_variablesites.phy -n asc_uncorr_boot

    raxmlHPC -m GTRGAMMA -f b -t RAxML_bestTree.asc_uncorrected -z RAxML_bootstrap.asc_uncorr_boot -n asc_uncorr_bipart

    HW 9What is the bootstrap support for the one bipartition in the tree? (You can open it in figtree, but with such a simple tree you can also just look at the text file directly)
    HW 10Is that bipartition in the true tree?
  • However, even if you only have the variable sites, by using an appropriate model of evolution, it is possible to rescue your analysis. In RAxML you can you a model corrected for ascertainment bias by using a model corrected for these known biases. We will use th ASC_GTRGAMMA model, with the lewis (as in Paul Lewis) correction for discarding sites that don't vary in the alignment.

    raxmlHPC -m ASC_GTRGAMMA --asc-corr lewis -p 2 -s datafiles/sim_variablesites.phy -n asc_corrected

    Did you get the correct tree?
  • Bootstrap it!

    raxmlHPC -m ASC_GTRGAMMA --asc-corr lewis -p 2 -# 100 -b 123 -s datafiles/sim_variablesites.phy -n asc_corr_boot

    raxmlHPC -m ASC_GTRGAMMA -f b -t RAxML_bestTree.asc_corrected -z RAxML_bootstrap.asc_corr_boot -n asc_corr_bipart

    HW 11What is the bootstrap support for the one bipartition in the tree?
    HW 12Is that bipartition in the true tree?

    This is the exact same dataset! If our model of evolution is not appropriate for our data, our results can be systematically biased. Incorrect inferences can have 100% bootstrap support, because sampling across our data does not capture the problem.
    NOTE: The ascertainment bias corrections in RAxML will not run if there are ANY invariant columns in your alignment.


EXERCISE FOR CLASS ENDS HERE! Continue if you feel like it.

exercise 7: use a custom amino acid model

In addition to nucleotide-based analyses, we can analyze protein-coding genes at the amino acid level. We might prefer this to nucleotide analyses under certain conditions, particularly when our sequences are quite dissimilar and silent substitutions at the third codon position are saturated. Unlike nucleotide models, the amino acid models also implicitly take into account how well particular amino acids can substitute for one other in proteins. However, by ignoring silent substitutions amino acid models do throw out information that may be informative at some level, and that has the potential to worsen phylogenetic estimates.

Garli One handy feature of GARLI is that it can do the translation from nucleotide to amino acid sequences internally. So, you can use the same alignment file as input for nucleotide, amino acid and codon analyses and only make changes in the config file. Note that version 2.0 of the program allows three genetic codes: the standard code, the vertebrate mitochondrial code and the invertebrate mitochondrial code.

As with nucleotide analyses, the first step is to choose a model. The program Prottest is similar to Modeltest, and does a good job of this. One unfortunate fact is that Prottest does require an amino acid alignment, so a nucleotide alignment will have to be translated first. The program is available at: http://darwin.uvigo.es/software/Prottest.html

Note that GARLI does not yet implement many of the models considered by Prottest. In this case I already ran Prottest on this dataset, and the model it chose is what is usually termed the Jones or JTT model (Jones, Taylor and Thornton, 1992), with gamma rate heterogeneity. You can look at the Prottest output in the Prottest directory if you like.

However, to make things more interesting, we will be using an altogether different model, one that GARLI does not implement internally. This is the "LG" model (from Le and Gasquel, 2008), and will give us an example of how model parameter values can be passed to GARLI, rather than having it estimate them. The procedure is the same regardless of whether the model is at the nucleotide, amino acid or codon level.

Set up the config file:
  • In the 08.customAA directory, open the garli.conf file
  • Change the datatype from “dna” to “codon-aminoacid” (codon-aminoacid tells GARLI to do the codon to amino acid translation internally. datatype = aminoacid should be used for actual amino acid alignments)
  • Change both the ratematrix and statefrequencies settings to fixed. This tells GARLI that the values of those parameters will be provided to it from file and should not be estimated.
  • Set invariantsites = none
  • Change ofprefix to AARun1
  • Set streefname = LGmodel.mod. This file is already in the 08.customAA directory, and contains all of the parameter values of the LG model in a format that GARLI can use. It is rather scary looking, so don't worry about the details.
  • Save the file
  • Start GARLI

You will notice that the amino acid analysis runs significantly slower than the nucleotide one, so the config file is set to only do a single search replicate. Once the run finishes (approx. 10-15 min. on a slow machine) you can use Figtree to visually compare the trees from the nucleotide and amino acid analyses, or use PAUP for more quantitative comparisons. You will notice that the two types of analyses give very different results. In this case the nucleotide results are much more reasonable. You will also notice that the amino acid data do not support the Whippo relationship.

RAxML

exercise 9: use a codon model

Codon-based analyses are very, very slow. We won't do a complete search here, but will set up a configuration file for one and start it to get a feel for the speed. We'll tell GARLI to use a model more or less equivalent to the Goldman-Yang 1994 model.

In the 09.basicCodon directory, edit the configuration file. Some of it is already set up for this data set. We only need to set the details of the codon model.
  • Set datatype = codon
  • Set ratematrix = 2rate
  • Set statefrequencies = f3x4
  • Set ratehetmodel = none
  • Set numratecats = 1
  • Set invariantsites = none
  • Save the file, start GARLI.
  • You'll quickly notice that the codon-based analysis is very slow, and you can kill it by typing ctrl-C.

    exercise 10: use gap (insertion-deletion) models

    GARLI implements two models appropriate for incorporating gap information into analyses of fixed alignments. These are the "DIMM" model (Dollo Indel Mixture Model) and a variant of the Mkv or "morphology" model. Both decompose an aligned matrix into two: one that contains normal sequence data, and the other that encodes only the gaps as 0/1 characters. The two matrices are then analyzed under a partitioned model. The DNA portion is treated normally, while the 0/1 matrix is treated differently under the two models:

    • The DIMM model assumes a very strict definition of homology of gap characters, and does not allow multiple insertions within a single alignment column. This also implies a "dollo" assumption, meaning that after a base is deleted another cannot be inserted in the same column. This also means that it infers rooted trees. The DIMM model extracts very strong signal from the gap information, but also ends up being VERY strongly affected by alignment error.
    • The Mkv gap variant works on columns of 0/1 characters, but assumes that columns of entirely 0 (fully gap columns) will not be seen. This model DOES allow multiple transitions back and forth between 0 and 1 (gap and base). It does not extract as much information as DIMM, but is also not as sensitive to alignment error.
    Preparing the data:

    To use the DIMM or Mkv gap models we first need to create a "gap coded" matrix that is just a direct copy of the DNA matrix with gaps as "0" and bases as "1". This is done with an external program called "gapcode". Scripts are provided to format nexus or fasta datasets for you, and to start the analyses. For the demo the dataset we'll use is called forTutorial.nex.

    • Format data for gap analysis: From the command line in the 10.gapModels/gapModels or 10.gapModels/gapModels-Win directory, type ./prepareNexusData.sh forTutorial.nex or prepareNexusData.bat forTutorial.nex
    • This will create some alignments in the preparedData directory. (These files are actually already there in the demo package, in case you have difficulty running gapcode.)
    • You can also use these same scripts to prepare your own nexus or fasta alignment.
    Running GARLI gap models:

    Now we run the DIMM and Mkv gap analyses by using other scripts:

    • type ./runGarli.dna+gapModels.sh or runGarli.dna+gapModels.bat
    • This will do several GARLI searches on the same data. First a quick run will be done to generate starting trees for the other analyses. Then DNA only searches will be run, as well as the DIMM and Mkv gap model searches.
    • The runs will create output that you can look at in the garliOutput directory. Looking at the XXX.screen.log files will tell you about the details of the run and parameter estimates. The XXX.best.tre files contain the best trees found in each search.
    • Note that the DIMM model indicates its inferred root by adding a dummy outgroup taxon named ROOT in the tree files. On OS X and Linux the prepareData scripts will create alignment files containing this taxon in the preparedData directory. I haven't managed to automate this on Windows.
    • If you use the above prepareData scripts on your own dataset, these runGarli scripts should also work properly to automatically analyze your data.

    exercise 11: further exercises

    If you have your own data set of interest, now would be a good time to give it a try in GARLI. You can use the config file in the basicNucleotide directory as a template.

    You might also try doing a constrained amino acid search that forces Whale and Hippo to be sister, since they are not sister in the ML amino acid tree. You can use the same constraint file as before, simply change the "-" at the start of the constraint string to a "+" to denote that it is a positive constraint. Comparing the likelihood of the constrained and unconstrained amino acid trees will give a measure of the support of the amino acid data against the Whippo hypothesis.

    -->