\HeaderA{normalizePlateMedian}{Median normalization of the data and data transformation}{normalizePlateMedian}
\keyword{manip}{normalizePlateMedian}
\begin{Description}\relax
Plate median normalization of the data \code{xraw} of a cellHTS object.
Optionally, a data transformation such \code{log}, and a
transformation to z-scores can be performed.
\end{Description}
\begin{Usage}
\begin{verbatim}
normalizePlateMedian(x, transform, zscore)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a \code{cellHTS} object that has already been configured (see details).
\item[\code{transform}] a function that takes a numeric vector and returns a
numeric vector of the same length; for example, the logarithm
function \code{\LinkA{log}{log}}.
\item[\code{zscore}] indicates if the data should be centered and scaled after
normalization and transformation. If missing (default), the data will
not be centered and scaled. Otherwise, the value of this argument
should be a character string, either "+" or "-", which will be used to set the sign 
for the calculated z-scores (see details).
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For each plate, replicate and batch, the median value across
the wells annotated as \code{sample} in \code{x\$wellAnno} is
calculated. Then, every measurement is divided by this value.

If \code{transform} is not missing, the chosen data transformation is applied. 
Most commonly, this option can be used to apply a log transformation.

If \code{zscore} is not missing, a robust z-score for each individual
measurement will be determined for each plate and each well by
subtracting the overall \code{\LinkA{median}{median}} and dividing by the overall
\code{\LinkA{mad}{mad}}. These are taken by considering
the distribution of intensities (over all plates) in the wells whose
content is annotated as \code{sample}.  The allowed values for
\code{zscore} ("+" or "-") are used to set the sign of the calculated z-scores.
For example, with a \code{zscore="-"} a strong decrease in the signal will be 
represented by a positive z-score, whereas setting \code{zscore="+"}, 
such a phenotype will be represented by a negative z-score.  
This option can be set to calculate the results to the commonly used convention.
\end{Details}
\begin{Value}
An object of class \code{cellHTS}, which is a copy of the argument
\code{x}, plus an additional slot \code{xnorm} containing the normalized
data. This is an array of the same dimensions as \code{xraw}.

Moreover, the processing status of the \code{cellHTS} object is updated
in the slot \code{state} to \code{state["normalized"]=TRUE}.
\end{Value}
\begin{Author}\relax
Ligia Braz \email{ligia@ebi.ac.uk}, Wolfgang Huber \email{huber@ebi.ac.uk}
\end{Author}
\begin{References}\relax
..
\end{References}
\begin{Examples}
\begin{ExampleCode}
 datadir = system.file("KcViabSmall", package = "cellHTS")
 x = readPlateData("Platelist.txt", "KcViabSmall", path=datadir)
 confFile = system.file("KcViabSmall", "Plateconf.txt", package="cellHTS")
 logFile  = system.file("KcViabSmall", "Screenlog.txt", package="cellHTS")
 descripFile  = system.file("KcViabSmall", "DESCRIPTION.txt", package="cellHTS")
 x = configure(x, confFile, logFile, descripFile)
 x = normalizePlateMedian(x, zscore="-")
\end{ExampleCode}
\end{Examples}

