Part II · Module 11 · IQ-TREE 3

Gene-tree inference with IQ-TREE 3

Infer one maximum-likelihood tree for each UCE locus. These locus trees preserve gene-tree heterogeneity and will be used as input for species-tree inference in the next module.

Objective

Return to the locus-by-locus UCE alignments selected in Module 09 and infer an independent maximum-likelihood tree for every retained locus using IQ-TREE 3.

Do not use the AMAS supermatrix here

The concatenated matrix from Module 10 is used only for the concatenated analysis. Gene-tree inference must start from the individual UCE alignments so each locus retains its own evolutionary history.

1. Activate the phylogeny environment

conda activate uce-phylogeny

Confirm the IQ-TREE 3 version:

iqtree3 --version

This tutorial uses IQ-TREE 3.1.4.

2. Select the locus dataset

Use the same occupancy-filtered locus set used for the corresponding concatenated analysis. Here, the 75% matrix is shown only as an example.

PROJECT="/path/to/my_UCE_project"

DATASET="$PROJECT/taxon-sets/all"
ALIGNMENTS="$DATASET/mafft-nexus-75p"

GENETREES="$DATASET/gene-trees-75p"
mkdir -p "$GENETREES"
Keep analyses comparable

If the concatenated analysis used the 95% dataset, use the same 95% locus set here. If you analyze multiple occupancy matrices, infer a separate set of gene trees for each matrix.

3. Confirm the input loci

Count the alignments:

find "$ALIGNMENTS" \
  -maxdepth 1 \
  -name "*.nexus" \
  | wc -l

Inspect a few files:

find "$ALIGNMENTS" \
  -maxdepth 1 \
  -name "*.nexus" \
  | sort \
  | head

4. Infer one tree per locus

IQ-TREE 3 provides -S specifically for separate locus-tree inference. When a directory is supplied, IQ-TREE loads all alignments in that directory, performs model selection separately for each alignment, and infers one tree per locus.

iqtree3 \
  -S "$ALIGNMENTS" \
  -T AUTO \
  --seed 12345 \
  --prefix "$GENETREES/uce75_loci"
-S
Treats each alignment as a separate locus and infers an independent tree for each locus.
-T AUTO
Lets IQ-TREE determine an efficient number of CPU threads.
--seed 12345
Uses an explicit random seed for reproducibility.
--prefix
Places all locus-tree outputs under a consistent analysis prefix.
Model selection is locus-specific

With -S, IQ-TREE performs ModelFinder and tree inference separately for each locus. Different UCE loci can therefore receive different substitution models.

5. Why not concatenate first?

A concatenated analysis estimates a single topology from the combined sequence matrix. Gene-tree analysis instead estimates a topology independently for each UCE. This preserves discordance among loci, which can arise from incomplete lineage sorting, limited phylogenetic information, estimation error, introgression or other processes.

The species-tree analysis in the next module uses this collection of independent locus trees rather than the concatenated supermatrix.

6. Main output

The key file is the combined locus-tree file:

gene-trees-75p/
├── uce75_loci.treefile
├── uce75_loci.iqtree
├── uce75_loci.log
└── ...

uce75_loci.treefile contains one Newick tree per locus. This is the principal input for summary species-tree programs such as ASTER/ASTRAL.

7. Count the inferred gene trees

Each non-empty line in the combined .treefile represents one locus tree.

GENE_TREE_FILE="$GENETREES/uce75_loci.treefile"

grep -cve '^[[:space:]]*$' "$GENE_TREE_FILE"

Compare this count with the number of input alignments. Differences should be investigated in the IQ-TREE log.

8. Inspect several locus trees

head -5 "$GENE_TREE_FILE"

Gene trees can differ substantially in topology and taxon representation because individual UCE loci differ in occupancy and phylogenetic information.

Low information is expected for some UCE loci

Individual UCE alignments are much shorter than the concatenated supermatrix. Some loci may therefore contain few informative sites and produce weakly resolved gene trees. This is one reason to interpret species-tree results together with gene-tree support and concordance measures.

9. Should every locus receive bootstrap analysis?

Not necessarily. For the primary species-tree workflow presented here, the maximum- likelihood tree inferred for each locus is sufficient as input to a summary species- tree method.

Bootstrap analyses for thousands of individual loci can be computationally expensive and are not required simply to generate the gene-tree set. They can be added when locus-level support itself is a specific analytical objective.

10. Keep taxon names unchanged

Species-tree methods identify taxa by the labels present at the tips of the gene trees. Do not rename samples between alignment, gene-tree and species-tree stages unless the change is performed consistently across the entire dataset.

11. Expected workflow

Occupancy-filtered UCE alignments
    ↓
IQ-TREE 3 -S
    ↓
Independent ML tree for each UCE locus
    ↓
Combined locus tree file
    ↓
ASTER / ASTRAL species-tree inference

12. Pre-flight check

✓ The intended occupancy-filtered locus set was selected.
✓ Individual UCE alignments, not the AMAS supermatrix, were used as input.
✓ IQ-TREE 3 was run with -S on the alignment directory.
✓ Model selection and tree inference were performed independently for each locus.
✓ The combined .treefile contains one tree per successfully analyzed locus.
✓ The number of inferred trees was compared with the number of input loci.
✓ Sample names remain consistent across all gene trees.
✓ Logs were retained for loci that failed or generated warnings.

References and official documentation

IQ-TREE 3 — Inferring gene/locus trees

IQ-TREE — Command reference

IQ-TREE 3 — Official releases

IQ-TREE 3 feature used here

The -S option accepts either a partition definition or a directory of alignments. With a directory, IQ-TREE 3 performs model selection and phylogenetic inference separately for every alignment and writes the inferred locus trees to a combined .treefile.

← Concatenated phylogenetic inference Next: Species-tree inference →