%
% NOTE -- ONLY EDIT THE .Rnw FILE!!!  The .tex file is
% likely to be overwritten.
%
% \VignetteIndexEntry{Lab 3A}
%\VignetteDepends{Biobase,marrayNorm,marrayPlots}
%\VignetteKeywords{Microarray}
\documentclass[12pt]{article}

\usepackage{amsmath,pstricks}
\usepackage[authoryear,round]{natbib}
\usepackage{hyperref}


\textwidth=6.2in
\textheight=8.5in
%\parskip=.3cm
\oddsidemargin=.1in
\evensidemargin=.1in
\headheight=-.3in

\newcommand{\scscst}{\scriptscriptstyle}
\newcommand{\scst}{\scriptstyle}

\bibliographystyle{plainnat}

\title{Lab 3A: An Introduction to Bioconductor's {\tt marray} packages}

\begin{document}
%'
\maketitle

In this lab, we demonstrate the main functions in the \verb+marray+
suite of packages for diagnostic plots and normalization of two-color
spotted microarray data. To load the packages

<<loadpacks>>=
library(marrayNorm)
@

For a more detailed introduction, consult the package vignettes which
can be listed by the command {\tt openVignette()}. A demo for
\verb+marrayPlots+ can also be accessed by {\tt demo(marrayPlots)}. We
will work with the sample dataset \verb+swirl+; for a description of
\verb+swirl+, type {\tt ? swirl}. To load this dataset

<<loaddata>>=
data(swirl)
@

%%%%%%%%%%%%%%%%%%%%%%%%%
%%% marrayClasses

\section{Basic classes and methods: {\tt marrayClasses} package}

One of the main classes in \verb+marrayClasses+ is the \verb+marrayLayout+
class; it is used to keep track of important layout parameters, such as the total number of spotted probe sequences on the array, the dimensions of
     the spot and grid matrices, the plate origin of the probes,
     information on spotted control sequences.
For details on this class consult the help file, {\tt ?
marrayLayout. Two other important classes are
\verb+marrayRaw+ and \verb+marrayNorm+, which represent, respectively,
pre-normalization and post-normalization intensity data for a batch
     of spotted microarrays. Methods for manipulating instances of these
classes are also described in the help files.

The object \verb+swirl+  is an instance of the class
\verb+marrayRaw+. Try the following commands to obtain information on
this object

<<swirl1>>=
class(swirl)
slotNames(swirl)
swirl
@


To access individual slots

<<swirl2>>=

maLayout(swirl)
maGnames(swirl)
@

As with other microarray objects in Bioconductor packages, you can
use subsetting commands for {\tt marrayRaw} objects

<<sub>>=
sw<-swirl[1:100,2]
class(sw)
sw
@

You can access red and green foreground and background intensities,
and log ratios as follows
<<RG>>=
Gb<-maGb(swirl)
dim(Gb)
Gb[1:5,]
Rf<-maRf(swirl)
dim(Rf)
Rf[1:5,]
M<-maM(swirl)
dim(M)
@


%%%%%%%%%%%%%%%%%%%%%%%%%
%%% marrayInput

\section{Reading in data: {\tt marrayInput} package}

Functions and widgets for reading in spotted array data are
provided in the \verb+marrayInput+ package, see for example {\tt ?
read.marrayRaw} or {\tt ? widget.marrayRaw}.


%%%%%%%%%%%%%%%%%%%%%%%%%
%%% marrayPlots

\section{Diagnostic plots: {\tt marrayPlots} package}

The \verb+marrayPlots+ package provides functions for diagnostic plots
of microarray spot statistics.

To produce a spatial image of background intensities for the Cy3
channel in the third array
<<image1,fig=TRUE>>=
tmp<-maImage(swirl[,3],x="maGb",bar=FALSE)
@

To produce a spatial image of log ratios for the first array in the batch
<<image2,fig=TRUE>>=
tmp<-maImage(swirl[,1],col=maPalette(low="blue",high="yellow"),bar=FALSE)
@

To produce boxplots of log ratios by sector for the first array in the batch
<<boxplot1,fig=TRUE>>=
maBoxplot(swirl[,1])
@


To produce boxplots of log ratios by plate for the second array in the batch
<<boxplot2,fig=TRUE>>=
maPlate(swirl)<-maCompPlate(swirl,n=384)
maBoxplot(swirl[,2],x="maPlate",names=NULL)
@

For boxplots of log ratios for all four arrays
<<boxplot3,fig=TRUE>>=
maBoxplot(swirl)
@


%%%%%%%%%%%%%%%%%%%%%%%%%
%%% marrayNorm

\section{Normalization: {\tt marrayNorm} package}

The \verb+marrayNorm+ package implements robust adaptive location and
scale normalization procedures, which correct for different types of dye
biases (e.g., intensity, spatial, plate biases).

The main location and scale normalization function is
\verb+maNormMain+. Simpler wrapper functions are provided in
\verb+maNorm+ and \verb+maNormScale+.
The function operate on objects of class \verb+marrayRaw+ (or possibly \verb+marrayNorm+, if normalization is performed in several steps) and return objects of class
\verb+marrayNorm+.

For within-print-tip-group loess location normalization of batch swirl

<<norm>>=
swirl.norm<-maNormMain(swirl)
@

For boxplots of post-normalization log-ratios
<<boxplot4,fig=TRUE>>=
maBoxplot(swirl.norm[,1])
@

<<boxplot5,fig=TRUE>>=
maBoxplot(swirl.norm)
@







\end{document}
