Construct phylogenetic tree from pairwise distances


PhyloTree = seqlinkage(Distances)
PhyloTree = seqlinkage(Distances, Method)
PhyloTree = seqlinkage(Distances, Method, Names)



Matrix or vector of pairwise distances, such as returned by the seqpdist function.


String that specifies a distance method. Choices are:

  • 'single'

  • 'complete'

  • 'average' (default)

  • 'weighted'

  • 'centroid'

  • 'median'


Specifies alternative labels for leaf nodes. Choices are:

  • Vector of structures, each with a Header or Name field

  • Cell array of strings

The elements must be unique. The number of elements must comply with the number of samples used to generate the pairwise distances in Dist.


PhyloTree = seqlinkage(Distances) returns a phylogenetic tree object from the pairwise distances, Distances, between the species or products. Distances is a matrix or vector of pairwise distances, such as returned by the seqpdist function.

PhyloTree = seqlinkage(Distances, Method) creates a phylogenetic tree object using a specified patristic distance method. The available methods are:


Nearest distance (single linkage method)


Furthest distance (complete linkage method)

'average' (default)

Unweighted Pair Group Method Average (UPGMA, group average).


Weighted Pair Group Method Average (WPGMA)


Unweighted Pair Group Method Centroid (UPGMC)


Weighted Pair Group Method Centroid (WPGMC)

PhyloTree = seqlinkage(Distances, Method, Names) passes a list of unique names to label the leaf nodes (for example, species or products) in a phylogenetic tree object.


collapse all

Build Phylogenetic Tree from Pairwise Distances

Build a phylogenetic tree from pairwise distances, specifying both a distance-computing method and leaf names.

Create an array of structures representing a multiple alignment of amino acids:

seqs = fastaread('pf00002.fa');

Measure the Jukes-Cantor pairwise distances between sequences:

distances = seqpdist(seqs,'method','jukes-cantor','indels','pair');

You will use the output argument distances, a vector containing biological distances between each pair of sequences, as an input argument to seqlinkage.

Build the phylogenetic tree for the multiple sequence alignment from pairwise distances. Specify the method to compute the distances of the new nodes to all other nodes. Provide leaf names:

phylotree = seqlinkage(distances,'single',seqs)

Phylogenetic tree object with 32 leaves (31 branches)

View the phylogenetic tree:


Was this topic helpful?