# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
This procedure calculates, for every gene and every sample, an offset to apply to the log2 reads per million (RPM) and the function normalizeCounts() adds this offset to the the log2 RPM values calculated from the input count data matrix, unlogs them and rolls back these normalized RPM values into integer counts. For more information on customizing the embed code, read Single-Cell Analysis Toolkit for Gene Expression Data in R#' Compute (log-)normalized expression values by dividing counts for each cell by the corresponding size factor.#' @param x A numeric matrix-like object containing counts for cells in the columns and features in the rows.#' Alternatively, a \linkS4class{SingleCellExperiment} or \linkS4class{SummarizedExperiment} object containing such a count matrix.#' @param exprs_values A string or integer scalar specifying the assay of \code{x} containing the count matrix.#' @param size_factors A numeric vector of cell-specific size factors.#' Alternatively \code{NULL}, in which case the size factors are extracted or computed from \code{x}.#' @param log Logical scalar indicating whether normalized values should be log2-transformed.#' @param pseudo_count Numeric scalar specifying the pseudo_count to add when log-transforming expression values.#' @param center_size_factors Logical scalar indicating whether size factors should be centered at unity before being used.#' @param subset_row A vector specifying the subset of rows of \code{x} for which to return a result.#' @param downsample Logical scalar indicating whether downsampling should be performed prior to scaling and log-transformation.#' @param down_target Numeric scalar specifying the downsampling target when \code{downsample=TRUE}.#' If \code{NULL}, this is defined by \code{down_prop} and a warning is emitted.#' @param down_prop Numeric scalar between 0 and 1 indicating the quantile to use to define the downsampling target when \code{downsample=TRUE}.#' @param ... For the generic, arguments to pass to specific methods.#' For the SummarizedExperiment method, further arguments to pass to the ANY or \linkS4class{DelayedMatrix} methods.#' For the SingleCellExperiment method, further arguments to pass to the SummarizedExperiment method.#' @param BPPARAM A \linkS4class{BiocParallelParam} object specifying how library size factor calculations should be parallelized.#' Only used if \code{size_factors} is not specified.#' Normalized expression values are computed by dividing the counts for each cell by the size factor for that cell.#' This aims to remove cell-specific scaling biases, e.g., due to differences in sequencing coverage or capture efficiency.#' If \code{log=TRUE}, log-normalized values are calculated by adding \code{pseudo_count} to the normalized count and performing a log2 transformation.#' If no size factors are supplied, they are determined automatically from \code{x}:#' \item For count matrices and \linkS4class{SummarizedExperiment} inputs,#' the sum of counts for each cell is used to compute a size factor via the \code{\link{librarySizeFactors}} function.#' \item For \linkS4class{SingleCellExperiment} instances, the function searches for \code{\link{sizeFactors}} from \code{x}.#' If none are available, it defaults to library size-derived size factors.#' If \code{size_factors} are supplied, they will override any size factors present in \code{x}.#' If \code{center_size_factors=TRUE}, size factors are centred at unity prior to calculation of normalized expression values.#' This ensures that the computed expression values can be interpreted as being on the same scale as original counts.#' We can then compare abundances between features normalized with different sets of size factors; the most common use of this fact is in the comparison between spike-in and endogenous abundances when modelling technical noise (see \code{\link[scran]{modelGeneVarWithSpikes}} package for an example).#' More generally, when \code{log=TRUE}, centering of the size factors ensures that the value of \code{pseudo_count} can be interpreted as being on the same scale as the counts, i.e., the pseudo-count can actually be thought of as a \emph{count}.#' This is important as it implies that the pseudo-count's impact will diminish as sequencing coverage improves.#' Thus, if the size factors are centered, differences between log-normalized expression values will more closely approximate the true log-fold change with increasing coverage, whereas this would not be true of other metrics like log-CPMs with a fixed offset.#' The disadvantage of using centered size factors is that the expression values are not directly comparable across different calls to \code{\link{normalizeCounts}}, typically for multiple batches.#' In theory, this is not a problem for metrics like the CPM, but in practice, we have to apply batch correction methods anyway to perform any joint analysis - see \code{\link[batchelor]{multiBatchNorm}} for more details.