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

xpsPreFilter(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{PreFilter}.
\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{treename}] tree name to be used in ROOT filter file.
\item[\code{xps.call}] optional object of class \code{CallTreeSet}.
\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{prefilter}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function applies the different filters initialized with constructor \code{\LinkA{PreFilter}{PreFilter}}
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 method \code{\LinkA{callFilter}{callFilter}} was initialized with constructor \code{\LinkA{PreFilter}{PreFilter}}
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}
A \code{\LinkA{FilterTreeSet}{FilterTreeSet.Rdash.class}}
\end{Value}
\begin{Author}\relax
Christian Stratowa
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{PreFilter}{PreFilter}}, \code{\LinkA{unifilter}{unifilter}}
\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_TestRMA",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_TestRMA.root:
data.rma@rootfile <- paste(.path.package("xps"),"rootdata/tmp_Test3RMA.root",sep="/")
data.rma@filedir  <- paste(.path.package("xps"),"rootdata",sep="/")

## third, construct a PreFilter
prefltr <- PreFilter(mad=c(0.5,0.01),lothreshold=c(6.0,0.02,"mean"),hithreshold=c(10.5,80.0,"percent"))

## finally, create a FilterTreeSet
rma.pfr <- prefilter(data.rma,"tmp_Test3Prefilter",getwd(),prefltr,2,verbose=FALSE)
str(rma.pfr)
\end{ExampleCode}
\end{Examples}

