Contents
rowOrder
Clustered row order of a ComplexHeatmap object
Reads back the row order a ComplexHeatmap clustering produced, for both a
single Heatmap and a multi-panel HeatmapList. Without it, callers reach
past the supported API into @-slot internals.
Usage
rowOrder(ht, which = NULL, ...)S3 method for class 'Heatmap'
rowOrder(ht, which = NULL, ...)S3 method for class 'HeatmapList'
rowOrder(ht, which = NULL, ...)Default S3 method:
rowOrder(ht, which = NULL, ...)Arguments
| Argument | Description |
|---|---|
ht | A ComplexHeatmap::Heatmap or a ComplexHeatmap::HeatmapList. The Heatmap method draws onto a null device itself, so an undrawn heatmap is fine and nothing reaches the caller's device. The HeatmapList method does not, so pass one that has been drawn; otherwise ComplexHeatmap warns that the heatmap has not been initialized. |
which | Integer scalar, or NULL (default). For a HeatmapList only, the 1-based index into ht@ht_list whose row names the shared row order is read against; NULL uses the first panel that is itself a Heatmap, skipping annotation entries. Ignored for a plain Heatmap; an index out of range, or a list with no Heatmap panel and no explicit which, aborts. |
... | Unused. Present for S3 method compatibility. |
Value
A character vector of row names in clustered top-to-bottom order,
the same length as the panel's row axis. Any other input reaches the
default method, which aborts. Both methods abort when ComplexHeatmap is
not installed.
Details
Clustering is only resolved at draw time, which is why the pattern being
wrapped is rownames(ht@matrix)[row_order(ht)], or
rownames(ht@ht_list[[i]]@matrix)[row_order(ht)] for a composite. Every
row-aligned panel of a HeatmapList shares one order, so which selects
only which panel's names it is read against. Drawing a single Heatmap
promotes it to a one-panel HeatmapList in current ComplexHeatmap
versions, so a drawn heatmap dispatches to the list method. Where row
splitting makes ComplexHeatmap::row_order() return a per-group list, the
groups are concatenated in displayed order.
Examples
if (requireNamespace("ComplexHeatmap", quietly = TRUE)) {
mat <- matrix(rnorm(20), nrow = 5, dimnames = list(paste0("r", 1:5), paste0("c", 1:4)))
rowOrder(ComplexHeatmap::Heatmap(mat))
}