Clustergram
Clustergram is a hierarchically clustered heatmap for a matrix (e.g. genes
by cells, or genes by clusters) — the data-visualization counterpart to the
spatial views, for inspecting expression patterns directly rather than their
tissue location.
What it shows
- A matrix view: rows and columns rendered as a dot-matrix (dot size/color
encodes value) or a filled tile, toggled with the
TILE: prop/unitand compositionprop/countscontrols. - Dendrograms on both axes, with sliders to change the linkage-distance cutoff used to cut the tree into clusters. While adjusting a slider, a temporary full-tree overview appears over the matrix on a translucent white background. A blue water rectangle expands from the leaves to the cutoff, showing the branches merged below that level. It rises for columns and moves sideways for rows. Release the slider to fade the overview, or press Escape to dismiss it immediately. Keyboard slider controls also work.
- Reorder controls for both axes (
clust,sum,var,ini) to resort rows/columns by clustering order, summed value, variance, or the original input order. - Category bar graphs shown alongside a dendrogram when its cut point is clicked.
For comparing category composition (e.g. cell-type proportions) across
groups instead of a general heatmap, see Composition, a
Clustergram variant purpose-built for that comparison.
The tree preview follows the matrix's zoom and pan: row branches stay aligned vertically and column branches horizontally, including in the current RANK view. The blue cut rectangle stays fitted to the visible matrix. The preview appears in clustering order; an axis crop keeps its dendrogram slice pinned until the crop is undone.
Usage
Clustergram is built from a clustered celldega.clust.Matrix:
import celldega as dega
mat = dega.clust.Matrix(adata)
mat.filter("row", by="var", num=5000)
mat.norm("col", by="total")
mat.norm("row", by="zscore")
mat.cluster()
cgm = dega.viz.Clustergram(matrix=mat)
cgm
Clustergram can also be linked to a spatial view (Landscape, CellCloud,
or NeighborhoodCloud) so that selecting rows/columns highlights the
corresponding cells spatially — see
dega.viz.spatial_clustergram.
For the full constructor options (including the more efficient
parquet_data path via
Matrix.export_viz_parquet),
see the Viz Module API reference.
Note
Screenshots and an example video are coming soon.