Draw a clustered heat map with pheatmap, keeping its values for maidr
Source:R/pheatmap_capture.R
pheatmap.RdA 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.
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.
See also
show() and save_html(), which read the result.