<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.christophchamp.com/index.php?action=history&amp;feed=atom&amp;title=Heatmap</id>
		<title>Heatmap - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.christophchamp.com/index.php?action=history&amp;feed=atom&amp;title=Heatmap"/>
		<link rel="alternate" type="text/html" href="http://wiki.christophchamp.com/index.php?title=Heatmap&amp;action=history"/>
		<updated>2026-04-30T15:22:24Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://wiki.christophchamp.com/index.php?title=Heatmap&amp;diff=3324&amp;oldid=prev</id>
		<title>Christoph at 10:07, 12 February 2007</title>
		<link rel="alternate" type="text/html" href="http://wiki.christophchamp.com/index.php?title=Heatmap&amp;diff=3324&amp;oldid=prev"/>
				<updated>2007-02-12T10:07:00Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 10:07, 12 February 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l47&quot; &gt;Line 47:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 47:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By default (scale = &amp;quot;row&amp;quot;) the rows are scaled to have mean zero and standard deviation one. There is some empirical evidence from genomic plotting that this is useful.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By default (scale = &amp;quot;row&amp;quot;) the rows are scaled to have mean zero and standard deviation one. There is some empirical evidence from genomic plotting that this is useful.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The default &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;colors &lt;/del&gt;are not pretty. Consider using enhancements such as the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;RColorBrewer package, &lt;/del&gt;http://cran.r-project.org/src/contrib/PACKAGES.html#RColorBrewer.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The default &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;colours &lt;/ins&gt;are not pretty. Consider using enhancements such as the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;http://cran.r-project.org/src/contrib/PACKAGES.html#RColorBrewer &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;RColorBrewer package]&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Value ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Value ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Christoph</name></author>	</entry>

	<entry>
		<id>http://wiki.christophchamp.com/index.php?title=Heatmap&amp;diff=3046&amp;oldid=prev</id>
		<title>Christoph at 00:57, 29 October 2006</title>
		<link rel="alternate" type="text/html" href="http://wiki.christophchamp.com/index.php?title=Heatmap&amp;diff=3046&amp;oldid=prev"/>
				<updated>2006-10-29T00:57:04Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{ModifiedSource}}&lt;br /&gt;
A '''heat map''' is a false colour image (see: &amp;lt;code&amp;gt;image(t(x))&amp;lt;/code&amp;gt;) 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.&lt;br /&gt;
&lt;br /&gt;
This article will discuss how to generate a heatmap using [[R programming language|R]].&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
 heatmap(x, Rowv=NULL, Colv=if(symm)&amp;quot;Rowv&amp;quot; else NULL,&lt;br /&gt;
         distfun = dist, hclustfun = hclust,&lt;br /&gt;
         reorderfun = function(d,w) reorder(d,w),&lt;br /&gt;
         add.expr, symm = FALSE, revC = identical(Colv, &amp;quot;Rowv&amp;quot;),&lt;br /&gt;
         scale=c(&amp;quot;row&amp;quot;, &amp;quot;column&amp;quot;, &amp;quot;none&amp;quot;), na.rm = TRUE,&lt;br /&gt;
         margins = c(5, 5), ColSideColors, RowSideColors,&lt;br /&gt;
         cexRow = 0.2 + 1/log10(nr), cexCol = 0.2 + 1/log10(nc),&lt;br /&gt;
         labRow = NULL, labCol = NULL, main = NULL,&lt;br /&gt;
         xlab = NULL, ylab = NULL,&lt;br /&gt;
         keep.dendro = FALSE, verbose = getOption(&amp;quot;verbose&amp;quot;), ...)&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;x : numeric matrix of the values to be plotted.&lt;br /&gt;
;Rowv : determines if and how the row dendrogram should be computed and reordered. Either a dendrogram or a vector of values used to reorder the row dendrogram or NA to suppress any row dendrogram (and reordering) or by default, NULL, see Details below.&lt;br /&gt;
;Colv : determines if and how the column dendrogram should be reordered. Has the same options as the Rowv argument above and additionally when x is a square matrix, Colv = &amp;quot;Rowv&amp;quot; means that columns should be treated identically to the rows.&lt;br /&gt;
;distfun : function used to compute the distance (dissimilarity) between both rows and columns. Defaults to dist.&lt;br /&gt;
;hclustfun : function used to compute the hierarchical clustering when Rowv or Colv are not dendrograms. Defaults to hclust.&lt;br /&gt;
;reorderfun : function(d,w) of dendrogram and weights for reordering the row and column dendrograms. The default uses reorder.dendrogram.&lt;br /&gt;
;add.expr : expression that will be evaluated after the call to image. Can be used to add components to the plot.&lt;br /&gt;
;symm : logical indicating if x should be treated symmetrically; can only be true when x is a square matrix.&lt;br /&gt;
;revC : logical indicating if the column order should be reversed for plotting, such that e.g., for the symmetric case, the symmetry axis is as usual.&lt;br /&gt;
;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 &amp;quot;row&amp;quot; if symm false, and &amp;quot;none&amp;quot; otherwise.&lt;br /&gt;
;na.rm : logical indicating whether NA's should be removed.&lt;br /&gt;
;margins : numeric vector of length 2 containing the margins (see par(mar= *)) for column and row names, respectively.&lt;br /&gt;
;ColSideColors : (optional) character vector of length ncol(x) containing the color names for a horizontal side bar that may be used to annotate the columns of x.&lt;br /&gt;
;RowSideColors : (optional) character vector of length nrow(x) containing the color names for a vertical side bar that may be used to annotate the rows of x.&lt;br /&gt;
;cexRow, cexCol : positive numbers, used as cex.axis in for the row or column axis labeling. The defaults currently only use number of rows or columns, respectively.&lt;br /&gt;
;labRow, labCol : character vectors with row and column labels to use; these default to rownames(x) or colnames(x), respectively.&lt;br /&gt;
;main, xlab, ylab : main, x- and y-axis titles; defaults to none.&lt;br /&gt;
;keep.dendro : logical indicating if the dendrogram(s) should be kept as part of the result (when Rowv and/or Colv are not NA).&lt;br /&gt;
;verbose : logical indicating if information should be printed.&lt;br /&gt;
;... : additional arguments passed on to image, e.g., col specifying the colors.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
&lt;br /&gt;
If either Rowv or Colv are dendrograms they are honored (and not reordered). Otherwise, dendrograms are computed as dd &amp;lt;- as.dendrogram(hclustfun(distfun(X))) where X is either x or t(x).&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;- rowMeans(x, na.rm=na.rm). If either is NULL, no reordering will be done for the corresponding side.&lt;br /&gt;
&lt;br /&gt;
By default (scale = &amp;quot;row&amp;quot;) the rows are scaled to have mean zero and standard deviation one. There is some empirical evidence from genomic plotting that this is useful.&lt;br /&gt;
&lt;br /&gt;
The default colors are not pretty. Consider using enhancements such as the RColorBrewer package, http://cran.r-project.org/src/contrib/PACKAGES.html#RColorBrewer.&lt;br /&gt;
&lt;br /&gt;
== Value ==&lt;br /&gt;
&lt;br /&gt;
Invisibly, a list with components&lt;br /&gt;
rowInd 	row index permutation vector as returned by order.dendrogram.&lt;br /&gt;
colInd 	column index permutation vector.&lt;br /&gt;
Rowv 	the row dendrogram; only if input Rowv was not NA and keep.dendro is true.&lt;br /&gt;
Colv 	the column dendrogram; only if input Colv was not NA and keep.dendro is true.&lt;br /&gt;
Note&lt;br /&gt;
&lt;br /&gt;
Unless Rowv = NA (or Colw = NA), the original rows and columns are reordered in any case to match the dendrogram, e.g., the rows by order.dendrogram(Rowv) where Rowv is the (possibly reorder()ed) row dendrogram.&lt;br /&gt;
&lt;br /&gt;
heatmap() uses layout and draws the image in the lower right corner of a 2x2 layout. Consequentially, it can not be used in a multi column/row layout, i.e., when par(mfrow= *) or (mfcol= *) has been called.&lt;br /&gt;
&lt;br /&gt;
== Author(s) ==&lt;br /&gt;
Andy Liaw, original; R. Gentleman, M. Maechler, W. Huber, revisions.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* &amp;lt;code&amp;gt;image, hclust&amp;lt;/code&amp;gt;&lt;br /&gt;
* [http://www.colorbrewer.org/ ColorBrewer]&lt;br /&gt;
* [http://cran.r-project.org/src/contrib/Descriptions/RColorBrewer.html RColorBrewer]&lt;br /&gt;
&lt;br /&gt;
; pdbdistplot : retrieves the entry PDBid from the Protein Data Bank (PDB) database and creates a heat map showing interatom distances and a spy plot showing the residues where the minimum distances apart are less than 7 Angstroms.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
require(graphics)&lt;br /&gt;
x  &amp;lt;- as.matrix(mtcars)&lt;br /&gt;
rc &amp;lt;- rainbow(nrow(x), start=0, end=.3)&lt;br /&gt;
cc &amp;lt;- rainbow(ncol(x), start=0, end=.3)&lt;br /&gt;
hv &amp;lt;- heatmap(x, col = cm.colors(256), scale=&amp;quot;column&amp;quot;,&lt;br /&gt;
              RowSideColors = rc, ColSideColors = cc, margin=c(5,10),&lt;br /&gt;
              xlab = &amp;quot;specification variables&amp;quot;, ylab= &amp;quot;Car Models&amp;quot;,&lt;br /&gt;
              main = &amp;quot;heatmap(&amp;lt;Mtcars data&amp;gt;, ..., scale = \&amp;quot;column\&amp;quot;)&amp;quot;)&lt;br /&gt;
str(hv) # the two re-ordering index vectors&lt;br /&gt;
&lt;br /&gt;
## no column dendrogram (nor reordering) at all:&lt;br /&gt;
heatmap(x, Colv = NA, col = cm.colors(256), scale=&amp;quot;column&amp;quot;,&lt;br /&gt;
        RowSideColors = rc, margin=c(5,10),&lt;br /&gt;
        xlab = &amp;quot;specification variables&amp;quot;, ylab= &amp;quot;Car Models&amp;quot;,&lt;br /&gt;
        main = &amp;quot;heatmap(&amp;lt;Mtcars data&amp;gt;, ..., scale = \&amp;quot;column\&amp;quot;)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## &amp;quot;no nothing&amp;quot;&lt;br /&gt;
heatmap(x, Rowv = NA, Colv = NA, scale=&amp;quot;column&amp;quot;,&lt;br /&gt;
        main = &amp;quot;heatmap(*, NA, NA) ~= image(t(x))&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
round(Ca &amp;lt;- cor(attitude), 2)&lt;br /&gt;
symnum(Ca) # simple graphic&lt;br /&gt;
heatmap(Ca,             symm = TRUE, margin=c(6,6))# with reorder()&lt;br /&gt;
heatmap(Ca, Rowv=FALSE, symm = TRUE, margin=c(6,6))# _NO_ reorder()&lt;br /&gt;
&lt;br /&gt;
## For variable clustering, rather use distance based on cor():&lt;br /&gt;
symnum( cU &amp;lt;- cor(USJudgeRatings) )&lt;br /&gt;
&lt;br /&gt;
hU &amp;lt;- heatmap(cU, Rowv = FALSE, symm = TRUE, col = topo.colors(16),&lt;br /&gt;
             distfun = function(c) as.dist(1 - c), keep.dendro = TRUE)&lt;br /&gt;
## The Correlation matrix with same reordering:&lt;br /&gt;
round(100 * cU[hU[[1]], hU[[2]]])&lt;br /&gt;
## The column dendrogram:&lt;br /&gt;
str(hU$Colv)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Source ==&lt;br /&gt;
* [http://cran.r-project.org/manuals.html The R manual] (''modified'')&lt;br /&gt;
&lt;br /&gt;
[[Category:R]]&lt;/div&gt;</summary>
		<author><name>Christoph</name></author>	</entry>

	</feed>