Tutorials › High-Dimensional Genomic Data Analysis › Spectral Clustering of High-Dimensional Profiles

Dimension Reduction and Clustering · Tutorial 620 of 795

Spectral Clustering of High-Dimensional Profiles

Learn how a similarity graph and its Laplacian reveal non-spherical cluster structure, and how to turn the Laplacian eigenvectors into cluster assignments.

Intermediate 12 min read

What You'll Learn

  • Construct a symmetric affinity graph from distances between genomic profiles.
  • Calculate vertex degrees and the symmetric normalized graph Laplacian.
  • Explain why its smallest-eigenvalue eigenvectors encode graph neighborhoods.
  • Row-normalize the spectral embedding and apply k-means to its rows.
  • Diagnose disconnected graphs, isolated profiles, and misleading similarity choices.
  • Compare spectral clustering with k-means, Gaussian mixtures, and hierarchical clustering.

Why Cluster Profiles Through a Graph?

K-means assigns profiles to groups by proximity to their cluster centers. This is effective when clusters are roughly compact, but its boundaries are linear in the original profile space and can be a poor match for curved or otherwise non-spherical groups. Spectral clustering takes a different route: it represents profiles as vertices in a weighted graph, with strong edges joining similar profiles, then uses the graph’s Laplacian eigenvectors to construct a new representation for clustering.

This approach does not make clustering assumption-free. Its results depend on how similarity is defined, which edges are retained, and how the graph is normalized. In high-dimensional genomic data, distance concentration can make many profile pairs appear similarly far apart. Feature scaling, the choice of distance, and the graph construction therefore need scientific and statistical justification.

Definition: Let \(x_i\in\mathbb{R}^p\) denote the measured profile for observational unit \(i\), for \(i=1,\ldots,n\). A weighted similarity graph has one vertex per profile and a symmetric, nonnegative weight \(w_{ij}\) for the edge between profiles \(i\) and \(j\). Large \(w_{ij}\) indicates strong similarity; \(w_{ij}=0\) means that the edge is absent. The degree of vertex \(i\) is \(d_i=\sum_{j=1}^n w_{ij}\). With \(W=(w_{ij})\) and \(D=\operatorname{diag}(d_1,\ldots,d_n)\), the symmetric normalized graph Laplacian is \(L_{\mathrm{sym}}=I-D^{-1/2}WD^{-1/2}\), provided all \(d_i>0\).

From Profiles to a Similarity Graph

A common starting point is a Gaussian affinity, \(w_{ij}=\exp(-\gamma\lVert x_i-x_j\rVert^2)\) for \(i\ne j\), where \(\gamma>0\) controls how quickly similarity decreases with squared distance. The resulting complete graph can be dense, so practitioners often retain only edges to each profile’s nearest neighbors or discard affinities below a chosen threshold. Whatever rule is used, the final graph should be made symmetric. For a directed nearest-neighbor rule, common choices are to retain an edge if either profile selected the other, or only if both did; these choices need not give the same graph. Set \(w_{ii}=0\) unless a different convention is explicitly intended.

The graph construction assumes that the chosen distance and weighting rule capture meaningful local resemblance. For gene-expression profiles, for example, a few high-variance genes or technical batch effects can dominate distances unless preprocessing is appropriate. A graph with an isolated vertex has \(d_i=0\), so \(D^{-1/2}\) is undefined there; the construction must be revised or the isolated profile handled separately. A disconnected graph is mathematically allowed, but its multiple connected components affect the eigenvectors and the number of zero eigenvalues.

Worked Example: Gaussian Weights and Vertex Degrees

Suppose four hypothetical profiles have coordinates \(x_1=(0,0)\), \(x_2=(0.5,0)\), \(x_3=(0,1.5)\), and \(x_4=(0,-1.5)\). Use the Gaussian affinity with \(\gamma=0.5\), and retain edges only when \(w_{ij}\geq \exp(-1.125)\). Self-edges are omitted.

For profiles 1 and 2, the squared distance is \(0.5^2=0.25\), giving \(w_{12}=\exp(-0.5(0.25))=\exp(-0.125)\approx0.8824969\). For profiles 1 and 3, and also 1 and 4, the squared distance is \(1.5^2=2.25\), giving weights \(\exp(-1.125)\approx0.3246525\). The squared distances from profile 2 to either 3 or 4 are \(0.5^2+1.5^2=2.5\), so those weights are \(\exp(-1.25)\approx0.2865048\), below the threshold. The weight between profiles 3 and 4 is \(\exp(-0.5(3^2))=\exp(-4.5)\), also below threshold.

Thus profile 1 is joined to profiles 2, 3, and 4, and there are no other retained edges. Calculate its degree from the unrounded weights:

$$ d_1=\exp(-0.125)+2\exp(-1.125)\approx1.5318018\approx1.5318. $$

The other degrees are \(d_2=\exp(-0.125)\approx0.8825\), and \(d_3=d_4=\exp(-1.125)\approx0.3247\). The graph is symmetric and connected, and every degree is positive, so its symmetric normalized Laplacian is defined. This example also illustrates that thresholding changes the graph: the discarded edges are not small rounding errors but are set to zero by the specified rule.

Why the Small Laplacian Eigenvectors Help

For any vector \(z\in\mathbb{R}^n\), put \(y=D^{-1/2}z\). Since \(L_{\mathrm{sym}}=I-D^{-1/2}WD^{-1/2}\) and \(W\) is symmetric with zero diagonal, direct expansion gives the identity below.

$$ z^\mathsf{T}L_{\mathrm{sym}}z =\frac{1}{2}\sum_{i=1}^n\sum_{j=1}^n w_{ij}\left(\frac{z_i}{\sqrt{d_i}}-\frac{z_j}{\sqrt{d_j}}\right)^2. $$

Every term on the right is nonnegative. For nonzero \(z\), a small value relative to \(\lVert z\rVert^2\) (that is, a small Rayleigh quotient \(z^\mathsf{T}L_{\mathrm{sym}}z/\lVert z\rVert^2\)) indicates that \(z_i/\sqrt{d_i}\) and \(z_j/\sqrt{d_j}\) tend to be similar across edges with large weight. Thus eigenvectors with small eigenvalues vary relatively little across strongly connected profiles. The eigenvectors can represent groups that are not compact or linearly separable in the original feature space.

Because \(L_{\mathrm{sym}}\) is a real symmetric positive semidefinite matrix, it has real nonnegative eigenvalues and an orthonormal eigenbasis. For a specified number of clusters \(K\), take eigenvectors corresponding to its \(K\) smallest eigenvalues and place them as columns of \(U\in\mathbb{R}^{n\times K}\). The usual normalized spectral clustering procedure scales each nonzero row of \(U\) to have Euclidean length one, then runs k-means on those \(n\) row vectors. The final group label for a profile is the k-means assignment of its row, not an eigenvector index.

Theorem: If the graph is connected and all degrees are positive, \(L_{\mathrm{sym}}\) has one zero eigenvalue. Its zero-eigenvalue eigenvector is proportional to \(D^{1/2}\mathbf{1}\), where \(\mathbf{1}\) is the vector of ones. This vector is constant only when all vertex degrees are equal. If the graph has \(C\) connected components, the zero eigenvalue has multiplicity \(C\).

To verify the connected-graph direction, set \(v=D^{1/2}\mathbf{1}\). Then \(D^{-1/2}v=\mathbf{1}\), and \(W\mathbf{1}=D\mathbf{1}\), since the row sums of \(W\) are the degrees. Therefore \(D^{-1/2}WD^{-1/2}v=D^{-1/2}D\mathbf{1}=v\), so \(L_{\mathrm{sym}}v=0\). The quadratic identity shows that a zero-energy vector must be constant after division of each coordinate by \(\sqrt{d_i}\) along every edge; in a connected graph this condition extends to all vertices. Each disconnected component can have its own such constant, explaining the multiplicity.

Worked Example: Separating Two Groups in the Spectral Embedding

Consider four hypothetical profiles whose graph has weight 1 between profiles 1 and 2 and between profiles 3 and 4, and weight 0.1 between every profile in the first pair and every profile in the second pair. All other diagonal weights are zero. Each degree is \(1+0.1+0.1=1.2\), so \(D=1.2I\) and \(L_{\mathrm{sym}}=I-W/1.2\).

The vector \((1,1,1,1)^\mathsf{T}\) is an eigenvector of \(W\) with eigenvalue 1.2. The contrast vector \((1,1,-1,-1)^\mathsf{T}\) has eigenvalue \(0.8\): for example, the first coordinate of its product with \(W\) is \(1-0.1-0.1=0.8\), matching that eigenvalue. In fact, the cross-pair contributions are \(0.1(-1)+0.1(-1)=-0.2\), and adding the within-pair contribution \(1\) gives \(0.8\). Thus its eigenvalue is \(0.8\), not 1.

The two within-pair contrasts, such as \((1,-1,0,0)^\mathsf{T}\), have eigenvalue \(-1\) for \(W\): the first coordinate is \(-1\), while the cross-pair contributions cancel. Therefore the eigenvalues of \(W\) are \(1.2,0.8,-1,-1\), and those of \(L_{\mathrm{sym}}\) are \(0,1/3,11/6,11/6\), respectively. For \(K=2\), choose the normalized eigenvectors \(u_1=(1,1,1,1)^\mathsf{T}/2\) and \(u_2=(1,1,-1,-1)^\mathsf{T}/2\). The rows of \(U\) are \((0.5,0.5)\) for profiles 1 and 2 and \((0.5,-0.5)\) for profiles 3 and 4. Each row already has length \(1/\sqrt{2}\); after row normalization, the two distinct row vectors are \((1/\sqrt{2},1/\sqrt{2})\) and \((1/\sqrt{2},-1/\sqrt{2})\). K-means with \(K=2\) assigns each identical pair together. The graph’s strong within-pair edges and weaker between-pair edges are reflected in the embedding.

Procedure, Choices, and Diagnostics

1
Prepare profiles and specify similarity.
Choose a distance and, if using a Gaussian affinity, a bandwidth parameter \(\gamma\). Check whether feature scaling and preprocessing make that distance scientifically meaningful.
2
Construct and inspect the graph.
Apply a stated threshold or nearest-neighbor rule, symmetrize the edges, and calculate degrees. Check for isolated vertices, unexpected disconnected components, and extreme degree imbalance.
3
Calculate the Laplacian and embed.
Form \(L_{\mathrm{sym}}\), find eigenvectors for the \(K\) smallest eigenvalues, and row-normalize the resulting matrix when rows are nonzero.
4
Cluster and examine the result.
Run k-means on the normalized rows and assign its labels to the original profiles. Inspect the graph and embedding as well as the assignments; a numerical partition alone does not establish meaningful biological groups.

A practical diagnostic is to check whether small changes in the affinity bandwidth, edge rule, or distance radically alter the graph’s connectivity or the resulting grouping. Abrupt changes can indicate that the clustering is being driven by an arbitrary tuning choice. A graph with \(C\) components has \(C\) zero eigenvalues; if \(K<C\), the selected low-eigenvalue embedding does not canonically separate all components, and k-means can assign multiple disconnected components to the same cluster. Conversely, an overly dense graph may connect profiles across groups, while an overly sparse graph may fragment a group or isolate profiles. These checks diagnose construction problems; they do not constitute a formal test of the number or truth of clusters.

A useful non-regular graph example makes the zero-eigenvector distinction concrete. Take a three-vertex path with edge weights 1 between vertices 1 and 2 and 3 between vertices 2 and 3. Its degrees are \(1,4,3\), so the zero-eigenvalue direction is proportional to \((1,2,\sqrt{3})^\mathsf{T}\), not a constant vector. Indeed, the middle coordinate of \(L_{\mathrm{sym}}(1,2,\sqrt{3})^\mathsf{T}\) is \(-0.5+2-(\sqrt{3}/2)\sqrt{3}=0\), and the first and third coordinates are also zero. Treating the normalized-Laplacian zero eigenvector as constant when degrees differ is a common mistake.

Alternatives and Limits

K-means in the original profile space is simpler and directly optimizes within-cluster squared distances, but its geometry favors compact groups. Spectral clustering instead relies on a graph encoding local similarity and then uses k-means in an eigenvector representation. Gaussian mixture models describe clusters through probability distributions and can represent some non-spherical shapes depending on their covariance structure, but they impose a distributional model and are fitted by likelihood methods. Agglomerative hierarchical clustering builds a nested grouping from pairwise distances and a linkage rule, rather than using a Laplacian embedding. None is universally preferable: their assumptions and outputs differ.

Spectral clustering can be computationally demanding for very large \(n\), particularly when many eigenvectors are needed. It is also sensitive to graph choices and can be difficult to apply to new profiles without an additional out-of-sample embedding rule. The row normalization and k-means stage do not remove those limitations. Finally, a cluster is a feature of the chosen data representation and method; it is not by itself evidence of a biological mechanism or causal distinction.

Worked Example: Interpreting a Non-Regular Graph’s Zero Direction

Use the weighted path with edge weights \(w_{12}=1\), \(w_{23}=3\), and \(w_{13}=0\). Its degrees are \(d_1=1\), \(d_2=4\), and \(d_3=3\). The vector \(v=D^{1/2}\mathbf{1}\) is therefore \((1,2,\sqrt{3})^\mathsf{T}\), with norm \(\sqrt{1+4+3}=\sqrt{8}\). The unit zero-eigenvalue vector is \(v/\sqrt{8}\), approximately \((0.3536,0.7071,0.6124)^\mathsf{T}\).

For a direct check, the first row of \(L_{\mathrm{sym}}\) is \((1,-1/2,0)\), so its product with \(v\) is \(1-(1/2)2=0\). The second row is \((-1/2,1,-\sqrt{3}/2)\), giving \(-1/2+2-3/2=0\). The third row is \((0,-\sqrt{3}/2,1)\), giving \(-\sqrt{3}+ \sqrt{3}=0\). Hence \(L_{\mathrm{sym}}v=0\), while \(v\) is plainly not constant. The direction is constant only after dividing each entry by the square root of its degree.

Common Mistakes

  • Calling the zero-eigenvalue vector constant for every graph. For the symmetric normalized Laplacian, it is proportional to \(D^{1/2}\mathbf{1}\); unequal degrees generally produce unequal entries.
  • Clustering the eigenvector columns as if they were profiles. The standard procedure clusters the rows, one row per profile, after the specified row normalization.
  • Ignoring graph construction. A visually appealing partition cannot rescue a graph whose distances or edges do not encode relevant similarity.
  • Assuming a low-dimensional embedding proves cluster validity. Eigenvectors summarize graph structure; they do not establish that the groups are biologically real or robust.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. For a connected graph with positive degrees, what is the zero-eigenvalue direction of \(L_{\mathrm{sym}}\), and when is it constant?
  2. A profile has no retained edges. What problem does this create for the normalized Laplacian?
  3. In spectral clustering, are the rows or columns of the selected eigenvector matrix clustered?
  4. Why can an excessively sparse graph be problematic?
  5. Give one important distinction between spectral clustering and a Gaussian mixture model.

Solutions. (1) The direction is \(D^{1/2}\mathbf{1}\), up to a nonzero scaling; it is constant when all degrees are equal. (2) Its degree is zero, so the corresponding entry of \(D^{-1/2}\) is undefined; the graph construction or treatment of that profile must be revised. (3) The rows are clustered, after row normalization in the usual procedure, because each row represents one profile in the embedding. (4) It can disconnect the graph or leave profiles isolated, changing the zero-eigenvalue structure and potentially preventing meaningful comparisons between groups. (5) Spectral clustering uses graph similarities and Laplacian eigenvectors, whereas a Gaussian mixture specifies and fits a probability model for the profile distribution.

Clinical Biostats