\Header{processArrayData}{Automated processing of two colour DNA microarray data}
\keyword{utilities}{processArrayData}
\begin{Description}\relax
Automated processing of image analyis result files
and related annotation information. Combines several
steps of microarray data processing, read
the package vignette for a detailed example. To access
the vignette call openVignette()
after calling library(arrayMagic).
\end{Description}
\begin{Usage}
\begin{verbatim}processArrayData(spotIdentifier = "Name", verbose = TRUE, loadPath = ".", slideDescriptionFile = "slideDescription.txt", deleteBlanks = TRUE, fileNameColumn = "fileName", slideNameColumn, type = "GenePix", dataColumns = NULL, spotAnnoColumns = NULL, channelColumn = NULL, removePattern = NULL, skip = NULL, quote = "\"'", normalisationMethod = "vsn", subtractBackground=FALSE, spotsRemovedBeforeNormalisation = NULL, spotsRemovedAfterNormalisation = NULL, subGroups = NULL, channelsSeparately = FALSE, hybridisationGroups = NULL, savePath = ".", objectsFileName, plotOutput = "screen")\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{spotIdentifier}] character string; required; default "Name".
\code{spotIdentifier} specifies the column
in the image analysis result files which contain
spot or gene identifiers
\item[\code{verbose}] logical; required; default: \code{TRUE}
\item[\code{loadPath}] character string; required; default: ".".
The path is used for loading of the \code{slideDescriptionFile}
and the image analysis result files;
note: "." refers to the working directory.

\item[\code{slideDescriptionFile}] character string;
required; default "slideDescription.txt".
The first line of the tab-deliminated file
must contain all column names, i.e. a header
line. In particular it must contain the
column named \code{fileNameColum} and possibly
additionally a column named \code{slideNameColumn}. 
\item[\code{deleteBlanks}] logical; required; default: \code{TRUE}.
If set to \code{TRUE} any blank character (space)
is removed from the text body of the
\code{slideDescriptionFile}. 
\item[\code{fileNameColumn}] character string; required; default: "fileName".
\code{fileNameColumn} specifies the column which
contains the names of all
image analysis result files.
\item[\code{slideNameColumn}] character string; optional; default missing.
If \code{slideNameColumn} is missing the value is set
to \code{fileNameColumn}.
\item[\code{channelColumn}] optional; cf. \code{\Link{readIntensities}};
default: \code{NULL} 
\item[\code{type}] character string to characterize
the file type like "GenePix" or "generic";
note e.g. "generic" requires the arguments \code{dataColumns}
and \code{spotAnnoColumns}; default: "GenePix"; cf.
\code{\Link{readIntensities}} for details
\item[\code{dataColumns}] required for \code{type} "generic";
cf. \code{\Link{readIntensities}}; default: \code{NULL} 
\item[\code{spotAnnoColumns}] required for \code{type} "generic";
cf. \code{\Link{readIntensities}}; default: \code{NULL} 
\item[\code{removePattern}] optional; cf.  \code{\Link{readIntensities}};
default: \code{NULL} 
\item[\code{skip}] optional; cf.  \code{\Link{readIntensities}};
default: \code{NULL} 
\item[\code{quote}] character string; cf. \code{\Link{readIntensities}};
required; default: \code{quote = "\\"'"}
\item[\code{normalisationMethod}] character string; required; default: "vsn";
cf. argument \code{method} of \code{\Link{normalise}} 
\item[\code{subtractBackground}] logical; required; default: \code{FALSE}
cf. \code{\Link{normalise}} 
\item[\code{spotsRemovedBeforeNormalisation}] vector of character strings;
required; default: \code{NULL}.
All spots which match the string(s) will be excluded  
already before normalisation and will not be present
in the resulting objects at all.

\item[\code{spotsRemovedAfterNormalisation}] vector of character strings;
required; default: \code{NULL};
cf. argument \code{spotsRemovedBeforeNormalisation}.

\item[\code{subGroups}] character string or \code{NULL};
required; cf. \code{\Link{normalise}};
default: \code{NULL} 
\item[\code{channelsSeparately}] logical; required;
cf. \code{\Link{normalise}};
default \code{FALSE}
\item[\code{hybridisationGroups}] list of numeric vectors;
cf. \code{\Link{normalise}};
required; default: \code{NULL}
\item[\code{savePath}] character string; required; default: ".".
The directory \code{savePath} used to store
the results (cf. argument \code{objectsFileName}
and processed files.
If the path does not exist a directory is created;
note: "." refers to the working directory.

\item[\code{objectsFileName}] character string; optional;
default missing, i.e. no file is created.
\code{objectsFileName} specifies
the name of the file used to store the object
"resultList", i.e. the return value of the function.

\item[\code{plotOutput}] character string; required; default: "screen";
Possible values: "screen", "pdf" or "win.metafile". 
\end{ldescription}
\end{Arguments}
\begin{Value}
A list of objects, i.e.  an "exprSetRGObject" and an
"arrayDataObject" with corresponding class types
\code{\Link{exprSetRG-class}} and
\code{\Link{arrayData-class}}.
Side-effects: The result list "resultList" is stored
as file \code{objectsFileName} in the directory \code{savePath}
if the argument \code{objectsFileName} is supplied.
The \code{slideDescriptionFile} is stored
with suffix "\_processed"
in the directory \code{savePath}.
\end{Value}
\begin{Author}\relax
Andreas Buness <a.buness@dkfz.de>
\end{Author}
\begin{SeeAlso}\relax
\code{\Link{readpDataSlides}},
\code{\Link{readIntensities}},
\code{\Link{processArrayDataObject}},
\code{\Link{normalise}},
\code{\Link{exprSetRG-class}},
\code{\Link{arrayData-class}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

       LOADPATH <- file.path(.path.package("arrayMagic"), "extdata")
       SAVEPATH <- tempdir()
        SLIDEDESCRIPTIONFILE <- "slideDescription"
  
        resultList <- processArrayData(
                             loadPath=LOADPATH, 
                              savePath=SAVEPATH,
                             slideDescriptionFile=SLIDEDESCRIPTIONFILE
                  )
       writeToFile(arrayDataObject=resultList$arrayDataObject,
                   exprSetRGObject=resultList$exprSetRGObject,
                   fileName="normalisedData.txt",
                   savePath=SAVEPATH)

       summarizedResult <- slideMerge(exprSetRGObject=resultList$exprSetRGObject, slideMergeColumn="replicates" )

        qPL <- qualityParameters(arrayDataObject=resultList$arrayDataObject,
                                 exprSetRGObject=resultList$exprSetRGObject)

        visualiseQualityParameters(qualityParameters=qPL$qualityParameters,
                                   savePath=tempdir())

        qualityDiagnostics(
                    arrayDataObject=resultList$arrayDataObject,
                    exprSetRGObject=resultList$exprSetRGObject,
                    qualityParametersList=qPL,
                    slideNameColumn="fileName",
                    savePath=tempdir(),
                    plotOutput="pdf")

        unlink(file.path(SAVEPATH, paste(SLIDEDESCRIPTIONFILE,"_processed",sep="")))
         resultListG <- processArrayData(
                             loadPath=LOADPATH, 
                              savePath=SAVEPATH,
                             slideDescriptionFile=SLIDEDESCRIPTIONFILE,
                             plotOutput="pdf",
                             hybridisationGroups = list((1:4),(5:9))
                  )
 unlink(file.path(SAVEPATH, paste(SLIDEDESCRIPTIONFILE,"_processed",sep="")))
 resultListG2 <- processArrayData(
                             loadPath=LOADPATH, 
                              savePath=SAVEPATH,
                             slideDescriptionFile=SLIDEDESCRIPTIONFILE,
                             plotOutput="pdf",
                             objectsFileName = "exprSetRG.RData",
                             hybridisationGroups = "slideBySlide"
                                         )
 unlink(file.path(SAVEPATH, paste(SLIDEDESCRIPTIONFILE,"_processed",sep="")))

 SLIDEDESCRIPTIONFILE <- "genericChannelsPerFile"
 spotAnnoColumns <- c("Index", "Label" , "Type" , "Name" , "ID" )
 dataColumns <- c("Normalized....","Average....","Normalized....","Average....")
 names(dataColumns) <- c("greenForeground","greenBackground",
                      "redForeground","redBackground")

 resultGenericChannel <- processArrayData(
                                spotIdentifier="Index",
                                loadPath=LOADPATH, 
                                savePath=SAVEPATH,
                                slideDescriptionFile=SLIDEDESCRIPTIONFILE,
                                normalisationMethod="none",
                                channelColumn="channel",
                                fileNameColumn="files",
                                slideNameColumn="name",
                                type="genericOneFilePerChannel",
                                spotAnnoColumns=spotAnnoColumns,
                                dataColumns=dataColumns
                            )

 unlink(file.path(SAVEPATH, paste(SLIDEDESCRIPTIONFILE,"_processed",sep="")))
 SLIDEDESCRIPTIONFILE <- "genericChannelsPerFileTwo"
 dataColumns <- c("Integral..QL.","Bkg..QL.", "Integral..QL.","Bkg..QL.")
 names(dataColumns) <- c("greenForeground","greenBackground",
                      "redForeground","redBackground")

 resultGenericChannelTwo <- processArrayData(
                                spotIdentifier="ID",
                                loadPath=LOADPATH, 
                                savePath=SAVEPATH,
                                slideDescriptionFile=SLIDEDESCRIPTIONFILE,
                                normalisationMethod="vsn",
                                channelColumn="channel",
                                fileNameColumn="files",
                                slideNameColumn="name",
                                subtractBackground=TRUE,
                                type="genericOneFilePerChannel",
                                spotAnnoColumns=spotAnnoColumns,
                                dataColumns=dataColumns
                            )
 unlink(file.path(SAVEPATH, paste(SLIDEDESCRIPTIONFILE,"_processed",sep="")))

       
 \end{ExampleCode}
\end{Examples}

