Back to Blog
PhylogeneticsMSA

Install MAFFT and IQ-TREE for Phylogenetics (macOS, conda)

Install MAFFT and IQ-TREE 2 in one conda env, align a gene family, then infer a maximum-likelihood tree with ModelFinder and ultrafast bootstrap.

SSSudipta SardarJuly 20, 20269 min read
Install MAFFT and IQ-TREE for Phylogenetics (macOS, conda)

Every phylogenetics project starts with the same two questions: how do these sequences line up, and what tree best explains that alignment? MAFFT answers the first with fast, accurate multiple sequence alignment, and IQ-TREE answers the second with maximum-likelihood tree inference plus automatic model selection. Together they form a minimal but genuinely publication-capable phylogenetics bench, and both install cleanly from bioconda in a couple of minutes.

This guide sets up a single conda environment with both tools, verifies each one, and walks through a real small alignment-to-tree run so you can see what a healthy result looks like before you point these tools at your own data.

Prerequisites

You need a working conda on your Mac. If you do not have one yet, start with our Miniconda on Apple Silicon guide (or the Anaconda on macOS guide if you prefer the full distribution) and come back here. This walkthrough assumes an Apple Silicon Mac (arm64) with a recent conda and the libmamba solver.

We install only from conda-forge and bioconda, with --override-channels so conda never falls back to the Anaconda defaults channel. Recent conda versions gate defaults behind a Terms-of-Service prompt, and skipping it entirely avoids that error altogether. If you want the background on why channel order matters, see Conda environments and Bioconda channels.

TL;DR: copy-paste install

bash
conda create -n bu-phylo --override-channels -c conda-forge -c bioconda mafft iqtree
conda activate bu-phylo
mafft --version
iqtree2 --version

That is the whole install. The rest of this guide walks through each step, a real alignment-to-tree run, and the gotchas worth knowing before you trust the output.

Step 1: Create an isolated environment

We name the environment bu-phylo and ask bioconda for both packages in one solve, so conda picks mutually compatible builds. conda-forge is listed first for priority, and bioconda supplies the two phylogenetics packages.

bash
conda create -n bu-phylo --override-channels -c conda-forge -c bioconda mafft iqtree

Conda will resolve dependencies (mostly small C/C++ runtime libraries) and print an install plan before downloading. Once it finishes, activate the environment — you need to do this in every new shell:

bash
conda activate bu-phylo

The bioconda package is named iqtree, but the binary it installs is iqtree2 — this is IQ-TREE 2, a full C++ rewrite of the original IQ-TREE with a very different feature set and command syntax. There is also an iqtree3 package and binary further along the bioconda pipeline for IQ-TREE 3, the newest major version. This guide covers IQ-TREE 2, which is still the most widely used and cited version in published phylogenetics work. If a script or paper says iqtree with no version suffix, check which major version they actually mean before assuming compatibility.

Apple Silicon note

Both MAFFT and IQ-TREE ship native osx-arm64 builds on bioconda, so on an Apple Silicon Mac you get compiled binaries running directly on the chip rather than under Rosetta 2 emulation. Confirm this after activating the environment:

bash
conda list -n bu-phylo mafft iqtree
file $(which iqtree2)

The channel/build string should show bioconda/osx-arm64, and file should report an arm64 Mach-O binary. If you ever need an x86-64 fallback for a tool without a native build, the pattern is a separate environment pinned with CONDA_SUBDIR=osx-64, but neither MAFFT nor IQ-TREE needs that here.

Step 2: Verify the install

Check both tools report a version and that they resolve from inside the environment, not some stray system copy:

bash
which mafft iqtree2
mafft --version
iqtree2 --version

mafft --version prints a short version string to stderr (this is normal MAFFT behavior, not an error), and iqtree2 --version prints a longer banner with the build date and citation information. If either command returns command not found, you forgot to conda activate bu-phylo in this shell.

Step 3: Align, then build a tree

This is the real two-command workflow: align a set of homologous sequences with MAFFT, then feed that alignment straight into IQ-TREE. Start with a small toy FASTA of a few related protein sequences — in practice these would come from a BLAST search or an OrthoDB/Pfam family (see Installing BLAST locally if you need to gather homologs first).

bash
mkdir -p /tmp/phylo_smoke && cd /tmp/phylo_smoke
cat > seqs.fasta << 'EOF'
>seqA
MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQAPILSRVGDGTQDNLSGAEKAVQVKV
>seqB
MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQAPILSRVGDGTQDNLSGAEKAVQVKV
>seqC
MKTAYIAKQRQISFVKSHFNRQLEERLGLVEVQAPILSRVGDGTQDNLSGPEKAVQVKV
>seqD
MKSAYIAKQRQISFVKSHFSRQLEERLGLIEVQAPILSRVGDGTQDNLSGAEKAVQIKV
EOF
mafft --auto seqs.fasta > aln.fasta

--auto tells MAFFT to pick an appropriate alignment strategy based on the number and length of your sequences — for a handful of short sequences like this it typically falls back to progressive alignment (FFT-NS-2 or similar), while larger or more divergent sets get iterative refinement. For real datasets this is almost always the flag you want; only reach for the manual strategy flags (--localpair, --globalpair, --maxiterate) once you understand your data's specific alignment needs.

With an alignment in hand, run IQ-TREE 2 with ModelFinder and the ultrafast bootstrap:

bash
iqtree2 -s aln.fasta -m MFP -bb 1000
  • -s aln.fasta is the input alignment.
  • -m MFP runs ModelFinder Plus: IQ-TREE tests a large panel of substitution models against your alignment and picks the best one by BIC before building the tree, rather than you guessing a model up front.
  • -bb 1000 requests 1000 ultrafast bootstrap replicates. This is the practical minimum IQ-TREE enforces — passing a smaller number produces an error telling you to raise it — and 1000 is the standard value reported in most papers.

You should see something like this on the console as it runs:

text
Checking data properties...
ModelFinder
Testing models...
Best-fit model: JTT+G4 chosen according to BIC
...
Analysis results written to:
  IQ-TREE report:                aln.fasta.iqtree
  Maximum-likelihood tree:       aln.fasta.treefile
  Ultrafast bootstrap tree:      aln.fasta.contree

The file you actually want is aln.fasta.treefile (the best ML tree in Newick format) or aln.fasta.contree (the same topology with ultrafast bootstrap support values as node labels). Open aln.fasta.iqtree in a text editor first — it is a full human-readable report with the chosen model, log-likelihood, and a summary of the tree, which is the fastest way to sanity-check a run before visualizing anything.

Ultrafast bootstrap (-bb) values are not the same statistic as classic Felsenstein bootstrap (-b) values, even though both are reported on a 0-100 scale. Ultrafast bootstrap tends to run less conservative and support values above roughly 95 are usually interpreted as strong support, compared to the traditional 70 threshold often used for standard bootstrap. Do not directly compare the two numbers across papers that used different methods.

Reading the output: a quick reference

FileWhat it is
aln.fasta.iqtreeFull text report: chosen model, log-likelihood, run parameters
aln.fasta.treefileBest maximum-likelihood tree, Newick format, no support values
aln.fasta.contreeConsensus tree with ultrafast bootstrap support at each node
aln.fasta.logFull run log, useful for debugging a failed or killed run
aln.fasta.model.gzCached ModelFinder results, so a rerun skips model testing

Common errors and fixes

ErrorFix
command not found: iqtree2The bioconda package is iqtree but the binary is iqtree2. Also confirm you activated bu-phylo.
CondaToSNonInteractiveError during installDo not use the defaults channel. Install with --override-channels -c conda-forge -c bioconda as shown.
ERROR: Number of bootstrap replicates must be >= 1000The ultrafast bootstrap minimum is enforced by IQ-TREE. Use -bb 1000 or higher.
Tree looks like a star (no resolved internal branches)Usually too few informative sites. Check aln.fasta.iqtree for the number of parsimony-informative sites, and confirm your alignment isn't dominated by gaps.
MAFFT alignment has huge gap columnsYour input sequences may not be truly homologous, or one sequence is a fragment. Trim or remove outlier sequences and realign.
iqtree2 runs but only uses one CPU corePass -nt AUTO to let IQ-TREE detect and use available cores, or -nt 4 to pin a specific count.

Managing the environment

Update both tools in place:

bash
conda update -n bu-phylo --override-channels -c conda-forge -c bioconda mafft iqtree

Snapshot the exact environment so a collaborator can reproduce it:

bash
conda env export -n bu-phylo > phylo-env.yml

And when you are done, remove it cleanly:

bash
conda remove -n bu-phylo --all

Next steps

You now have a working alignment-and-tree pipeline. A few natural follow-ons: