%\VignetteDepends{ALL}
%\VignetteIndexEntry{Introduction to Bioconductor}
%\VignettePackage{SeattleIntro2010}

\documentclass{beamer}

\usepackage{BioconductorSlides}
\SweaveOpts{keep.source=TRUE}

\title{Introduction to Bioconductor}
\author{Martin Morgan \\ Fred Hutchinson Cancer Research Center}
\date{9-10 December, 2010}

\begin{document}

<<setup, echo=FALSE>>=
options(width = 40)
@ 

\frame{\titlepage}

\section[Outline]{}

\frame{\tableofcontents}

\section{Bioconductor}

\subsection{Project Motivation and Success}

\begin{frame}{\Bioconductor{}: Analysis and Comprehension of High Throughput Genetic Data}
  \begin{description}
  \item[Goal] Help biologists understand their data
  \item[Focus]
    \begin{itemize}
    \item Expression and other microarray; flow cytometry
    \item High-throughput sequencing
    \end{itemize}
  \item[Themes]
    \begin{itemize}
    \item Open source / open development
    \item Code reuse -- statistics, visualization, domain-specific
      applications, e.g., \Biocpkg{limma}
    \item Interoperability
    \item Reproducible -- scripts, \emph{vignettes}, packages
    \end{itemize}
  \item[Success] $>400$ packages; very active mailing list; annual
    conferences (BioC2011, Seattle, July 27-29); courses; \ldots
  \end{description}
\end{frame}

\subsection{Representative Packages (Microarrays)}

\begin{frame}{Representative Packages (Microarrays)}
  \begin{description}
  \item [Pre-processing] \Biocpkg{affy}, \Biocpkg{oligo},
    \Biocpkg{lumi}, \Biocpkg{beadarray}, \Biocpkg{limma},
    \Biocpkg{genefilter}, \ldots
  \item [Machine learning] \Biocpkg{MLInterfaces}, \Biocpkg{CMA}
  \item [Differential expression] \Biocpkg{limma}, \ldots
  \item [Gene set enrichment] \Biocpkg{topGO}, \Biocpkg{GOstats},
    \Biocpkg{GSEABase}, \ldots
  \item [Annotation] \Biocpkg{AnnotationDbi}, `chip', `org' and
    \Biocpkg{BSgenome} packages
  \item [`Domain-specific'] \Biocpkg{DNAcopy}, \Biocpkg{snpMatrix},
    \ldots
  \end{description}
\end{frame}

\section{Microarrays: Work Flows}

\begin{frame}[fragile]{Work Flow: Expression Microarrays}
  Prior to analysis
  \begin{itemize}
  \item Biological experimental design -- treatments, replication,
    etc.
  \item Microarray preparation -- especially two-channel
  \end{itemize}
  Analysis
  \begin{enumerate}
  \item Pre-processing (normalization); quality assessment;
    exploratory analysis
  \item Differential expression; machine learning (clustering and
    classification)
  \item Annotation
  \item Gene set enrichment analysis
  \item \ldots
  \end{enumerate}
  
  \url{http://bioconductor.org/workflows} for common analyses.
  
\end{frame}

\begin{frame}{Example Data}
  Chiaretti et al., 2005~\cite{pmid16243790}
  \begin{itemize}
  \item 128 adult patients, newly diagnosed for ALL
  \item B- and T-lineage; various molecular and cytological
    characteristics.
  \item HG-U95Av2
  \item Pre-processed (background correction, normalization,
    summarization into probe sets).
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{The ALL dataset}
<<load ALL package>>=
library(ALL); data(ALL); ALL
@ 
\end{frame}

\begin{frame}[fragile]{\Rclass{ExpressionSet}}
  Example of an `S4' class
  \begin{itemize}
  \item Coordinate different types of data (assay, phenotype, feature,
    experiment) into a single container
  \item Reduces clerical errors, enhances interoperability and
    reproducibility
  \end{itemize}
  Manipulate with \emph{accessors} and \emph{subsetting}
<<phenoData>>=
m <- exprs(ALL)       # matrix of expression values
adf <- phenoData(ALL) # data frame-like sample description
some <- ALL[,1:10]    # first 10 samples
@ 
  Metadata, e.g., \Robject{adf}
  \begin{itemize}
  \item \Rfunction{pData(adf)}: 1 row per sample, columns representing
    measured attributes, e.g., sex, age, `fusion protein'.
  \item Data about the columns, e.g., \Rfunction{varMetadata(adf)}
  \end{itemize}
  Warning: different S4 classes have different conventions
\end{frame}

\subsection{Pre-processing}

\begin{frame}
  \frametitle{Pre-processing}
  Background correction
  \begin{itemize}
  \item One-channel: PM / MM probes
  \item Two-channel: background vs.~foreground intensities
  \end{itemize}
  Normalization
  \begin{itemize}
  \item Key assumption: most probe sets not differentially expressed;
    distribution of intensities approxiamtely equal across arrays
  \end{itemize}
  Summarization
  \begin{itemize}
  \item One-channel: from probes to probesets (approxiamtely, genes)
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
  \frametitle{One channel Affymetrix 3' expression arrays} 
  \begin{itemize}
  \item In practice:
<<one-channel-workflow, eval=FALSE, keep.source=TRUE>>=
## assume phenoData is an AnnotatedDataFrame
## "/celfile/directory" contains CEL files
setwd("/your/celfile/directory")
library(affy)
eset <- just.rma(phenoData=phenoData)
@ 
%% 
  \item Other normalizatons, e.g., \Rfunction{just.gcrma},
    \Rfunction{vsn2}; \Biocpkg{affyPLM} for detailed probe models;
    \Biocpkg{oligo} for recent arrays.
  \item \Biocpkg{limma} for two-channel arrays.
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Example: RMA (robust multi-chip average)}
  Background correction
  \begin{itemize}
  \item Observation: using MM probes is problematic when MM $>$ PM.
  \item Model PM probes as exponentially distributed signal, plus
    normal noise, \( \exp(\alpha) + N(\mu, \sigma^2) \).
  \end{itemize}
  Normalization
  \begin{itemize}
  \item Quantile normalization -- force the \emph{distribution} of
    background-corrected expression values of each array to have
    exactly the same.
  \end{itemize}
  Summarization
  \begin{itemize}
  \item Estimate probeset effect by fitting a linear model to all
    probes in each probe set, across array.
  \end{itemize}
\end{frame}

\subsection{Quality Assessment}

\begin{frame}[fragile]
  \frametitle{Quality assessment}
  \begin{itemize}
  \item In practice:
<<arrayQualityMetrics, eval=FALSE, keep.source=TRUE>>=
library(arrayQualityMetrics)
rpt <- arrayQualityMetrics(eset)
## or, as appropriate,
##   rpt <- arrayQualityMetrics(abatch)
##   rpt <- arrayQualityMetrics(rg)
browseURL(rpt)
@ 
%% 
  \item QC summary statistics: acceptable ranges for `control' probes
  \item Between-array distances: no unintended association with
    experimental conditions, e.g., run date.
  \item NUSE (normalized unscaled standard error) and RLE (relative
    log expression) plots: consistent expression and variablity across
    arrays.
  \end{itemize}
\end{frame}

\subsection{Filtering}

\begin{frame}[fragile]{Filtering probe sets}
  Use \Rfunction{nsFilter} from the \Biocpkg{genefilter} package to
  filter out probes that:
  \begin{itemize}
    \item Lack variability
    \item Are without an Entrez Gene ID annotation
    \item Map to the same Entrez Gene ID
    \item Are not annotated to GO (or other) terms
  \end{itemize}
<<nsfilter,eval=FALSE>>=
library(genefilter)
filteredESet <- nsFilter(eset, require.entrez=TRUE,
    remove.dupEntrez=TRUE, feature.exclude="^AFFX")
@ 
\end{frame}

\section{Resources}

\subsection{Lab Activity}

\begin{frame}{Lab activity}
  Goal: learn to work with S4 classes, especially
  \Rclass{ExpressionSet}
  \begin{enumerate}
  \item Load and explore \Robject{ALL} object, including finding help
    on S4 objects.
  \item Extract \Rcode{mol.biol} \Rfunction{phenoData}, subset samples
    to include only BCR/ABL or NEG.
  \item Perform quality assessment.
  \item Filter (remove) probes without gene-level annotation
  \end{enumerate}
\end{frame}

\subsection{References}

\begin{frame}{References}
  \bibliographystyle{plain}
  \bibliography{SeattleIntro2010}
\end{frame}

\begin{frame}[fragile]{sessionInfo}
<<sessionInfo, results=tex, echo=FALSE>>=
toLatex(sessionInfo())
@ 
  
\end{frame}

\end{document}
