\documentclass{article}

\begin{document}
\SweaveOpts{concordance=TRUE}
\SweaveOpts{engine=R}
%\VignetteIndexEntry{Using ESTIMATE}\\
%\VignetteKeywords{estimate, prediction}\\
%\VignettePackage{estimate}\\

\SweaveOpts{keep.source=TRUE}

\title{ESTIMATE vignette}
\author{Kosuke Yoshihara}
\maketitle

\section{Introduction}

This vignette shows an example of using the \verb@estimate@ package in R. Normal cells in tumor tissue not only influence the tumor signal in molecular studies but also play an important role in cancer biology.
The \verb@estimate@ package predicts the presence of stromal and immune cells in tumor tissue using gene expression data.

\section{Example}

We first use our data obtained from 10 ovarian cancer samples using Affymetrix U133Plus2.0 platform. It has gene-level expression data consisting 17,256 genes (row) and 10 samples (column). Second, we unify different number of genes per microarray platforms to 10,412 common genes. This algorithm uses HUGO GeneSymbols or Entrez gene IDs. Therefore, the row name in an input data must be gene symbols or Entrez gene IDs.

<<load>>=
library(estimate)
OvarianCancerExpr <- system.file("extdata", "sample_input.txt", package="estimate")
filterCommonGenes(input.f=OvarianCancerExpr, output.f="OV_10412genes.gct", id="GeneSymbol")
@

Third, we calculate stromal and immune scores that represent the presence of stromal and immune cells in tumor tissue, respectively. In addition, this function measures raw ESTIMATE score that are positively correlated with DNA copy number based tumor purity. This method is based on single sample gene set enrichment analysis (ssGSEA) algorithm.
<<estimate>>=
estimateScore("OV_10412genes.gct", "OV_estimate_score.gct", platform="affymetrix")
@

Once we calculate tumor purity, we can view the association between raw ESTIMATE score and tumor purity.
<<label=fig1plot, include=TRUE>>=
plotPurity(scores="OV_estimate_score.gct", samples="s516", platform="affymetrix")
@

\begin{center}
\includegraphics{./estimated_purity_plots/s516.png}
\end{center}


\section{Running time}
Finally, we show running time of our functions using ten ovarian cancer data.
Function \verb@unifyCommonGenes@
<<runningtime1>>=
ptm <- proc.time()
filterCommonGenes(input.f=OvarianCancerExpr, output.f="OV_10412genes.gct", id="GeneSymbol")
proc.time()-ptm
@
Function \verb@estimateScore@
<<runningtime2>>=
ptm <- proc.time()
estimateScore("OV_10412genes.gct", "OV_estimate_score.gct", platform="affymetrix")
proc.time()-ptm
@

\end{document}