\HeaderA{gainLoss}{Function to compute proportion of gains and losses for each clones}{gainLoss}
\keyword{htest}{gainLoss}
\begin{Description}\relax
This function outputs lists containing proportion of gains and losses for each clone.
\end{Description}
\begin{Usage}
\begin{verbatim}
gainLoss(dat, cols, thres=0.25)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{dat}] log2ratios of the relevant array CGH object
\item[\code{cols}] indeces of the samples to use
\item[\code{thres}] global or tumor-specific threshold. defaults to 0.25
\end{ldescription}
\end{Arguments}
\begin{Value}
\begin{ldescription}
\item[\code{gainP}] Vector of proportion gained for each clones
\item[\code{lossP}] Vector of proportion lost for each clones
\end{ldescription}
\end{Value}
\begin{Author}\relax
Jane Fridlyand
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{plotFreqStat}{plotFreqStat}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

data(colorectal)

## Use mt.maxT function from multtest package to test
## differences in group means for each clone grouped by sex
##use only clones with show gain or loss in at least 10% of the samples
colnames(phenotype(colorectal))
sex <- phenotype(colorectal)$sex
sex.na <- !is.na(sex)
colorectal.na <- colorectal[ ,sex.na, keep = TRUE ]
factor <- 2.5
minChanged <- 0.1
gainloss <- gainLoss(log2.ratios(colorectal.na), cols=1:ncol(colorectal.na), thres=factor*sd.samples(colorectal.na)$madGenome)
ind.clones.use <- which(gainloss$gainP >= minChanged | gainloss$lossP>= minChanged)
#create filtered dataset
colorectal.na <- colorectal.na[ind.clones.use,keep=TRUE]
dat <- log2.ratios.imputed(colorectal.na)
resT.sex <- mt.maxT(dat, sex[sex.na],test = "t.equalvar", B = 1000)

## Plot the result along the genome
plotFreqStat(colorectal.na, resT.sex, sex[sex.na],factor=factor,titles = c("Male", "Female"))

\end{ExampleCode}
\end{Examples}

