\HeaderA{binarize}{Binarize}{binarize}
\aliasA{binarizeByPercentage}{binarize}{binarizeByPercentage}
\aliasA{densityOnes}{binarize}{densityOnes}
\keyword{manip}{binarize}
\keyword{array}{binarize}
\begin{Description}\relax
Methods to convert a real matrix to a binary matrix.
\end{Description}
\begin{Usage}
\begin{verbatim}
binarize(x, threshold=NA)
binarizeByPercentage(x,percentage, error=0.2, gap=0.1)
densityOnes(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] The data matrix to be binarized.
\item[\code{threshold}] Threshold used to binarize. Values over threshold will be set to 1,
the rest to 0. If threshold is NA, median is used as threshold. Default NA.
\item[\code{percentage}] Percentage of ones against zeros desired in the binary matrix.
\item[\code{error}] Percentage of ones against zeros in the final matrix will be in [percentage-error, percentage+error]. Default 0.2
\item[\code{gap}] Value used for incremental search of threshold. Default 0.1
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{binarize} function returns a matrix binarized by input threshold, or by the median if no threshold is given.

The \code{binarizeByPercentage} function returns a matrix binarize by input percentage, given as desired density of ones against zeros.

The \code{densityOnes} function returns the percentage of ones against zeros in a logical matrix
\end{Details}
\begin{Author}\relax
Rodrigo Santamaria
\email{rodri@usal.es}
\end{Author}
\begin{Examples}
\begin{ExampleCode}
  data(BicatYeast)
  m1=binarize(BicatYeast)
  m2=binarize(BicatYeast, 0.2)
  m3=binarizeByPercentage(BicatYeast, 5)
  densityOnes(m3)
  densityOnes(m2)
  densityOnes(m1)
  drawHeatmap(BicatYeast)
  drawHeatmap(m1)
  drawHeatmap(m2)
  drawHeatmap(m3)
\end{ExampleCode}
\end{Examples}

