\HeaderA{unifilter}{Function for Applying an UniFilter to an ExprTreeSet}{unifilter}
\aliasA{xpsUniFilter}{unifilter}{xpsUniFilter}
\aliasA{xpsUniFilter-methods}{unifilter}{xpsUniFilter.Rdash.methods}
\keyword{manip}{unifilter}
\begin{Description}\relax
This function applies an \code{\LinkA{UniFilter}{UniFilter}} to an \code{\LinkA{ExprTreeSet}{ExprTreeSet}}.
\end{Description}
\begin{Usage}
\begin{verbatim}
unifilter(xps.expr,
          filename   = character(0),
          filedir    = getwd(),
          filter     = NULL,
          minfilters = 999,
          logbase    = "log2",
          group      = character(0),
          treename   = "UniTest",
          xps.fltr   = NULL,
          xps.call   = NULL,
          update     = FALSE,
          verbose    = TRUE)

xpsUniFilter(object, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{xps.expr}] object of class \code{ExprTreeSet}.
\item[\code{filename}] file name of ROOT filter file.
\item[\code{filedir}] system directory where ROOT filter file should be stored.
\item[\code{filter}] object of class \code{UniFilter}.
\item[\code{minfilters}] minimum number of initialized filter methods to satisfy (default is all filters).
\item[\code{logbase}] convert data to logarithm of base: \code{"0"}, \code{"log"}, \code{"log2"} (default), \code{"log10"}
\item[\code{group}] a character vector assigning the trees of \code{xps.expr} to one of two groups.
\item[\code{treename}] tree name to be used in ROOT filter file.
\item[\code{xps.fltr}] optional object of class \code{FilterTreeSet}.
\item[\code{xps.call}] optional object of class \code{CallTreeSet}.
\item[\code{update}] logical. If \code{TRUE} the existing ROOT filter file \code{filename} will be updated.
\item[\code{verbose}] logical, if \code{TRUE} print status information.
\item[\code{object}] object of class \code{ExprTreeSet}.
\item[\code{...}] same arguments as function \code{unifilter}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function applies the different filters initialized with constructor \code{\LinkA{UniFilter}{UniFilter}}
to the \code{\LinkA{ExprTreeSet}{ExprTreeSet}} \code{xps.expr}.

Slot \code{minfilters} determines the minimum number of initialized filters, which must be satisfied
so that the mask is set to \code{flag=1}. For \code{minfilters=1} at least one filter must be 
satisfied, equivalent to logical \sQuote{OR}; for \code{minfilters=999} all filters must be 
satisfied, equivalent to logical \sQuote{AND}.

If pre-filtering should be done before applying function \code{unifilter} then a
\code{\LinkA{FilterTreeSet}{FilterTreeSet}} \code{xps.fltr} must be supplied, created with function
\code{\LinkA{prefilter}{prefilter}}.

If method \code{\LinkA{callFilter}{callFilter}} was initialized with constructor \code{\LinkA{UniFilter}{UniFilter}}
then \code{\LinkA{CallTreeSet}{CallTreeSet}} \code{xps.call} must be supplied, usually created with function
\code{\LinkA{mas5.call}{mas5.call}}.
\end{Details}
\begin{Value}
An \code{\LinkA{AnalysisTreeSet}{AnalysisTreeSet.Rdash.class}}
\end{Value}
\begin{Note}\relax
Internally, slot \code{group} will be converted to integer values using \code{as.integer(as.factor(group))},
thus \code{group=c("GrpA","GrpA","GrpB","GrpB")} will result in a fold-change of \code{fc=mean(GrpB)/mean(GrpA)}.
\end{Note}
\begin{Author}\relax
Christian Stratowa
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{UniFilter}{UniFilter}}, \code{\LinkA{prefilter}{prefilter}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## first, load ROOT scheme file and ROOT data file
scheme.test3 <- root.scheme(paste(.path.package("xps"),"schemes/SchemeTest3.root",sep="/"))
data.test3 <- root.data(scheme.test3, paste(.path.package("xps"),"rootdata/DataTest3_cel.root",sep="/"))

## second, create an ExprTreeSet
data.rma <- rma(data.test3,"tmp_Test3_RMA",tmpdir="",background="pmonly",normalize=TRUE,verbose=FALSE)
## note: do not copy/paste this code, it is necessary only because R CMD check fails since it does not find tmp_Test3_RMA.root:
data.rma@rootfile <- paste(.path.package("xps"),"rootdata/tmp_Test3RMA.root",sep="/")
data.rma@filedir  <- paste(.path.package("xps"),"rootdata",sep="/")

## third, construct an UniFilter
unifltr <- UniFilter(unitest=c("t.test","two.sided","none",0,0.0,FALSE,0.95,TRUE),foldchange=c(1.3,"both"),unifilter=c(0.1,"pval"))

## finally, create an AnalysisTreeSet
rma.ufr <- unifilter(data.rma,"tmp_Test3Unifilter",getwd(),unifltr,group=c("GrpA","GrpA","GrpB","GrpB"),verbose=FALSE)
str(rma.ufr)
\end{ExampleCode}
\end{Examples}

