% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{shrinkColumnProps}
\alias{shrinkColumnProps}
\title{shrinkColumnProps}
\usage{
shrinkColumnProps(x, shrinkTo = NULL, var.theo = FALSE)
}
\arguments{
\item{x}{A matrix of counts, with features as rows and samples as columns.}

\item{shrinkTo}{A vector (of length equal to \code{nrow(x)}) of sampling
probabilities to shrink towards, or a matrix (of the same dimensions as \code{x})
of such probabilities. If omitted, will be the weighted mean of the columns'
relative frequencies.}

\item{var.theo}{Logical; whether to use theoretical (i.e. binomial) variances
of the proportions, rather than the observed (weighted) variance.}
}
\value{
A matrix of the same dimensions as \code{x} representing the shrunk
column-wise proportions.
}
\description{
Empirical Bayes shrinkage of a matrix of counts towards a prior proportion
(by default the mean across columns).
}
\examples{
# generate a matrix of 5 sampling (with different total counts) of 20 
# features based on the same base frequency :
baseFreq <- abs(rnorm(20))
baseFreq <- baseFreq/sum(baseFreq)
mat <- sapply(c(10,20,30,40,50), function(tot){
  rpois(length(baseFreq), baseFreq*tot)
})
# apply shrinkage and confirm that shrunk proportions are better correlated
shrunk_mat <- shrinkColumnProps(mat)
mean(cor(shrunk_mat))>mean(cor(mat))
}
