Main Content


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.


Character vector or 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 character vectors or string vector

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

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');

Build the phylogenetic tree for the multiple sequence alignment from calculated 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:


Figure Phylogenetic Tree 1 contains an axes. The axes contains 70 objects of type line.

Compatibility Considerations

expand all

Behavior changed in R2017b

Introduced before R2006a