% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/combineMultFilterNAimput.R
\name{combineMultFilterNAimput}
\alias{combineMultFilterNAimput}
\title{Combine Multiple Filters On NA-imputed Data}
\usage{
combineMultFilterNAimput(
  dat,
  imputed,
  grp,
  useComparison = "all",
  experSetup = NULL,
  annDat = NULL,
  abundThr = NULL,
  colRazNa = NULL,
  colTotNa = NULL,
  minSpeNo = 1,
  minTotNo = 2,
  maxGrpMiss = 1,
  ratMaxNA = 0.8,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)
}
\arguments{
\item{dat}{(matrix or data.frame) main data (may contain \code{NA})}

\item{imputed}{(character)  same as 'dat' but with all \code{NA} imputed}

\item{grp}{(character or factor) define groups of replicates (in columns of 'dat')}

\item{useComparison}{(character or matrix) argument allowing to specify which pairwise comparions sould be performed, default \code{useComparison=NULL} will run all pairwise comparisons;
may be character as result of combining two group-names (from argument \code{grp}) (eg 'A-B', beware, the separator may not appear inside group-names) 
or 2-column matrix of group-names (thus, without separator; names combined with separator may be shown as rownames) or 2-column matrix of indexes to sorted group-names;
default setting of \code{useComparison='all'} will select all possible pairwise combinations}

\item{experSetup}{(list) optional esperimental setup (list with $ind, $pwGrpIndex,$sep and $pwGrpNa  as obtained using \code{getPairwiseSetup})}

\item{annDat}{(matrix or data.frame) annotation data (should match lines of 'dat')}

\item{abundThr}{(numeric) optional threshold filter for minimumn abundance}

\item{colRazNa}{(character) if razor peptides are used: column name for razor peptide count}

\item{colTotNa}{(character) column name for total peptide count}

\item{minSpeNo}{(integer) minimum number of specific peptides for maintaining proteins}

\item{minTotNo}{(integer) minimum total ie max razor number of peptides}

\item{maxGrpMiss}{(numeric) passd to \code{\link[wrMisc]{presenceFilt}} : at least 1 group has not more than this number of NAs (otherwise marke line as bad)}

\item{ratMaxNA}{(numeric) passd to \code{\link[wrMisc]{presenceFilt}} : at least 1 group below this content of \code{NA} values}

\item{silent}{(logical) suppress messages}

\item{debug}{(logical) additional messages for debugging}

\item{callFrom}{(character) allows easier tracking of messages produced}
}
\value{
This function returns a list with $data, $nNA, $randParam, $NAneigLst, $seed, $filt, and $annot
}
\description{
In most omics data-analysis one needs to employ a certain number of filtering strategies to avoid getting artifacts to the step of statistical testing.
This function takes both the origial data and the NA-imputed data to create several different filters (number of NAs, min abundance, ..) and finally combines them.
The filter-component aiming to take away the least abundant values (using the imputede data) can be fine-tuned by the argument \code{abundThr}.
}
\details{
The main filtering step compares the means for each group and line (from argument \code{imputed}), at least one group-mean has to be superior the threshold (\code{abundThr}, 
based on hypothesis that if all conditions represent extrememy low measures their differential may not be determined with certainty).

The filter addressing the number of missing values (\code{NA}) uses the original data (argument \code{dat}), the arguments \code{colTotNa}, \code{minSpeNo} and \code{minTotNo} 
are used during this step. Basically, this step allows defining a minimum content of 'real' (ie non-\code{NA}) values for further considering the measurements as reliable.
This part uses internally \code{\link[wrMisc]{presenceFilt}} for filtering elevated content of \code{NA} per line.

Finally, this function combines both filters (as matrix of \code{FALSE} and \code{TRUE}) on NA-imputed and original data 
and retruns a vector of logical values if corresponding lines passe all filter criteria.
}
\examples{
set.seed(2013)
datT6 <- matrix(round(rnorm(300)+3,1), ncol=6,
  dimnames=list(paste0("li",1:50), letters[19:24]))
datT6 <- datT6 +matrix(rep(1:nrow(datT6),ncol(datT6)), ncol=ncol(datT6))
datT6[6:7,c(1,3,6)] <- NA
datT6[which(datT6 < 11 & datT6 > 10.5)] <- NA
datT6[which(datT6 < 6 & datT6 > 5)] <- NA
datT6[which(datT6 < 4.6 & datT6 > 4)] <- NA
datT6b <- matrixNAneighbourImpute(datT6, gr=gl(2,3))
datT6c <- combineMultFilterNAimput(datT6, datT6b, grp=gl(2,3), abundThr=2)
head(datT6c$filt)
## with custom choice of comparisons :
gr2 <- gl(2, 3, labels=c("A","B"))
datT6d <- combineMultFilterNAimput(datT6, datT6b, grp=gr2, useCom="B-A", abundThr=2)
head(datT6d$filt)
}
\seealso{
\code{\link[wrMisc]{presenceFilt}}
}
