Consensus clustering
Discover patient or sample subgroups with similar numerical feature profiles using consensus agglomerative clustering.
Discover patient or sample subgroups with similar numerical feature profiles using consensus agglomerative clustering.
Consensus agglomerative clustering
Description
Analysis summary
Discovers patient or sample subgroups from a wide numeric feature table using consensus agglomerative clustering: repeated bootstrap subsamples test how consistently each pair of samples falls into the same cluster, and the final groups are the ones that co-cluster most reliably. The result reports a cluster label per sample, per-cluster separation statistics and a bootstrap-based stability score.
Computation
Runs consensus agglomerative clustering on the wide-format numeric feature matrix: each bootstrap iteration subsamples samples (and, optionally, features), clusters the subsample, and accumulates which sample pairs were sampled together and which of those co-clustered; dividing the two gives the consensus matrix, on which a final agglomerative clustering produces the cluster labels. Two consensus matrices are computed for every run. The 'train' one is the classic co-sampling consensus, counted over samples that were jointly subsampled. The 'test' one is built by a classifier: in each bootstrap, a classifier is fitted on the training split to recognise the clusters just found, then predicts cluster membership for the samples that were held out — the test consensus counts how often those never-clustered samples were predicted into the same cluster, so it measures how well the clustering structure generalises to unseen samples rather than how one subsample happened to cluster. The selected consensus mode's matrix drives the final labels. Stability is scored for both matrices with a two-proportion z-statistic comparing the rate at which pairs inside the same cluster co-cluster against the rate for pairs across clusters: a higher score means within-cluster pairs co-cluster much more consistently than between-cluster pairs, i.e. the clustering is stable and not an artefact of one particular subsample, while a score near zero means the clustering is no better than chance. The default stability variant rescales the statistic by the number of co-sampled pairs so scores stay comparable across cohort sizes and bootstrap counts. Per-cluster silhouette and nearest-neighbour-purity statistics are computed in the original feature space used for clustering — not in any 2-D rendering — so they validate clustering quality independently of the visualisation choice and complement the bootstrap-based stability score.
When to use
Use to discover unknown patient or sample subgroups from a mix of numeric features — gene expression, gene-signature scores, clinical numerics, histomics fractions — without predefining the groups. Not for clustering individual cells (scRNA-seq) or spots (spatial transcriptomics), and not for displaying a named, small feature panel as a heatmap annotated by known categorical variables — that is aggregation_analysis's complex_heatmap mode.
Caveats
The clusters reflect whatever features the query supplies: batch correction is a prerequisite — do not combine datasets, or centres/batches within one dataset, without correcting that effect first, since the batch stratification column only balances the bootstrap splits and does not correct the signal; uncorrected, the clusters will reflect batch, not biology. The number of clusters must be chosen up front — the analysis does not select it. Feature columns must be complete and numeric: missing values are not imputed, and the analysis raises on the first null or non-numeric feature column.
Example questions
Input columns
Visualizations
scatterHow to read: Each dot is one sample or patient, placed by a 2-D UMAP embedding of the feature matrix and coloured by its cluster label — good for a quick visual sense of how well the discovered subgroups separate. Tight, disjoint point clouds indicate well-separated clusters; overlapping clouds suggest the chosen cluster count may not fit the data. UMAP positions are qualitative — do not over-read distances or shapes — and the quantitative check is the per-cluster silhouette and purity statistics, computed in the original feature space rather than this rendering.diagonal_heatmapHow to read: Square heatmap of the consensus matrix: cell (i, j) is the bootstrap frequency with which samples i and j co-clustered (diagonal = 1), with a single top dendrogram driven by the agglomerative clustering that produced the final labels — rows and columns share the dendrogram's leaf order. Sharp, bright diagonal blocks mean stable, well-separated clusters; fuzzy blocks or bright off-diagonal signal mean unstable or overlapping ones — this is the view for judging cluster stability. Hovering a cell shows the pair's co-clustering frequency.
Example analysis 1
Name — Consensus Agglomerative Clustering of Mosaic Bladder Patients by Gene Expression (ERBB2, ROR1, CD8A, TP53) + Immune Signature + Age
Analysis parameters
Visualization — scatter

Output table
Example analysis 2
Name — Consensus Matrix of Mosaic Bladder Patients by Gene Expression (ERBB2, ROR1, CD8A, TP53) + Immune Signature + Age
Analysis parameters
Visualization — diagonal_heatmap

Output table
Last updated
Was this helpful?