This help topic is for R version 1.7.1. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/mva/html/heatmap.html
heatmap {mva}R Documentation

Draw a Heat Map

Description

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.

Usage

heatmap(x, Rowv, Colv, distfun = dist, hclustfun = hclust, add.expr,
        scale=c("row", "column", "none"), na.rm = TRUE, ...)

Arguments

x

numeric matrix of the values to be plotted.

Rowv

either a dendrogram or a vector of values used to reorder the row dendrogram or by default, missing, see Details below.

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 dist.

hclustfun

function used to compute the hierarchical clustering when Rowv or Colv are not dendrograms. Defaults to hclust.

add.expr

expression that will be evaluated after the call to image. Can be used to add components to the plot.

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 "row".

na.rm

logical indicating whether NA's should be removed.

...

additional arguments passed on to image, e.g., col specifying the colors.

Details

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.

Value

Invisibly, a list with components

rowInd

row index permutation vector as returned by order.dendrogram.

colInd

column index permutation vector.

Author(s)

Andy Liaw, original; R. Gentleman and M. Maechler, revisions.

See Also

image, hclust

Examples

  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))