Complete-linkage clustering
Complete-linkage clustering is one of several methods of agglomerative hierarchical clustering. At the beginning of the process, each element is in a cluster of its own. The clusters are then sequentially combined into larger clusters until all elements end up being in the same cluster. The method is also known as farthest neighbour clustering. The result of the clustering can be visualized as a dendrogram, which shows the sequence of cluster fusion and the distance at which each fusion took place.[1][2][3]
Clustering procedure
At each step, the two clusters separated by the shortest distance are combined. The definition of 'shortest distance' is what differentiates between the different agglomerative clustering methods. In complete-linkage clustering, the link between two clusters contains all element pairs, and the distance between clusters equals the distance between those two elements (one in each cluster) that are farthest away from each other. The shortest of these links that remains at any step causes the fusion of the two clusters whose elements are involved.
Mathematically, the complete linkage function — the distance [math]\displaystyle{ D(X,Y) }[/math] between clusters [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math] — is described by the following expression : [math]\displaystyle{ D(X,Y)= \max_{x\in X, y\in Y} d(x,y) }[/math]
where
- [math]\displaystyle{ d(x,y) }[/math] is the distance between elements [math]\displaystyle{ x \in X }[/math] and [math]\displaystyle{ y \in Y }[/math] ;
- [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math] are two sets of elements (clusters).
Algorithms
Naive scheme
The following algorithm is an agglomerative scheme that erases rows and columns in a proximity matrix as old clusters are merged into new ones. The [math]\displaystyle{ N \times N }[/math] proximity matrix D contains all distances d(i,j). The clusterings are assigned sequence numbers 0,1,......, (n − 1) and L(k) is the level of the kth clustering. A cluster with sequence number m is denoted (m) and the proximity between clusters (r) and (s) is denoted d[(r),(s)].
The complete linkage clustering algorithm consists of the following steps:
- Begin with the disjoint clustering having level [math]\displaystyle{ L(0) = 0 }[/math] and sequence number [math]\displaystyle{ m=0 }[/math].
- Find the most similar pair of clusters in the current clustering, say pair [math]\displaystyle{ (r), (s) }[/math], according to [math]\displaystyle{ d[(r),(s)] = \max d[(i),(j)] }[/math]where the maximum is over all pairs of clusters in the current clustering.
- Increment the sequence number: [math]\displaystyle{ m = m + 1 }[/math]. Merge clusters [math]\displaystyle{ (r) }[/math] and [math]\displaystyle{ (s) }[/math] into a single cluster to form the next clustering [math]\displaystyle{ m }[/math]. Set the level of this clustering to [math]\displaystyle{ L(m) = d[(r),(s)] }[/math]
- Update the proximity matrix, [math]\displaystyle{ D }[/math], by deleting the rows and columns corresponding to clusters [math]\displaystyle{ (r) }[/math] and [math]\displaystyle{ (s) }[/math] and adding a row and column corresponding to the newly formed cluster. The proximity between the new cluster, denoted [math]\displaystyle{ (r,s) }[/math], and an old cluster [math]\displaystyle{ (k) }[/math] is defined as [math]\displaystyle{ d[(r,s),(k)] = \max \{d[(k),(r)], d[(k),(s)] \} }[/math].
- If all objects are in one cluster, stop. Else, go to step 2.
Optimally efficient scheme
The algorithm explained above is easy to understand but of complexity [math]\displaystyle{ O(n^3) }[/math]. In May 1976, D. Defays proposed an optimally efficient algorithm of only complexity [math]\displaystyle{ O(n^2) }[/math] known as CLINK (published 1977)[4] inspired by the similar algorithm SLINK for single-linkage clustering.
Working example
The working example is based on a JC69 genetic distance matrix computed from the 5S ribosomal RNA sequence alignment of five bacteria: Bacillus subtilis ([math]\displaystyle{ a }[/math]), Bacillus stearothermophilus ([math]\displaystyle{ b }[/math]), Lactobacillus viridescens ([math]\displaystyle{ c }[/math]), Acholeplasma modicum ([math]\displaystyle{ d }[/math]), and Micrococcus luteus ([math]\displaystyle{ e }[/math]).[5][6]
First step
- First clustering
Let us assume that we have five elements [math]\displaystyle{ (a,b,c,d,e) }[/math] and the following matrix [math]\displaystyle{ D_1 }[/math] of pairwise distances between them:
a | b | c | d | e | |
---|---|---|---|---|---|
a | 0 | 17 | 21 | 31 | 23 |
b | 17 | 0 | 30 | 34 | 21 |
c | 21 | 30 | 0 | 28 | 39 |
d | 31 | 34 | 28 | 0 | 43 |
e | 23 | 21 | 39 | 43 | 0 |
In this example, [math]\displaystyle{ D_1 (a,b)=17 }[/math] is the smallest value of [math]\displaystyle{ D_1 }[/math], so we join elements [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math].
- First branch length estimation
Let [math]\displaystyle{ u }[/math] denote the node to which [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math] are now connected. Setting [math]\displaystyle{ \delta(a,u)=\delta(b,u)=D_1(a,b)/2 }[/math] ensures that elements [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math] are equidistant from [math]\displaystyle{ u }[/math]. This corresponds to the expectation of the ultrametricity hypothesis. The branches joining [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math] to [math]\displaystyle{ u }[/math] then have lengths [math]\displaystyle{ \delta(a,u)=\delta(b,u)=17/2=8.5 }[/math] (see the final dendrogram)
- First distance matrix update
We then proceed to update the initial proximity matrix [math]\displaystyle{ D_1 }[/math] into a new proximity matrix [math]\displaystyle{ D_2 }[/math] (see below), reduced in size by one row and one column because of the clustering of [math]\displaystyle{ a }[/math] with [math]\displaystyle{ b }[/math]. Bold values in [math]\displaystyle{ D_2 }[/math] correspond to the new distances, calculated by retaining the maximum distance between each element of the first cluster [math]\displaystyle{ (a,b) }[/math] and each of the remaining elements:
[math]\displaystyle{ D_2((a,b),c)=max(D_1(a,c),D_1(b,c))=max(21,30)=30 }[/math]
[math]\displaystyle{ D_2((a,b),d)=max(D_1(a,d),D_1(b,d))=max(31,34)=34 }[/math]
[math]\displaystyle{ D_2((a,b),e)=max(D_1(a,e),D_1(b,e))=max(23,21)=23 }[/math]
Italicized values in [math]\displaystyle{ D_2 }[/math] are not affected by the matrix update as they correspond to distances between elements not involved in the first cluster.
Second step
- Second clustering
We now reiterate the three previous steps, starting from the new distance matrix [math]\displaystyle{ D_2 }[/math] :
(a,b) | c | d | e | |
---|---|---|---|---|
(a,b) | 0 | 30 | 34 | 23 |
c | 30 | 0 | 28 | 39 |
d | 34 | 28 | 0 | 43 |
e | 23 | 39 | 43 | 0 |
Here, [math]\displaystyle{ D_2 ((a,b),e)=23 }[/math] is the lowest value of [math]\displaystyle{ D_2 }[/math], so we join cluster [math]\displaystyle{ (a,b) }[/math] with element [math]\displaystyle{ e }[/math].
- Second branch length estimation
Let [math]\displaystyle{ v }[/math] denote the node to which [math]\displaystyle{ (a,b) }[/math] and [math]\displaystyle{ e }[/math] are now connected. Because of the ultrametricity constraint, the branches joining [math]\displaystyle{ a }[/math] or [math]\displaystyle{ b }[/math] to [math]\displaystyle{ v }[/math], and [math]\displaystyle{ e }[/math] to [math]\displaystyle{ v }[/math], are equal and have the following total length: [math]\displaystyle{ \delta(a,v)=\delta(b,v)=\delta(e,v)=23/2=11.5 }[/math]
We deduce the missing branch length: [math]\displaystyle{ \delta(u,v)=\delta(e,v)-\delta(a,u)=\delta(e,v)-\delta(b,u)=11.5-8.5=3 }[/math] (see the final dendrogram)
- Second distance matrix update
We then proceed to update the [math]\displaystyle{ D_2 }[/math] matrix into a new distance matrix [math]\displaystyle{ D_3 }[/math] (see below), reduced in size by one row and one column because of the clustering of [math]\displaystyle{ (a,b) }[/math] with [math]\displaystyle{ e }[/math] :
[math]\displaystyle{ D_3(((a,b),e),c)=max(D_2((a,b),c),D_2(e,c))=max(30,39)=39 }[/math]
[math]\displaystyle{ D_3(((a,b),e),d)=max(D_2((a,b),d),D_2(e,d))=max(34,43)=43 }[/math]
Third step
- Third clustering
We again reiterate the three previous steps, starting from the updated distance matrix [math]\displaystyle{ D_3 }[/math].
((a,b),e) | c | d | |
---|---|---|---|
((a,b),e) | 0 | 39 | 43 |
c | 39 | 0 | 28 |
d | 43 | 28 | 0 |
Here, [math]\displaystyle{ D_3 (c,d)=28 }[/math] is the smallest value of [math]\displaystyle{ D_3 }[/math], so we join elements [math]\displaystyle{ c }[/math] and [math]\displaystyle{ d }[/math].
- Third branch length estimation
Let [math]\displaystyle{ w }[/math] denote the node to which [math]\displaystyle{ c }[/math] and [math]\displaystyle{ d }[/math] are now connected. The branches joining [math]\displaystyle{ c }[/math] and [math]\displaystyle{ d }[/math] to [math]\displaystyle{ w }[/math] then have lengths [math]\displaystyle{ \delta(c,w)=\delta(d,w)=28/2=14 }[/math] (see the final dendrogram)
- Third distance matrix update
There is a single entry to update: [math]\displaystyle{ D_4((c,d),((a,b),e))=max(D_3(c,((a,b),e)), D_3(d,((a,b),e)))=max(39, 43)=43 }[/math]
Final step
The final [math]\displaystyle{ D_4 }[/math] matrix is:
((a,b),e) | (c,d) | |
---|---|---|
((a,b),e) | 0 | 43 |
(c,d) | 43 | 0 |
So we join clusters [math]\displaystyle{ ((a,b),e) }[/math] and [math]\displaystyle{ (c,d) }[/math].
Let [math]\displaystyle{ r }[/math] denote the (root) node to which [math]\displaystyle{ ((a,b),e) }[/math] and [math]\displaystyle{ (c,d) }[/math] are now connected. The branches joining [math]\displaystyle{ ((a,b),e) }[/math] and [math]\displaystyle{ (c,d) }[/math] to [math]\displaystyle{ r }[/math] then have lengths:
[math]\displaystyle{ \delta(((a,b),e),r)=\delta((c,d),r)=43/2=21.5 }[/math]
We deduce the two remaining branch lengths:
[math]\displaystyle{ \delta(v,r)=\delta(((a,b),e),r)-\delta(e,v)=21.5-11.5=10 }[/math]
[math]\displaystyle{ \delta(w,r)=\delta((c,d),r)-\delta(c,w)=21.5-14=7.5 }[/math]
The complete-linkage dendrogram
The dendrogram is now complete. It is ultrametric because all tips ([math]\displaystyle{ a }[/math] to [math]\displaystyle{ e }[/math]) are equidistant from [math]\displaystyle{ r }[/math] :
[math]\displaystyle{ \delta(a,r)=\delta(b,r)=\delta(e,r)=\delta(c,r)=\delta(d,r)=21.5 }[/math]
The dendrogram is therefore rooted by [math]\displaystyle{ r }[/math], its deepest node.
Comparison with other linkages
Alternative linkage schemes include single linkage clustering and average linkage clustering - implementing a different linkage in the naive algorithm is simply a matter of using a different formula to calculate inter-cluster distances in the initial computation of the proximity matrix and in step 4 of the above algorithm. An optimally efficient algorithm is however not available for arbitrary linkages. The formula that should be adjusted has been highlighted using bold text.
Complete linkage clustering avoids a drawback of the alternative single linkage method - the so-called chaining phenomenon, where clusters formed via single linkage clustering may be forced together due to single elements being close to each other, even though many of the elements in each cluster may be very distant to each other. Complete linkage tends to find compact clusters of approximately equal diameters.[7]
Single-linkage clustering. | Complete-linkage clustering. | Average linkage clustering: WPGMA. | Average linkage clustering: UPGMA. |
See also
- Cluster analysis
- Hierarchical clustering
- Molecular clock
- Neighbor-joining
- Single-linkage clustering
- UPGMA
- WPGMA
References
- ↑ "A method of establishing groups of equal amplitude in plant sociology based on similarity of species and its application to analyses of the vegetation on Danish commons.". Biologiske Skrifter 5: 1–34. 1948.
- ↑ Numerical Ecology (Second English ed.). 1998. pp. 853.
- ↑ Everitt, Brian S.; Landau, Sabine; Leese, Morven (2001). Cluster Analysis (Fourth ed.). London: Arnold. ISBN 0-340-76119-9.
- ↑ "An efficient algorithm for a complete link method". The Computer Journal (British Computer Society) 20 (4): 364–366. 1977. doi:10.1093/comjnl/20.4.364.
- ↑ "Collection of published 5S, 5.8S and 4.5S ribosomal RNA sequences". Nucleic Acids Research 14 Suppl (Suppl): r1-59. 1986. doi:10.1093/nar/14.suppl.r1. PMID 2422630.
- ↑ Phylogenetic analysis using ribosomal RNA. Methods in Enzymology. 164. 1988. pp. 793–812. doi:10.1016/s0076-6879(88)64084-5.
- ↑ Everitt, Landau and Leese (2001), pp. 62-64.
Further reading
- Cluster Analysis Algorithms. Chichester: Ellis Horwood. 1980.
Original source: https://en.wikipedia.org/wiki/Complete-linkage clustering.
Read more |