\name{FilterResults}
\alias{FilterResults}
\alias{FilterResults,RolexaRun-method}
\title{FilterResults}
\description{Filter basecalling results to keep only high-quality bases}
\usage{
\S4method{FilterResults}{RolexaRun}(run=Rolexa.env,results)
FilterResults(run,...)
}
\arguments{
  \item{run}{a \link[=RolexaRun-class]{RolexaRun} object defining the run parameters}
  \item{results}{a results object from \code{\link{SeqScore}}}
  \item{\dots}{additional arguments, ignored}
}
\details{
  \code{FilterResults} filters the sequences according to the
  entropy thresholds set by 
  \code{\link[=RolexaRun-class]{IThresholds}} and applies the
  tag length cutoff
  \code{\link[=RolexaRun-class]{MinimumTagLength}}.

  The algorithm works as follows: for each tag the base entropies are
  searched for a sub-vector \code{k+1:l} such that
  \code{sum(entropy[n,5+k+1:l])<=\link[=RolexaRun-class]{IThresholds}[l]} 
  where \code{l=\link[=RolexaRun-class]{MinimumTagLength}}. If
  such a sub-vector exists, it is then extended in both direction until the
  total entropy exceeds the threshold:
  \code{sum(results[n,5+k1:k2])>\link[=RolexaRun-class]{IThresholds}[k2-k1+1]}.

  The tag is then shortened: \code{substr(results[n,5],k1,k2)}, but [ACGT]
  bases to left of \code{k1} and to the right of \code{k2} are
  added. The \code{\link[=RolexaRun-class]{Barcode}} first bases of the tags
  will always be included in a separate column if this parameter has
  been set. If \code{\link[=RolexaRun-class]{PET}=TRUE} then the whole
  procedure is applied independently to each half of the sequence (and
  two separate sets of tags and scores are returned) and
  the barcode (if any) is assumed to be in-between the two paired tags.
}
\value{
  \code{FilterResults} returns an object suitable for
  \code{\link{SaveResults}}
}
\seealso{\link[ShortRead:readFastq]{readFastq} to read fastq files,
  \code{\link{SeqScore}} and \code{\link{FilterResults}} to
  produce results for \code{SaveResults}}
\references{Probabilistic base calling of Solexa sequencing data, BMC Bioinformatics 2008, 9:431}
\author{Jacques Rougemont, Arnaud Amzallag, Christian Iseli, Laurent Farinelli, Ioannis Xenarios, Felix Naef}
\keyword{manip}
%