heatmap_2: Display Data as Heatmap

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/oldHeatplus.R

Description

This function displays an expression data matrix as a heatmap. It is based on an old version of heatmap in the stats package, but offers more flexibility (e.g. skipping dendrograms, skipping row/column labelling, adding a legend).

This function is just about to be deprecated. Please use regHeatmap for new projects.

Usage

1
2
3
4
heatmap_2(x, Rowv, Colv, distfun = dist, hclustfun = hclust, add.expr, 
          scale = c("row", "column", "none"), na.rm = TRUE, 
		  do.dendro = c(TRUE, TRUE), legend = 0, legfrac = 8, 
		  col = heat.colors(12), trim, ...)

Arguments

x

the numerical data matrix to be displayed.

Rowv

either a dendrogram or a vector of reordering indexes for the rows.

Colv

either a dendrogram or a vector of reordering indexes for the columns.

distfun

function to compute the distances between rows and columns. Defaults to dist.

hclustfun

function used to cluster rows and columns. Defaults to hclust.

add.expr

Expression to be evaluated after the call to image. See Details.

scale

indicates whether values should be scaled by either by row, column, or not at all. Defaults to row.

na.rm

logical indicating whther to remove NAs.

do.dendro

logical vector of length two, indicating (in this order) whether to draw the row and column dendrograms.

legend

integer between 1 and 4, indicating on which side of the plot the legend should be drawn, as in mtext.

legfrac

fraction of the plot that is taken up by the legend; larger values correspond to smaller legends.

col

the color scheme for image. The default sucks.

trim

Percentage of values to be trimmed. This helps to keep an informative color scale, see Details.

...

extra arguments to image.

Details

With all parameters at their default, this gives the same result as a very old version of heatmap that was the base for the modifications. All parameters of the same name have the same function as in heatmap, though add.expr, which can be used for adding graphical elements after the call to image, will probably not produce useful results. Note also that row- and column labels are optional, i.e. if the corresponding dimname of x is NULL, no labels are displayed.

Note that setting Rowv or Colv to NA completely suppresses re-ordering of rows or columns as well as the corresponding dendrogram. Setting both to NA works basically like image (though you can still add a legend).

Setting trim to a number between 0 and 1 uses equidistant classes between the (trim)- and (1-trim)-quantile, and lumps the values below and above this range into separate open-ended classes. If the data comes from a heavy-tailed distribution, this can save the display from putting too many values into to few classes.

Value

Same as heatmap with keep.dendro=FALSE: an invisible list giving the reordered indices of the row- and column-elements as elements rowInd and colInd.

Author(s)

Original by Andy Liaw, with revisions by Robert Gentleman and Martin Maechler.

Alexander Ploner for this version.

See Also

heatmap, hclust, heatmap_plus, regHeatmap, annHeatmap

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# create data
mm = matrix(rnorm(1000, m=1), 100,10)
mm = cbind(mm, matrix(rnorm(2000), 100, 20))
mm = cbind(mm, matrix(rnorm(1500, m=-1), 100, 15))
mm2 = matrix(rnorm(450), 30, 15)
mm2 = cbind(mm2, matrix(rnorm(900,m=1.5), 30,30))
mm=rbind(mm, mm2)
colnames(mm) = paste("Sample", 1:45)
rownames(mm) = paste("Gene", 1:130)

# similar to base heatmap
heatmap_2(mm)

# remove column dendrogram
heatmap_2(mm, do.dendro=c(TRUE, FALSE))

# add a legend under the plot
heatmap_2(mm, legend=1)
# make it smaller
heatmap_2(mm, legend=1, legfrac=10)
# ... on the left side
heatmap_2(mm, legend=2, legfrac=10)

# remove the column labels by removing the column names
colnames(mm)=NULL
heatmap_2(mm, legend=1, legfrac=10)

# truncate the data drastically
heatmap_2(mm, legend=1, legfrac=10, trim=0.1)

Example output



Heatplus documentation built on May 2, 2018, 4:03 a.m.