View source: R/utils.heatmap.r
| utils.heatmap | R Documentation |
A heat map is a false‐color image with optional row/column dendrograms and extensive customization of scaling, coloring, labeling, and layout.
utils.heatmap(
x,
Rowv = TRUE,
Colv = if (symm) "Rowv" else TRUE,
distfun = dist,
hclustfun = hclust,
dendrogram = c("both", "row", "column", "none"),
reorderfun = function(d, w) reorder(d, w),
symm = FALSE,
scale = c("none", "row", "column"),
na.rm = TRUE,
revC = identical(Colv, "Rowv"),
add.expr,
breaks,
symbreaks = any(x < 0, na.rm = TRUE) || scale != "none",
col = "heat.colors",
colsep,
rowsep,
sepcolor = "white",
sepwidth = c(0.05, 0.05),
cellnote,
notecex = 1,
notecol = "cyan",
na.color = par("bg"),
trace = c("column", "row", "both", "none"),
tracecol = "cyan",
hline = median(breaks),
vline = median(breaks),
linecol = tracecol,
margins = c(5, 5),
ColSideColors = NULL,
RowSideColors = NULL,
cexRow = 0.2 + 1/log10(nr),
cexCol = 0.2 + 1/log10(nc),
labRow = NULL,
labCol = NULL,
srtRow = NULL,
srtCol = NULL,
adjRow = c(0, NA),
adjCol = c(NA, 0),
offsetRow = 0.5,
offsetCol = 0.5,
colRow = NULL,
colCol = NULL,
key = TRUE,
keysize = 1.5,
density.info = c("histogram", "density", "none"),
denscol = tracecol,
symkey = any(x < 0, na.rm = TRUE) || symbreaks,
densadj = 0.25,
key.title = NULL,
key.xlab = NULL,
key.ylab = NULL,
key.xtickfun = NULL,
key.ytickfun = NULL,
key.par = list(),
main = NULL,
xlab = NULL,
ylab = NULL,
lmat = NULL,
lhei = NULL,
lwid = NULL,
extrafun = NULL,
...
)
x |
Numeric matrix of the values to be plotted. |
Rowv |
Logical, dendrogram, or vector. Controls row‐dendrogram creation and/or reordering. |
Colv |
Logical, dendrogram, or vector. Controls column‐dendrogram creation and/or reordering; may be "Rowv" for square matrices. |
distfun |
Function to compute distances; defaults to |
hclustfun |
Function to cluster; defaults to |
dendrogram |
Which dendrogram(s) to draw: "both", "row", "column", or "none". |
reorderfun |
Function to reorder dendrogram given weights. |
symm |
Logical; treat |
scale |
Character: "none", "row", or "column" scaling of |
na.rm |
Logical; remove |
revC |
Logical; reverse column order for plotting. |
add.expr |
Expression to evaluate after the heat map image is drawn. |
breaks |
Numeric vector or integer: breakpoints for color bins. |
symbreaks |
Logical; force symmetric breaks around zero. |
col |
Color palette or function; defaults to |
colsep, rowsep |
Integer vectors; where to put separator lines between blocks. |
sepcolor |
Color for separators. |
sepwidth |
Numeric vector of length 2; widths of separators relative to cell size. |
cellnote |
Optional character matrix for annotating each cell. |
notecex |
Numeric; scaling for |
notecol |
Color for |
na.color |
Color for |
trace |
Character: "column", "row", "both", or "none" for trace lines. |
tracecol |
Color for trace lines. |
hline, vline |
Numeric vectors; values at which to draw horizontal/vertical lines. |
linecol |
Color for |
margins |
Numeric vector of length 2; margins for column and row labels. |
ColSideColors, RowSideColors |
Optional color vectors for side bars [default NULL]. |
cexRow, cexCol |
Numeric; character expansion for row/column labels. |
labRow, labCol |
Character vectors of labels; defaults to row/column names. |
srtRow, srtCol |
Rotation angles for row/column labels. |
adjRow, adjCol |
Justification for row/column labels. |
offsetRow, offsetCol |
Numeric offsets (in character widths) for labels. |
colRow, colCol |
Color(s) for row/column label text. |
key |
Logical; draw a color key. |
keysize |
Numeric; size of the color key. |
density.info |
Character: "histogram", "density", or "none" on the key. |
denscol |
Color for density plot. |
symkey |
Logical; symmetric key around zero. |
densadj |
Numeric; adjustment for density bandwidth. |
key.title, key.xlab, key.ylab |
Main title and axis labels for key. |
key.xtickfun, key.ytickfun |
Functions for tick placement on key axes. |
key.par |
List of graphical parameters for the key. |
main, xlab, ylab |
Main title and axis labels for the heat map. |
lmat |
Matrix specifying layout positions. |
lhei |
Numeric vector specifying row heights in layout. |
lwid |
Numeric vector specifying column widths in layout. |
extrafun |
Function to call after plotting (e.g. add scatterplot). |
... |
Additional arguments passed to |
This function is a modified copy of gplots::heatmap.2,
vendored so that dendrogram leaf labels can be drawn and colored
(via dendextend, arguments colRow/colCol) - the
original suppresses them. Other local modifications: dendrogram
margins auto-sized from the column names,
ColSideColors/RowSideColors default to NULL, and a
local invalid2() replaces gplots' unexported helper.
If Rowv or Colv are dendrograms, they are honored
without reordering; otherwise they are computed via
as.dendrogram(hclustfun(distfun(...))) and optionally reordered.
Scaling centers and scales rows or columns when requested. The
default color palette may be enhanced via packages such as
RColorBrewer. Layout may be customized with
lmat, lwid, and lhei as in layout.
Invisibly, a list with components:
Row permutation vector.
Column permutation vector.
Matched function call.
Row means and SDs (if scale="row").
Column means and SDs (if scale="column").
Reordered/scaled matrix used for the image.
Dendrogram objects.
Breakpoints used for colors.
Colors used.
Center‐line values for trace (if used).
Data frame of color bins and ranges.
List with lmat, lhei, lwid.
The original rows and columns are reordered to match the dendrograms.
Because heatmap.2 uses layout, it cannot be used
inside another layout (e.g. par(mfrow=...)).
Andy Liaw (original); R. Gentleman, M. Maechler, W. Huber, G. Warnes (revisions)
data(mtcars)
x <- as.matrix(mtcars)
utils.heatmap(x)
utils.heatmap(x, dendrogram = "none")
utils.heatmap(x, scale = "row", col = cm.colors(255))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.