Skip to main content

Module M04: Phylogenetic Tree Inference & Time-Calibration

M04 builds the core evolutionary framework for the pipeline. It executes two sequential steps:
  1. ML tree inference (augur tree → IQ-TREE2): Infers the maximum-likelihood topology from the aligned sequences.
  2. Time-tree calibration (augur refine → TreeTime): Fits a strict molecular clock model to the ML topology, using sample collection dates from the enriched metadata to root and time-scale the tree.
The output time-tree (tree.nwk) and branch-length node data (branch_lengths.json) propagate downstream to M05 (HyPhy — requires a pruned tree), M06 (ancestral reconstruction), and ultimately M07 (Bridge Builder, which uses per-branch mutation mapping from M06).

Input Requirements

Configuration Parameters

Reference Clock Rates by Pathogen

clock_rate is the single most sensitive parameter in the pipeline. Incorrect values cause augur refine to fail with negative branch lengths or produce a tree with implausible root date. Consult current Nextstrain builds for your target pathogen/segment before setting this value.

Processing Stages

Stage 1 — ML Tree Inference (augur_tree)

Tool: IQ-TREE2 (called internally by augur tree)
augur tree wraps IQ-TREE2 and automatically selects the GTR+G substitution model (the standard for viral nucleotide alignments). The raw Newick output (tree_raw.nwk) is an unrooted, uncalibrated maximum-likelihood topology. IQ-TREE2 model selection note: IQ-TREE2 supports ModelFinder (-m TEST) for automatic model selection, but augur tree uses GTR+G by default for speed. For publication-grade analyses, consider running IQ-TREE2 directly with -m MFP and supplying the resulting tree to augur refine.

Stage 2 — Time-Tree Calibration (augur_refine)

Tool: TreeTime (called internally by augur refine)
Key flags: TreeTime algorithm overview:
TreeTime performs a regression of root-to-tip divergence against sample collection dates. For each taxon, it expects a linear relationship between evolutionary distance from the root and collection date. Outlier sequences (those that violate the clock model beyond clock_std_dev tolerance) are flagged in the output logs with Pruned outliers:.

Outputs

Reading the Branch Lengths JSON

numdate is the decimal year (2024.673 ≈ 2 September 2024). clock_length is the branch length in time units; mutation_length is the raw ML branch length.

Conda Environment

Key packages: augur, iqtree, treetime

Debugging Clock Failures

Symptom: augur refine exits with ERROR: Negative branch length detected. Diagnosis steps:
Resolution: If root-to-tip regression fails, try incrementally adjusting clock_std_dev upward (e.g., to 0.001) or removing sequences identified as outliers by augur clock-filter.

Known Limitations & Edge Cases

  • Polytomies warning is normal: The --stochastic-resolve flag produces a “Polytomies resolved stochastically” warning when sequences share identical sequence content. This is expected and does not indicate an error.
  • Protein phylogenetics (deferred): M04 currently only builds a nucleotide-level phylogeny. Protein-level phylogenetic inference (using WAG/LG substitution models for antigen/vaccine strain selection) is planned for a future phase when serological objectives are in scope.
  • Large dataset memory: IQ-TREE2 tree inference for >3,000 sequences requires approximately 16–32 GB RAM. If the system runs out of memory, reduce max_sequences in M02 config.
  • Reassortment (Influenza): Influenza A evolves primarily via reassortment (whole-segment exchange), not intra-segment recombination. The single-segment phylogeny built by M04 represents the evolutionary history of that segment only. Distinct segment-level trees are expected to have different topologies, which is biologically correct.