We illustrate the phylogeny reconstruction by least-squares using the F81 substitution model. We use the advanced-stepwise addition algorithm to search tree space. Here a is the number of taxa to exhaustively evaluate all possible phylogenies for. Successive taxa are added to the top k trees (measured by the least-squares metric) and k trees are kept at each iteration.
from cogent3.phylo.least_squares import WLSfrom cogent3.util.deserialise import deserialise_objectdists = deserialise_object("data/dists_for_phylo.json")ls = WLS(dists)stat, tree = ls.trex(a=5, k=5, show_progress=False)
/tmp/ipykernel_10164/2714906990.py:2: DeprecationWarning: cogent3.util.deserialise is discontinued and will be removed in version 2026.9, use scinexus.deserialise instead
from cogent3.util.deserialise import deserialise_object
Other optional arguments that can be passed to the trex method are: return_all, whether the k best trees at the final step are returned as a ScoredTreeCollection object; order, a series of tip names whose order defines the sequence in which tips will be added during tree building (this allows the user to randomise the input order).
By ML
We illustrate the phylogeny reconstruction using maximum-likelihood using the F81 substitution model. We use the advanced-stepwise addition algorithm to search tree space.