Skip to contents

A wrapper of pheatmap::pheatmap() that library(maidr) puts on the search path. It calls the original with every argument unchanged, draws exactly what it draws and returns what it returns, with one addition: the matrix the chart was drawn from, kept with the result so that show() and save_html() announce each cell's exact value.

Usage

pheatmap(mat, ...)

Arguments

mat

The numeric matrix to draw, as pheatmap::pheatmap() takes it

...

Every other argument of pheatmap::pheatmap(), passed on unchanged

Value

What pheatmap::pheatmap() returns, invisibly, with the drawn matrix as its "maidr_matrix" attribute

Details

pheatmap::pheatmap() returns its trees and its drawing but not its matrix. Without this wrapper – a chart drawn by a call to pheatmap::pheatmap() by name, before maidr was loaded, or with 'pheatmap' attached after maidr, which then masks this function – maidr can only read each cell back from its colour, to within one band of the legend, and says so.

The matrix kept is the one drawn: the input after scale = "row" or "column", computed as pheatmap computes it; the k-means centres with kmeans_k; in the order of the row and column trees.

Attach order

Attach 'pheatmap' before maidr, or call maidr::pheatmap():

library(pheatmap)
library(maidr)

See also

show() and save_html(), which read the result.

Examples

if (requireNamespace("pheatmap", quietly = TRUE)) {
  m <- matrix(rnorm(20), 4, 5, dimnames = list(letters[1:4], LETTERS[1:5]))
  p <- maidr::pheatmap(m, silent = TRUE)
  maidr::save_html(p, file = tempfile(fileext = ".html"))
}