% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/computeBackgrounds.R
\name{computeBackgrounds}
\alias{computeBackgrounds}
\title{computeBackgrounds}
\usage{
computeBackgrounds(
  object,
  bins,
  grouping = NULL,
  expectation = NULL,
  shrinkage = c("none", "average", "smooth"),
  sigma = 1,
  verbose = FALSE
)
}
\arguments{
\item{object}{A SummarizedExperiment (or SingleCellExperiment) with an assay
'counts', or a (sparse) matrix of counts.}

\item{bins}{A \code{bcvBackground} object, as produced by
\code{\link{getBackgroundBins}}.}

\item{grouping}{An optional factor or vector coercible to a factor indicating
the groupings of the columns of \code{object}. This is optionally used to 1)
compute the base expectation such that rare cell types are given as much
weight as abundant ones, and 2) apply shrinkage (if \code{shrinkage!="none"})
on a per-grouping fashion. In single-cell data, the grouping can for
instance be the interaction of samples and cell types. (The name of a
colData column of \code{object} can also be provided.)}

\item{expectation}{Optional vector of length equal to \code{nrow(object)}
giving the expected counts. If NULL, defaults to mean counts (eventually
grouped, see \code{grouping} and \code{\link{getExpectation}}).}

\item{shrinkage}{The method to use to shrink background (i.e. bias) bin
frequencies. Either "average" (shrinks towards the bin's average across
cells/samples of the same group), "smooth" (per-sample 2D smoothing over
the bin matrix, somewhat redundant with \code{w}), or "none" (default).}

\item{sigma}{Sigma parameter for the 2D smoothing. Ignored unless
\code{shrinkage="smooth"}.}

\item{verbose}{Logical; whether to output progress messages.}
}
\value{
A \code{bcvBackground} object with bins*samples slots filled, for use
with \code{\link{computeDeviationsAnalytic}}.
}
\description{
computeBackgrounds
}
\examples{
attach(getDummyData())
# if GC content not already in the object, use:
# counts <- addGCBias(counts, genome=YOUR_GENOME)

# we fist get the background bins:
bg <- getBackgroundBins(counts)
# then we can compute the backgrounds for each sample:
bg <- computeBackgrounds(counts, bg)
# for use in computeDeviationsAnalytic...
}
