Skip to contents

Renders a tidyheatmaps-style matrix heatmap as a plotit mark. Accepts a numeric matrix, a wide numeric data.frame (columns become heatmap columns), or a tidy long mapping (encode(x =, y =, fill =)). Optionally z-score normalises rows/columns (base::scale()) and reorders them by hierarchical clustering (stats::hclust()). The tile grid reuses the shared mark path, so it inherits the white-hairline cell chrome (tiles hug the panel, no 0-origin whitespace) and the colour-blind-safe viridis fill default; chain scale_fill() to replace it (last call wins). This is a mark, not a separate system: combine it with layout_dendrogram() and compose_marginal() for a full annotated heatmap.

Usage

mark_heatmap(
  plot,
  cluster = c("both", "row", "column", "none"),
  scale = c("none", "row", "column"),
  ...,
  rasterize = FALSE,
  rasterize_dpi = 300,
  rasterize_dev = "cairo"
)

Arguments

plot

A plotit object carrying the matrix / data.frame / tidy mapping.

cluster

Reorder axes by hierarchical clustering: "both" (default), "row", "column", or "none".

scale

z-score normalisation: "none" (default), "row", or "column".

...

Other arguments passed to ggplot2::geom_tile().

rasterize

If TRUE, rasterize via ggrastr::rasterise().

rasterize_dpi

DPI for rasterization (default 300).

rasterize_dev

Graphics device for rasterization (default "cairo").

Value

Modified plotit object.

References

tidyheatmaps: Heatmaps from Tidy Data

Examples

mat <- matrix(rnorm(30),
  nrow = 6,
  dimnames = list(paste0("g", 1:6), paste0("s", 1:5))
)
plotit(mat, encode()) |> mark_heatmap()

plotit(mat, encode()) |> mark_heatmap(cluster = "both", scale = "row")