\HeaderA{heatdiagram}{Stemmed Heat Diagram}{heatdiagram}
\aliasA{heatDiagram}{heatdiagram}{heatDiagram}
\keyword{hplot}{heatdiagram}
\begin{Description}\relax
Creates a heat diagram showing the co-regulation of genes under one condition with a range of other conditions.
\end{Description}
\begin{Usage}
\begin{verbatim}
heatDiagram(results,coef,primary=1,names=NULL,treatments=colnames(coef),limit=NULL,orientation="landscape",low="green",high="red",cex=1,mar=NULL,ncolors=123,...)
heatdiagram(stat,coef,primary=1,names=NULL,treatments=colnames(stat),critical.primary=4,critical.other=3,limit=NULL,orientation="landscape",low="green",high="red",cex=1,mar=NULL,ncolors=123,...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{results}] \code{TestResults} matrix, containing elements -1, 0 or 1, from \code{\LinkA{decideTests}{decideTests}}
\item[\code{stat}] numeric matrix of test statistics. Rows correspond to genes and columns to treatments or contrasts between treatments.
\item[\code{coef}] numeric matrix of the same size as \code{stat}. Holds the coefficients to be displayed in the plot.
\item[\code{primary}] number or name of the column to be compared to the others. Genes are included in the diagram according to this column of \code{stat} and are sorted according to this column of \code{coef}. If \code{primary} is a name, then \code{stat} and \code{coef} must have the same column names.
\item[\code{names}] optional character vector of gene names
\item[\code{treatments}] optional character vector of treatment names
\item[\code{critical.primary}] critical value above which the test statistics for the primary column are considered significant and included in the plot
\item[\code{critical.other}] critical value above which the other test statistics are considered significant. Should usually be no larger than \code{critical.primary} although larger values are permitted.
\item[\code{limit}] optional value for \code{coef} above which values will be plotted in extreme color. Defaults to \code{max(abs(coef))}.
\item[\code{orientation}] \code{"portrait"} for upright plot or \code{"landscape"} for plot orientated to be wider than high. \code{"portrait"} is likely to be appropriate for inclusion in printed document while \code{"landscape"} may be appropriate for a presentation on a computer screen.
\item[\code{low}] color associated with repressed gene regulation
\item[\code{high}] color associated with induced gene regulation
\item[\code{ncolors}] number of distinct colors used for each of up and down regulation
\item[\code{cex}] factor to increase or decrease size of column and row text
\item[\code{mar}] numeric vector of length four giving the size of the margin widths.
Default is \code{cex*c(5,6,1,1)} for landscape and \code{cex*c(1,1,4,3)} for portrait.
\item[\code{...}] any other arguments will be passed to the \code{image} function
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Users are encouraged to use \code{heatDiagram} rather than \code{heatdiagram} as the later function may be removed in future versions of limma.

This function plots an image of gene expression profiles in which rows (or columns for portrait orientation) correspond to treatment conditions and columns (or rows) correspond to genes.
Only genes which are significantly differentially expressed in the primary condition are included.
Genes are sorted by differential expression under the primary condition.

Note: the plot produced by this function is unique to the limma package.
It should not be confused with "heatmaps" often used to display results from cluster analyses.
\end{Details}
\begin{Value}
An image is created on the current graphics device.
A matrix with named rows containing the coefficients used in the plot is also invisibly returned.
\end{Value}
\begin{Author}\relax
Gordon Smyth
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{image}{image}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
library(sma)
data(MouseArray)
MA <- normalizeWithinArrays(mouse.data,layout=mouse.setup)
design <- cbind(c(1,1,1,0,0,0),c(0,0,0,1,1,1))
fit <- lmFit(MA,design=design)
contrasts.mouse <- cbind(Control=c(1,0),Mutant=c(0,1),Difference=c(-1,1))
fit <- eBayes(contrasts.fit(fit,contrasts=contrasts.mouse))
results <- decideTests(fit,method="global",p=0.1)
heatDiagram(results,fit$coef,primary="Difference")
\end{ExampleCode}
\end{Examples}

