\HeaderA{transform.madata}{Micro Array experiment data transformation}{transform.madata}
\keyword{smooth}{transform.madata}
\begin{Description}\relax
This is the function to transform the Micro Array experiment data
based on the given method.
\end{Description}
\begin{Usage}
\begin{verbatim}
## S3 method for class 'madata':
transform(`_data`,method=c("shift","glowess","rlowess","linlog","linlogshift"),
       lolim, uplim, f=0.1, iter=3, degree=1, cg=0.3, cr=0.3, n.bin=10,
       draw=c("screen", "dev", "off"), ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{\_data}] An object of class \code{madata}.
\item[\code{method}] The smoothing method.
\item[\code{lolim}] Low shift limit. If this argument is missing, the negative
of the minimum element in the pmt data is used.
\item[\code{uplim}] High shift limit. If this argument is missing, the minimum
element in the pmt data is used. lolim and uplim are applicable only if
the method is "shift" or "linlogshift".
\item[\code{f}] The smoother span. This gives the proportion of points in the
plot which influence the smooth at each value. Larger values give
more smoothness. It is equivalent to the "span" parameter in
\code{\LinkA{loess}{loess}}.
\item[\code{iter}] The number of robustifying iterations which should be
performed. Using smaller values of iter will make lowess run
faster.
\item[\code{degree}] The degree of the polynomials to be used in loess, up to
2. This is used when method is "glowess" or "rlowess".
\item[\code{cg}] Percentage of genes to be transformed linearly for the green
channel.
\item[\code{cr}] Percentage of genes to be transformed linearly for the red
channel.
\item[\code{n.bin}] Number of bins for calculating the variance after
linlogShift.
\item[\code{draw}] Where to plot the transformation plots. "off" means
no plot. "screen" means to display the plots on screen then
x11() (in Unix/Windows) or
macintosh() (in Mac) will be called inside the function.
"dev" means to output the plots to the current device. User can use
this option to output the plot to a file. Default option is
"screen". 
\item[\code{...}] Ignored at this point.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The smoothing methods include:

shift -- the calculation of offset is based on the minimum
sum of absolute deviations (SAD). Each array will have its own offset
value. The data after shift cannot be smaller than 1.

glowess -- Intensity-based lowess. This method is to smooth the scatter
plot of Ratio (R/G) versus Intensity (R*G). The formula in the fitting
is ratio ~ intensity. 

rlowess -- Joint lowess. This method is to smooth the scatter plot
of Ratio versus Intensity and grid locations. It is the joint of
intensity-based lowess and spatial loess. You have to have the grid
location for every spot in order to use this method. The formula in
fitting is ratio ~ intesity + row + col. 

linlog -- Linear-log transformation.

linlogshift -- Linear-log shift transformation.

Previously, intensity lowess was called global lowess and joint lowess
was called regional lowess. So I use "glowess" and "rlowess" in the
method. Although the method names doesn't make too much sense, I will
keep them for the reason of backward compatibility.

If you have replicated spots and want to collapse them in
\code{\LinkA{read.madata}{read.madata}} by providing avgreps=1 or 2, you will
lose grid information and joint lowess will be unavailable.

Note that this function is only working for two-dye array.
\end{Details}
\begin{Section}{Value}
The return value is an object of class \code{madata}. Compared with the input object, the following fields
are changed:
\Itemize{
\item Field \code{data} is the transformed data.
\item Field \code{TransformMethod} will be the transformation method
applied.
}
\end{Section}
\begin{Author}\relax
Hao Wu
\end{Author}
\begin{References}\relax
Kerr and Churchill(2001), Statistical design and the analysis of gene
expression microarrays, \emph{Genetical Research}, \bold{77}:123-128.

Kerr, Martin and Churchill(2000), Analysis of variance for gene expression
microarray data, \emph{Journal of Computational Biology},
\bold{7}:819-837.

Cui, Kerr and Churchill(2002), Data transformations for cDNA
Microarray data, submitted, find manuscript in www.jax.org/research/churchill.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{loess}{loess}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# load in data
data(kidney)
# do regional loess on raw data
## Not run: 
raw.lowess <- transform.madata(kidney.raw, method="rlowess")
graphics.off()
#do shift without displaying the plot 
data1.shift <- transform.madata(kidney.raw, method="shift", lolim=-50, 
     uplim=50,draw="off")

# do global lowess and output the plots to a postscript file
postscript(file="glowess.ps")
data1.glowess <- transform.madata(kidney.raw, method="glowess", draw="dev")
graphics.off()

# do linear-log
data1.linlog <- transform.madata(kidney.raw, method="linlog")
graphics.off()

# do linear-log shift
data1.linlogshift <- transform.madata(kidney.raw, method="linlogshift", 
  lolim=-50, uplim=50)
graphics.off()
## End(Not run)
\end{ExampleCode}
\end{Examples}

