Phylogenetic tree from an alignment
Paste an aligned FASTA. Distance matrix, Newick tree and a dendrogram you can read.
Paste an aligned FASTA. Distance matrix, Newick tree and a dendrogram you can read.
A distance method works in two steps, and both are shown on this page.
The sequences have to be aligned first, so that column 30 means the same site in every record. Align them with a multiple aligner, trim the ragged ends with thealignment trimmer if they need it, and paste the result here.
The p-distance is the observed proportion of differences, and it is exactly 1 − identity as the identity calculator reports it: a pair that is 96.7 % identical has a p-distance of 0.033. Gaps follow the same convention, so by default a column with a gap in either sequence counts as a difference and stays in the denominator. Switch Gap columns to "Skip in each pair" for pairwise deletion, where gap columns leave the comparison altogether, which is the usual choice when the alignment has long indels.
The Jukes-Cantor distance estimates the number of substitutions per site that actually happened, including the ones hidden by later changes at the same site. It is always larger than p: 0.10 becomes 0.107, 0.25 becomes 0.304, 0.50 becomes 0.824. The correction has a hard limit at p = 0.75, the difference expected between two random nucleotide sequences, where the logarithm goes to minus infinity. Distances near that limit are saturated and no correction can rescue them; the tool says so rather than inventing a number. Protein alignments use the p-distance, because Jukes-Cantor is a four-state nucleotide model.
UPGMA joins the two clusters with the smallest distance, places the new node at half that distance, and replaces the pair with their average distance to everything else, weighted by how many sequences each cluster holds. Repeating that until one cluster is left gives a rooted, ultrametric tree: every tip sits the same distance from the root, which is what a strict molecular clock would produce. That is also its weakness. If one lineage evolves faster than the others, UPGMA pulls it away from its real relatives to keep the tip distances equal, and the topology can be wrong.
Neighbour joining also joins one pair at a time, but it does not pick the closest pair. It picks the pair with the smallest Q, which subtracts from each distance how far the two sequences are from everything else, so a pair is only joined when they are close to each other and far from the rest. That correction is what makes the method immune to unequal rates: with perfectly additive distances neighbour joining returns the true tree. The two branch lengths of a new node are split with
and the remaining distances become d(u,k) = ½ (d(i,k) + d(j,k) − d(i,j)). The result is anunrooted tree, drawn here from its central three-way node. To root it, include an outgroup and re-root on that branch in FigTree or iTOL.
The example is a 60-column alignment of six primate sequences. With the default settings, UPGMA and the p-distance, the closest pair is Human and Chimpanzee, which differ at 2 of the 60 columns: p = 2 ÷ 60 = 0.0333, so they are joined at height 0.0333 ÷ 2 =0.01667. The most distant pair is Macaque against any ape, p = 0.2833. The tree is
Switch to Jukes-Cantor and the Human to Chimpanzee distance rises from 0.0333 to 0.0341 and the Macaque distances from 0.2833 to 0.3558, because the correction grows with divergence. The topology does not change: a monotonic correction cannot reorder the pairs. Switch to neighbour joining and the same six sequences give the unrooted tree(Gorilla,(Orangutan,(Gibbon,Macaque)),(Human,Chimpanzee)), which carries the same splits, with Macaque on the longest branch.
Newick writes a tree as nested brackets. A pair in brackets is a node, a comma separates siblings, the number after a colon is the length of the branch leading to that tip or node, and the semicolon ends the tree. (A:0.1,B:0.2) is two tips joined by a node, and((A:0.1,B:0.2):0.05,C:0.3) puts that node next to C. Copy gives the Newick string, Download saves it as a .nwk file, and both are accepted by FigTree, iTOL, Dendroscope, ape in R and Biopython.
Paste the aligned FASTA. The tool compares every pair of sequences column by column to get a distance matrix, then joins the sequences into a tree with UPGMA or with neighbour joining. The tree comes back as a Newick string you can paste into FigTree, iTOL, Dendroscope or R, and as a dendrogram you can read on the page. The sequences must already be aligned; this is a distance method, not an aligner.
UPGMA repeatedly joins the two closest clusters and places each join at half the distance between them, so every tip ends up the same distance from the root. That is only correct if every lineage evolved at the same rate, a molecular clock. Neighbour joining does not assume a clock: it picks the pair that minimises the total branch length of the whole tree, so lineages may have long and short branches. Neighbour joining is the safer default and the one used in practice; UPGMA is still useful when a clock is reasonable, for example for closely related strains, and it is the method that gives a rooted tree directly.
Whenever the sequences are divergent enough that a site may have changed more than once. The raw p-distance counts visible differences, and past about 10 percent divergence it underestimates the real number of substitutions because later changes hide earlier ones. Jukes-Cantor corrects for those hidden changes. It cannot help once the p-distance reaches 0.75, the value expected for two random nucleotide sequences, where the correction goes to infinity.
Because the distances are not exactly additive, which is normal for real data. Neighbour joining solves for branch lengths that best fit the matrix, and a short internal branch with noisy distances can come out slightly below zero. A small negative value is harmless and usually means the branch is really about zero, so the resolution at that node is not supported. Large negative values point to a bad alignment or to saturated distances.
No. Distance methods reduce each pair of sequences to a single number and then fit a tree to those numbers, which is fast but throws information away. Maximum likelihood and Bayesian methods score the tree against every column of the alignment under a substitution model, and give better trees on hard data plus a measure of support. Use this page to get a quick tree and to sanity-check an alignment, and RAxML, IQ-TREE or MrBayes for a tree that goes in a paper.