A GPU-accelerated heatmap for large expression matrices (samples x genes).
The matrix is uploaded to the GPU as a single texture and colormapped in a
fragment shader (via regl), so matrices with a million or more cells pan
and zoom smoothly. The colorbar legend and row/column tick labels are drawn
as crisp vector overlays; when rows or columns are too tight for every
label, every second, third or fourth one is drawn, and zooming in shows
the rest. A matrix with more rows or columns than the plot has pixels
is pooled for drawing: each pixel shows the mean of the cells under it,
so a lone outlier row still shows, fainter the more rows share its pixel.
A matrix with more rows or columns than the GPU's texture limit is
averaged in blocks of two or more rows (or columns) to fit it. Zoomed in
until each row and column in view has a pixel of its own, the view shows
every row and column once it stops moving.
Usage
bioheatmap(
mat,
colormap = NULL,
z_score = FALSE,
vmin = NULL,
vmax = NULL,
show_colorbar = TRUE,
legend_title = NULL,
theme = NULL,
width = NULL,
height = NULL,
element_id = NULL
)
heatmap_plotomics(
mat,
colormap = NULL,
z_score = FALSE,
vmin = NULL,
vmax = NULL,
show_colorbar = TRUE,
legend_title = NULL,
theme = NULL,
width = NULL,
height = NULL,
element_id = NULL
)Arguments
- mat
A numeric matrix (rows x columns).
rownames(mat)andcolnames(mat), when present, are used as row/column tick labels. A missing cell (NA,NaNor an infinite value) is drawn grey and left out of the colour range and the z-score, with a warning. Where several rows or columns share a pixel, the pixel shows the mean of their finite cells, so it is grey only when all of them are missing.- colormap
Color ramp: sequential
"viridis"or"ltc"(an earthy teal to sand to rust ramp), or diverging"rdbu"or"ltcdiv"(its counterpart, neutral cream at the midpoint).NULL(the default) uses"rdbu"whenz_scoreisTRUE, so values above and below the row mean get opposite colours, and"viridis"otherwise.- z_score
Logical; if
TRUE, each row is z-score normalized before coloring (a row-centered heatmap).- vmin, vmax
Lower/upper clamp of the color domain.
NULL(the default) auto-scales from the data. For a diverging colormap the auto domain is symmetric about zero, and a positivevmaxor a negativevmingiven alone is mirrored about zero, so zero keeps the neutral colour.- show_colorbar
Logical; draw the colorbar legend.
- legend_title
Colorbar title.
NULL(the default) uses"value", or"z-score"whenz_score = TRUE.- theme
Optional named list of theme overrides (colors, fonts, ...) merged over the component defaults in the browser.
NULLuses the default theme. Itspaddingentry is the space in px between the edge of the widget and the plot: one number for every side, or numbers namedtop,right,bottomandleftin a list or vector, a side left out keeping the default of 10. A colour given as a CSS custom property, such asbackground = "var(--bg)", takes the value the page gives it when the plot draws. After the page changes the property, what the plot drew on a canvas keeps the old colour until it draws again: resize the widget or render it again.- width, height
Widget dimensions (any valid CSS size).
- element_id
Optional explicit DOM id.
Details
The function is exported as bioheatmap() (and aliased as heatmap_plotomics())
to avoid masking stats::heatmap().