\HeaderA{ppsetApply}{Apply a function over the ProbeSets in an AffyBatch}{ppsetApply}
\aliasA{ppset.ttest}{ppsetApply}{ppset.ttest}
\keyword{manip}{ppsetApply}
\begin{Description}\relax
Apply a function over the ProbeSets in an AffyBatch
\end{Description}
\begin{Usage}
\begin{verbatim}
ppsetApply(abatch, FUN, genenames = NULL, ...)

ppset.ttest(ppset, covariate, pmcorrect.fun = pmcorrect.pmonly, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{abatch}] An object inheriting from \code{AffyBatch}.
\item[\code{ppset}] An object of class \code{ProbeSet}.
\item[\code{covariate}] the name a covariate in the slot \code{phenoData}.
\item[\code{pmcorrect.fun}] a function to corrrect PM intensities
\item[\code{FUN}] A function working on a \code{ProbeSet} 
\item[\code{genenames}] A list of Affymetrix probesets ids to work with. All
probe set ids used when \code{NULL}.
\item[\code{...}] Optional parameters to the function \code{FUN} 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\end{Details}
\begin{Value}
Returns a \code{list} of objects, or values, as returned by the
function \code{FUN}
for each \code{ProbeSet} it processes.
\end{Value}
\begin{Author}\relax
Laurent Gautier <laurent@cbs.dtu.dk>
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{ProbeSet-class}{ProbeSet.Rdash.class}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
ppset.ttest <- function(ppset, covariate, pmcorrect.fun = pmcorrect.pmonly, ...) {
  probes <- do.call("pmcorrect.fun", list(ppset))
  my.ttest <- function(x) {
    y <- split(x, get(covariate))
    t.test(y[[1]], y[[2]])$p.value
  }
  r <- apply(probes, 1, my.ttest)
  return(r)
}

## create a dataset
data(affybatch.example)
abatch <- merge(affybatch.example, affybatch.example2)
intensity(abatch) <- 2^jitter(log2(intensity(abatch)),1,1)
chip.variate <- c("a", "b", "a", "a", "b", "a", "a")
pData(abatch) <- data.frame(whatever = chip.variate)

## run a test over _all_ probes.
all.ttest <- ppsetApply(abatch, ppset.ttest, covariate="whatever")

\end{ExampleCode}
\end{Examples}


