heatmap {mva} | R Documentation |
A heat map is a false color image with a dendrogram added to the left side and to the top. Typically reordering of the rows and columns according to some set of values (row or column means) within the restrictions imposed by the dendrogram is carried out.
heatmap(x, Rowv, Colv, distfun = dist, hclustfun = hclust, add.expr,
scale=c("row", "column", "none"), na.rm = TRUE, ...)
x |
numeric matrix of the values to be plotted. |
Rowv |
either a |
Colv |
either a dendrogram or a vector of values used to reorder the column dendrogram. |
distfun |
function used to compute the distance (dissimilarity)
between both rows and columns. Defaults to |
hclustfun |
function used to compute the hierarchical clustering
when |
add.expr |
expression that will be evaluated after the call to
|
scale |
character indicating if the values should be centered and
scaled in either the row direction or the column direction, or
none. The default is |
na.rm |
logical indicating whether |
... |
additional arguments passed on to |
If either Rowv
or Colv
are dendrograms they are honored
(and not reordered). Otherwise, dendrograms are computed as
dd <- as.dendrogram(hclustfun(distfun(X)))
where X
is
either x
or t(x)
.
If either is a vector (of “weights”) then the appropriate dendrogram
is reordered according to the supplied values subject to the
constraints imposed by the dendrogram, by reorder(dd, Rowv)
,
in the row case. If either is missing, as by default, then the
ordering of the corresponding dendrogram is by the mean value of the
rows/columns, i.e., in the case of rows,
Rowv <- rowMeans(x, na.rm=na.rm)
.
By default (scale = "row"
) the rows are scaled to have mean
zero and standard deviation one. There is some empirical evidence
from genomic plotting that this is useful.
The default colors are not pretty. Consider using RColorBrewer.
Invisibly, a list with components
rowInd |
row index permutation vector as returned by
|
colInd |
column index permutation vector. |
Andy Liaw, original; R. Gentleman and M. Maechler, revisions.
image
, hclust
set.seed(132)
x <- matrix(runif(1000), 50, 20)
hv <- heatmap(x, col = topo.colors(32), main = "Random U[0,1] heatmap")
str(hv) # the two re-ordering index vectors
data(volcano)
## Volcano is not recognizable, but at least not random
heatmap(volcano, col = gray(0:64/64))