โ† Wiki Index / Genetics & Evolution / Subtree Pruning and Regrafting
๐Ÿงฌ Genetics & Evolution

Subtree Pruning and Regrafting

Subtree Pruning and Regrafting is a global phylogenetic tree rearrangement operator that detaches a clade and reinserts it across distant branches, enabling maximum-likelihood searches to escape local optima.

Subtree Pruning and Regrafting (SPR) is a global topological rearrangement operation used in phylogenetics to search the combinatorial space of evolutionary trees under maximum-likelihood phylogenetics, Bayesian inference, and maximum parsimony criteria. Whereas a Nearest-Neighbor Interchange (NNI) move is restricted to swapping adjacent subtrees across a single internal branch, an SPR operation detaches ("prunes") a subtree from its current position in an unrooted or rooted binary tree and reattaches ("regrafts") that subtree by subdividing any remaining branch of the residual tree.

Specifically, an unrooted SPR move proceeds in three topological steps:

  1. Pruning: Select any branch e of an unrooted binary tree ฯ„ and sever it, partitioning ฯ„ into two disconnected subtrees, Tprune (the pruned clade, rooted at the cut endpoint vp) and Trem (the remaining backbone tree).
  2. Suppression of the Degree-2 Node: In the residual backbone tree Trem, the internal vertex v0 from which Tprune was detached now has degree 2; suppressing vertex v0 merges its two incident edges e1 and e2 into a single continuous branch e12 of initial length t1 + t2.
  3. Regrafting: Select any target branch etarget โ‰  e12 anywhere in the residual backbone tree Trem, insert a new internal vertex vnew that splits etarget into two sub-branches, and attach the root vp of the pruned subtree Tprune to vnew via the reconnected branch e.

Because an SPR move can transport a misplaced taxon or clade across an arbitrary number of intervening nodes in a single step, SPR searches smoothly traverse low-likelihood valleys that trap local NNI hill-climbers.

Combinatorics of the SPR Neighborhood and Relation to NNI and TBR

Size of the 1-Step Unrooted SPR Neighborhood

Consider an unrooted binary tree ฯ„ with N terminal taxa, which contains 2N โˆ’ 3 total branches (N terminal tip branches and N โˆ’ 3 internal branches) and N โˆ’ 2 internal vertices. In a 1-step SPR neighborhood, every possible pruned subtree Tprune can be reattached onto any branch of the remaining backbone tree Trem except the merged branch e12 from which it was just detached.

Summing over all 2(2N โˆ’ 3) directed branch cuts and subtracting the redundant moves that regenerate the starting topology ฯ„ or duplicate identical 1-edge swaps (as derived by Allen and Steel in 2001), the number of distinct unrooted binary trees within a 1-step SPR move of ฯ„ is:

|NSPR(ฯ„)| = 2(N โˆ’ 3)(2N โˆ’ 7)

Notice that when the target branch etarget selected for regrafting is adjacent to the original attachment branch e12 (separated by only one internal node along the tree backbone), the SPR move reduces to a Nearest-Neighbor Interchange (NNI). Subtracting the 2(N โˆ’ 3) NNI moves from the total SPR count leaves 4(N โˆ’ 3)(N โˆ’ 4) non-NNI long-range SPR moves.

Hierarchy of Rearrangement Operators: NNI โŠ‚ SPR โŠ‚ TBR

Phylogenetic tree rearrangement operators form a nested inclusion hierarchy of neighborhoods around any tree ฯ„0:

NNNI(ฯ„0) โŠ‚ NSPR(ฯ„0) โŠ‚ NTBR(ฯ„0)

The broadest operator in this hierarchy is Tree Bisection and Reconnection (TBR): after severing an internal branch e to split the tree into two subtrees T1 and T2 (and suppressing the resulting degree-2 vertices in both T1 and T2), TBR allows the reconnection branch to join any branch of T1 to any branch of T2 (re-rooting Tprune before regrafting it). While TBR explores O(N3) neighbors per sweep, its size depends on the balance of the starting topology (ranging from ฮ˜(N2) on a caterpillar tree to ฮ˜(N3) on a balanced tree), whereas the SPR neighborhood size 2(N โˆ’ 3)(2N โˆ’ 7) is a topological invariant independent of tree shape.

Rearrangement OperatorNeighborhood Size for N TaxaNeighbors at N = 50 TaxaRe-Roots Pruned Subtree?Primary Algorithmic Role
Nearest-Neighbor Interchange (NNI)2(N โˆ’ 3)94No (radius r = 1 node)Ultra-fast local refinement and SH-aLRT support
Radius-Constrained SPR (r-SPR)O(N ยท 2r)~500โ€“1,200 (for r = 4)No (radius โ‰ค r nodes)Fast intermediate search in RAxML and BioNJ+SPR
Full Unrooted SPR2(N โˆ’ 3)(2N โˆ’ 7)8,742No (attaches at cut root vp)Standard global topology search in PhyML and RAxML
Tree Bisection & Reconnection (TBR)O(N3) [shape-dependent]~65,000โ€“110,000Yes (reconnects any pair of edges)Intensive small-to-medium parsimony/ML searches

Lazy SPR and Radius-Constrained Heuristics in Maximum Likelihood

The Computational Bottleneck of Naively Evaluating O(N2) SPR Moves

Evaluating a full alignment log-likelihood from scratch via Felsenstein's tree-pruning algorithm requires O(N ยท Lu ยท A2) operations. If a naive SPR implementation evaluated all O(N2) candidate trees in NSPR(ฯ„) from scratch and optimized all 2N โˆ’ 3 branch lengths on each candidate, a single SPR sweep would require O(N3 ยท Lu ยท A2) timeโ€”prohibitively slow for trees with N > 100 taxa.

To make SPR tractable for thousands of taxa, Alexandros Stamatakis (RAxML, 2006) and Stรฉphane Guindon and Olivier Gascuel (PhyML 3.0, 2010) developed three algorithmic optimizations:

  1. Incremental Conditional Likelihood Updating along the Migration Path: When a pruned subtree Tprune is detached from node v0 and regrafted onto a target branch at distance d nodes away along the backbone tree Trem, the conditional likelihood vectors Lu(s) inside Tprune and inside all clades lying off the path between v0 and vnew remain unchanged. Only the d โˆ’ 1 internal nodes along the migration path between the old attachment point and the new insertion point require updated partial likelihood vectors. By sliding the insertion point step-by-step outward from v0 via depth-first traversal of Trem, each candidate regrafting site can be visited in O(1) amortized node updates per site pattern.
  2. Lazy Subtree Rearrangement (Fast Local Insertion Filtering): When testing a candidate regrafting branch etarget, RAxML and PhyML do not optimize all branch lengths of the tree. Instead, they perform a Lazy SPR check: only the three branches incident to the new insertion node vnew (or the new split lengths on etarget and the connecting branch e) are optimized via 1 to 3 Newton-Raphson steps while holding all other branch lengths fixed. Candidate moves whose fast lazy score falls substantially below the current best log-likelihood โ„“0 are discarded, and only the top-scoring candidate topologies undergo full multi-branch optimization.
  3. Adaptive Rearrangement Radius (r-SPR): Most likelihood-improving SPR moves transport a pruned subtree across a moderate topological distance (typically r = 2 to 8 internal nodes) rather than to the opposite side of a 1,000-taxon tree. RAxML automatically calibrates an initial rearrangement radius rminโ€“rmax on the starting tree, restricting early SPR sweeps to target branches within radius r of the pruning site before widening the search radius on promising clades.

Biological Interpretation: Horizontal Gene Transfer and Reticulation

Rooted SPR Distance and Lateral Gene Acquisition

Beyond its role as a numerical optimization heuristic in tree search, the rooted Subtree Pruning and Regrafting (rSPR) operation has a direct biological interpretation in molecular evolution: a single rooted SPR move models the topological incongruence between a gene tree and a species tree caused by one horizontal gene transfer (HGT) event or hybrid introgression.

When a donor lineage D transfers a genetic locus (such as an antibiotic resistance cassette on a mobile plasmid replicon or a pathogenicity island) horizontally into a recipient lineage R, the transferred gene copy in R traces its evolutionary ancestry back to the donor branch D rather than to the vertical ancestor of R. Consequently, reconstructing the gene tree produces a topology in which the recipient subtree R has been pruned from its vertical species-tree position and regrafted onto the donor branch D (respecting temporal ordering so that donor and recipient lineages are contemporaneous). Calculating the minimum rSPR distance drSPR(Tspecies, Tgene) between a reference species phylogeny and an anomalous gene phylogeny provides a rigorous lower bound on the minimum number of horizontal gene transfer or homologous recombination events required to reconcile the two evolutionary histories, although computing drSPR between two arbitrary trees is NP-hard and solved in practice via fixed-parameter tractable (FPT) kernelization algorithms.

Frequently Asked Questions

Why is Subtree Pruning and Regrafting (SPR) much less likely to get trapped in local optima than NNI?

Nearest-Neighbor Interchange (NNI) can only swap subtrees across a single internal branch (radius r = 1). If a taxon or clade is misplaced several nodes away from its optimal position in a starting tree (such as a Neighbor-Joining or BioNJ tree), moving it via NNI requires multiple sequential single-branch swaps that temporarily pass through low-likelihood intermediate topologies. SPR detaches the misplaced clade and regrafts it onto its optimal target branch in a single step, bypassing the intervening likelihood valley.

How does "Lazy SPR" speed up maximum-likelihood tree search in RAxML and PhyML?

Evaluating all 2(N โˆ’ 3)(2N โˆ’ 7) SPR neighbors by re-optimizing every branch length on the tree would take O(N3) time per sweep. Lazy SPR slides the pruned subtree outward along the backbone tree (updating only 1 conditional likelihood vector per step) and estimates the likelihood of each candidate regrafting branch by optimizing only the 1 to 3 branches touching the new insertion node; full branch-length optimization is reserved for moves that pass this fast local filter.

What is the connection between rooted SPR moves and horizontal gene transfer?

In evolutionary genomics, when a recipient species acquires a gene from a distant donor species via horizontal gene transfer (xenologous replacement), the gene tree differs from the vertical species tree by a single rooted SPR operation: the recipient clade is pruned from its vertical taxonomic family and regrafted as the sister group to the donor lineage.

References

  1. Allen, B. L., & Steel, M. (2001). "Subtree transfer operations and their induced metrics on evolutionary trees." Annals of Combinatorics, 5(1), 1โ€“15. https://doi.org/10.1007/s00026-001-8006-8
  2. Stamatakis, A. (2006). "RAxML-VI-HPC: Maximum likelihood-based phylogenetic analyses with thousands of taxa and mixed models." Bioinformatics, 22(21), 2688โ€“2690. https://doi.org/10.1093/bioinformatics/btl446
  3. Guindon, S., Dufayard, J.-F., Lefort, V., Anisimova, M., Hordijk, W., & Gascuel, O. (2010). "New algorithms and methods to estimate maximum-likelihood phylogenies: Assessing the performance of PhyML 3.0." Systematic Biology, 59(3), 307โ€“321. https://doi.org/10.1093/sysbio/syq010
  4. Hordijk, W., & Gascuel, O. (2005). "Improving the efficiency of SPR moves in phylogenetic tree search methods based on maximum likelihood." Bioinformatics, 21(24), 4338โ€“4347. https://doi.org/10.1093/bioinformatics/bti713
๐Ÿงฌ Support Open Science
Explore interactive science games on LowKey Games or browse scientific apparel & accessories in the CRV Science Shop.
๐Ÿ’ก Spot an inaccuracy or have primary literature to expand this article?
Submit a citation or revision note using your shared CRV Science / LowKey Games profile ID.
Suggest Revision