Tutorial - Maximum Likelihood in IQ-TREE
Introduction
IQ-TREE is a fast and effective software to infer phylogenetic trees by maximum likelihood (ML). To learn more about IQ-TREE see https://iqtree.github.io/. I prepared this tutorial with the goal of obtaining ML trees and used them as inputs for species delimitation analyses. We need to perform single-locus species delimitation analysis using mitochondrial and nuclear genes to evaluate whether cryptic species are present in our global amphibian dataset.
Getting started
IQ-TREE can run in Windows, Mac, and Linux machines. It can be downloaded from here: https://iqtree.github.io/#download. There is a web server to run the program http://iqtree.cibiv.univie.ac.at/, however I recommend run IQ-TREE in the Terminal or Command Prompt, because we can see and choose all the parameters more easily, and because I never used the web server before and I don’t know how it works! (But you can explore the web server if you want).
Once the program is installed you can run it with a few command lines.
For Windows users:
Open a Command Prompt window typing “cmd” and then press “Enter”.
Go into the recently extracted IQ-TREE folder by entering:
cd MyPrograms\iqtree_Windows
Then we can try to run an analysis in IQ-TREE using our alignment in FASTA (.fas), PHYLIP (.phy), or NEXUS (.nex) format.
Note: Before running the phylogenetic analyses, we can save our FASTA alignments in PHYLIP and NEXUS. We can use AliView (https://ormbunkar.se/aliview/) to do this change of format.
bin\iqtree -s MyAlignment.phy
For Mac users:
Open the Terminal.
Go into IQ-TREE folder by entering (assuming you downloaded version 2.2.0):
cd MyPrograms/iqtree-2.2.0-MacOSX
After this you can run the same step 3 as for Windows users.
For Linux users:
Open the Terminal. In Linux/Ubuntu, the default terminal application is known as the GNOME Terminal.
Go into the IQ-TREE/bin folder by entering:
cd MyPrograms/iqtree-2.2.0-Linux/binRun a simple test analysis
./iqtree2 -s MyAlignment.phy
Running example for single-locus alignment
We need to run IQ-TREE for our species, genus or family alignment (depending of the number of sequences) for each gene separately. Note that it is assumed that iqtree executable was already copied into system search path. If not, please replace iqtree with actual path to executable.
This time, we will use other parameters in addition to the input alignment.
iqtree -s MyAlignment.phy -m TEST -bb 1000 -nt AUTOThe options used are:
-s Input alignment in PHYLIP, FASTA or NEXUS format. In the example the alignment is in PHYLIP (.phy)
-m TEST. Standard model selection using ModelFinder.
-bb 1000. Ultrafast bootstrap (UFBoot) it should be >=1000. Used to assess the statistical support for branches in a maximum likelihood phylogenetic tree.
nt AUTO. Number of cores/threads. We used AUTO for automatic detection on our own computer.
Visualizing and saving the phylogenetic tree
IQ-TREE give us several files after run it. For example, two of the outputs are the .contree and .treefile that are basically the same tree file in Newick format (a parenthetical notation used to represent rooted or unrooted phylogenetic trees with optional edge lengths).
We will use the .contree file as input to visualize our tree. For this we can use the Figtree software that can be downloaded here https://github.com/rambaut/figtree/releases.
Once Figtree is downloaded, we can open the .contree file and rooted with the midpoint option. Midpoint rooting has several assumptions that are important to mention. This rooting option assumes that substitution rates are some similar across the tree. In practice, this is not 100% true if we have several species in our tree, but can be commonly used when 1) we do not have a known outgroup available (as will be in most of our cases here); and 2) the dataset contains closely related taxa (as in our case).
Using this rooting method is common in single-locus datasets (e.g., COI, ND2) used for exploratory species delimitation.
After rooting the tree, we need to save it in Newick format to use it as input for species delimitation analysis (e.g., mptp).
Another way to visualize the unrooted tree and rooted with the midpoint method is using the ape and phytools packages in R.
library(ape)
library(phytools)
#visualize tree
my.tree <- read.tree("/path/to/my/unrooted/iqtree/.contree")
plotTree(my.tree, fsize = 0.7)#The tree is unrooted, we can rooted by entering:
my.tree_rooted <- midpoint.root(my.tree)
plotTree(my.tree_rooted, fsize = 0.7)
#Then we can save our tree in Newick format for further analysis.
write.tree(my.tree_rooted, "my.tree_rooted.tre")Following this tutorial we will obtain a decent ML phylogenetic tree that will be used for single-locus species delimitation analyses.