\HeaderA{plotMA}{MA-Plot}{plotMA}
\keyword{hplot}{plotMA}
\begin{Description}\relax
Creates an MA-plot with color coding for control spots.
\end{Description}
\begin{Usage}
\begin{verbatim}
plotMA(MA, array=1, xlab="A", ylab="M", main=colnames(MA)[array], xlim=NULL, ylim=NULL, status, values, pch, col, cex, legend=TRUE, zero.weights=FALSE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{MA}] an \code{RGList}, \code{MAList} or \code{MArrayLM} object, or any list with components \code{M} containing log-ratios and \code{A} containing average intensities.
Alternatively a \code{matrix} or \code{ExpressionSet} object.
\item[\code{array}] integer giving the array to be plotted. Corresponds to columns of \code{M} and \code{A}.
\item[\code{xlab}] character string giving label for x-axis
\item[\code{ylab}] character string giving label for y-axis
\item[\code{main}] character string giving title for plot
\item[\code{xlim}] numeric vector of length 2 giving limits for x-axis, defaults to min and max of the data
\item[\code{ylim}] numeric vector of length 2 giving limits for y-axis, defaults to min and max of the data
\item[\code{status}] character vector giving the control status of each spot on the array, of same length as the number of rows of \code{MA\$M}.
If omitted, all points are plotted in the default color, symbol and size.
\item[\code{values}] character vector giving values of \code{status} to be highlighted on the plot. Defaults to unique values of \code{status}.
Ignored if there is no \code{status} vector.
\item[\code{pch}] vector or list of plotting characters. Default is integer code 16 which gives a solid circle.
Ignored is there is no \code{status} vector.
\item[\code{col}] numeric or character vector of colors, of the same length as \code{values}. Defaults to \code{1:length(values)}.
Ignored if there is no \code{status} vector.
\item[\code{cex}] numeric vector of plot symbol expansions, of the the same length as \code{values}. 
Defaults to 0.2 for the most common status value and 1 for the others.
Ignored if there is no \code{status} vector.
\item[\code{legend}] logical, should a legend of plotting symbols and colors be included. Ignored if there is no \code{status} vector.
\item[\code{zero.weights}] logical, should spots with zero or negative weights be plotted?
\item[\code{...}] any other arguments are passed to \code{plot}
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
An MA-plot is a plot of log-intensity ratios (M-values) versus log-intensity averages (A-values).
If \code{MA} is an \code{RGList} or \code{MAList} then this function produces an ordinary within-array MA-plot.
If \code{MA} is an \code{MArrayLM} object, then the plot is an fitted model MA-plot in which the estimated coefficient is on the y-axis and the average A-value is on the x-axis.

If \code{MA} is a \code{matrix} or \code{ExpressionSet} object, then this function produces a between-array MA-plot.
In this case the A-values in the plot are the average log-intensities across the arrays and the M-values are the deviations of the log-intensities for the specified array from the average.
If there are more than five arays, then the average is computed robustly using medians.
With five or fewer arrays, it is computed by means.

The \code{status} vector is intended to specify the control status of each spot, for example "gene", "ratio control", "house keeping gene", "buffer" and so on.
The vector is usually computed using the function \code{\LinkA{controlStatus}{controlStatus}} and a spot-types file.
However the function may be used to highlight any subset of spots.

The \code{status} can be included as the component \code{MA\$genes\$Status} instead of being passed as an argument to \code{plotMA}.
The arguments \code{values}, \code{pch}, \code{col} and \code{cex} can be included as attributes to \code{status} instead of being passed as arguments to \code{plotMA}.

See \code{\LinkA{points}{points}} for possible values for \code{pch}, \code{col} and \code{cex}.
\end{Details}
\begin{Value}
A plot is created on the current graphics device.
\end{Value}
\begin{Author}\relax
Gordon Smyth
\end{Author}
\begin{References}\relax
See \url{http://www.statsci.org/micrarra/refs/maplots.html}
\end{References}
\begin{SeeAlso}\relax
An overview of diagnostic functions available in LIMMA is given in \LinkA{09.Diagnostics}{09.Diagnostics}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
MA <- new("MAList")
MA$A <- runif(300,4,16)
MA$M <- rt(300,df=3)
status <- rep("Gene",300)
status[1:3] <- "M=0"
MA$M[1:3] <- 0
status[4:6] <- "M=3"
MA$M[4:6] <- 3
status[7:9] <- "M=-3"
MA$M[7:9] <- -3
plotMA(MA,main="MA-Plot with Simulated Data",status=status,values=c("M=0","M=3","M=-3"),col=c("blue","red","green"))

#  Same as above
attr(status,"values") <- c("M=0","M=3","M=-3")
attr(status,"col") <- c("blue","red","green")
plotMA(MA,main="MA-Plot with Simulated Data",status=status)

#  Same as above
MA$genes$Status <- status
plotMA(MA,main="MA-Plot with Simulated Data")
\end{ExampleCode}
\end{Examples}

