%\VignetteDepends{}
%\VignetteIndexEntry{Sequence Differential Representation}
%\VignettePackage{SeattleIntro2010}

\documentclass{beamer}

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

\title{Sequence Analysis: Differential Representation}
\author{Martin Morgan, Herv\'e Pag\`es, Nishant Gopalakrishnan \\ 
  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{Sequence Analysis}

\subsection{Work Flows}

\begin{frame}{Work Flows: Differential Representation}
  Prior to analysis
  \begin{itemize}
  \item Biological experimental design -- treatments, replication,
    etc.
  \item Sequencing preparation -- library preparation, manufacturer
    protocol, etc.
  \end{itemize}
  Analysis
  \begin{enumerate}
  \item Pre-processing (sequencing, alignment, quality assessment)
  \item Count, e.g., reads per transcript -- ChIP-seq; RNA-seq; novel
    transcript identification; microbiome; \ldots
  \item Differential representation
  \item Annotation
  \item \ldots
  \end{enumerate}
  
  \url{http://bioconductor.org/workflows} for common analyses.

\end{frame}

\begin{frame}{Third-party tools}
  \begin{itemize}
  \item Primary data generation.
  \item Aligners
    \begin{itemize}
    \item Differing in alignment flexibility (e.g., mismatches
      vs.\ indels); error models (e.g., SOLiD homopolymers);
      performance
    \item
      \href{http://bowtie-bio.sourceforge.net/}{\software{Bowtie},}
      \href{http://bio-bwa.sourceforge.net/}{\software{BWA},}
      \href{http://www.sanger.ac.uk/resources/software/ssaha2/}{\software{SSAHA2}},
      \ldots
    \end{itemize}
  \item Domain-specific
    \begin{itemize}
    \item ChIP-seq:
      \href{http://liulab.dfci.harvard.edu/MACS/}{\software{MACS}};
      \ldots
    \item RNA-seq:
      \href{http://research-pub.gene.com/gmap/}{\software{GSNAP}},
      \software{TopHat} (alignment); \software{Cufflinks} (isoform
      assembly), \ldots
    \item Variants:
      \href{http://samtools.sourceforge.net/}{\software{samtools}},
      \ldots
    \item Microbiome: ?
    \end{itemize}
  \item Comprehensive:
    \href{http://www.broadinstitute.org/gsa/wiki/index.php/The_Genome_Analysis_Toolkit}{\software{GATK}};
    \href{http://www.bioperl.org/}{\software{BioPerl}},
    \href{http://biopython.org/}{\software{Biopython}},
    \href{http://www-huber.embl.de/users/anders/HTSeq}{\software{HTSeq}}
  \item \href{http://seqanswers.com/wiki/Special:BrowseData}{SeqAnswers}
  \end{itemize}
\end{frame}

\begin{frame}{\Bioconductor{} entry points}
  \begin{itemize}
  \item Quality assessment.
  \item Preliminary read processing, e.g., demultiplexing, remediation
  \item Specialized alignment, e.g., \Rfunction{matchPDict} in
    \Biocpkg{Biostrings}.
  \item `Upstream' domain-specific work flows, e.g., ChIP-seq peak
    calling (\Biocpkg{chipseq}), RNA-seq reads per transcript
    (\Biocpkg{GenomicRanges} / \Biocpkg{IRanges} / \ldots)
  \item Statistical analysis of designed experiments, e.g.,
    \Biocpkg{edgeR}, \Biocpkg{DESeq}
  \item Specialized analysis, e.g., microbiome sequence processing and
    ecological analysis (\Rpackage{vegan}, \Rpackage{ape}, \ldots)
  \end{itemize}
\end{frame}

\subsection{Example data}

\begin{frame}{Example Data}
  \nocite{pmid18451266} Nagalakshmi et al., 2008. The transcriptional
  landscape of the yeast genome defined by RNA sequencing,
  \emph{Science} 320: 1344--1349.
  \begin{itemize}
  \item Original `RNA-seq' experiment
  \item Two different primers to generate DNA from poly(A) RNA: 
    \begin{description}
    \item [RH] Random hexamer
    \item [dT] oligo(dT)
    \end{description}
  \item Biological and technical replicates
  \item Illumina GAI -- relatively small number (<5 million / lane) of
    short (33bp) reads; poor trailing base quality.
  \end{itemize}
\end{frame}

\begin{frame}{Counting Reads}
  \begin{itemize}
  \item Retrieve results from SRA, reference sequence from UCSC.
  \item Align to reference using BWA
  \item Use \Biocpkg{GenomicFeatures} to identify exons
  \item \Rfunction{IRanges::countOverlaps} to count reads
  \item See \Rfunction{browseVignette("SeattleIntro2010")}
  \end{itemize}
\end{frame}

\subsection{Differential Representation}

\begin{frame}{\Bioconductor{} Solutions}
  Data
  \begin{itemize}
  \item Matrix (transcript $\times$ samples) of counts (caution: no
    special treatment of overlapping transcripts!)
  \item Designed experiment -- random hexamer vs.\ oligo(dT)
  \end{itemize}
  \Biocpkg{edgeR}~\cite{pmid19910308}
  \begin{itemize}
  \item Negative binomial error model (originally:(over-dispersed Poisson).
  \item Empirical Bayes to moderate over-dispersion.
  \item Recently: much more flexible experimental design -- negative
    binomial GLM -- \Rfunction{glmFit}
  \end{itemize}
  \Biocpkg{DESeq}~\cite{pmid20979621}
  \begin{itemize}
  \item Negative binomial error model
  \item Variance and mean estimation using local regression.
  \end{itemize}
\end{frame}

\begin{frame}{Issues in Analysis}
  Normalization
  \begin{itemize}
  \item Between-sample differences in total count
  \item Within-sample trade-offs in reads per transcript
  \item Approaches: robust estimates via trimmed or geometric mean
    counts or quantiles (e.g., 75th) per sample
  \end{itemize}
  Dispersion: overcoming poor estimates
  \begin{itemize}
  \item \Biocpkg{edgeR}: empirical Bayes, common dispersion.
  \item \Biocpkg{DESeq}: estimate per-gene mean and variance, then
    robust fit across genes to model mean / variance relationship
  \end{itemize}
  Significance
  \begin{itemize}
  \item Exact test (single factor; analogous to Fisher exact test)
  \item GLM likelihood ratio -- comparison of fitted to reduced model
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{\Biocpkg{DESeq} in a Nutshell}
<<DESeq-nutshell, eval=FALSE>>=
## counts: matrix of counts
## conditions: vector of treatments, corresponding 
##   to each column of counts
cds <- newCountDataSet(counts, conditions)
cds <- estimateSizeFactors(cds)
cds <- estimateVarianceFunctions(cds)

## 'top table' of differentially expressed regions
res <- nbinomTest(cds, "Condition_1", "Condition_2")
@ 
\end{frame}

\section{Subsequent Analysis}

\begin{frame}{Subsequent analysis}
  \begin{itemize}
  \item Annotation work flows
  \item Novel domain-specific approaches, e.g., ChIP-seq motif
    discovery
  \item Standard analyses tailored to sequence data, e.g.,
    \Biocpkg{goseq}.
  \item Application of microarray-style analyses.
  \end{itemize}
\end{frame}

\subsection{Lab activity}
\begin{frame}{Lab Activity}
  \begin{itemize}
  \item Exploratory assessment of `hits per transcript'
  \item \Biocpkg{DESeq} work flow
  \item Evaluation of results
  \end{itemize}
\end{frame}

\subsection{References}
\begin{frame}{References}
  \bibliography{SeattleIntro2010}
\end{frame}

\end{document}
