Introduction¶
The Gamma-Poisson (or Negative Binomial) distribution is a suitable model to describe variation accurately in count matrices of single-cell RNA-sequencing (scRNA-seq) data in both theory and practice Ahlmann-Eltze & Huber, 2021. It plays an essential role in normalizing count data in the SCTransform process before performing downstream analyses, such as principal component analysis (PCA) or clustering.
Although several packages implement this framework, glmGamPoi offers an outstanding and robust performance Ahlmann-Eltze & Huber, 2021.
Workflow¶
Overall, this workflow fits a raw count matrix to a Negative Binomial (NB) distribution. The primary target is to determine the model coefficients: , which represented as the log-scaled expected mean counts; and the dispersion parameter () for each gene.
The workflow begins with an initial rough dispersion estimation, followed by estimating the model coefficients using the Maximum Likelihood method. After fixing , the maximum likelihood estimation of is conducted. These gene-specific dispersion estimates are then stabilized via a shrinkage process.
Rough dispersion estimation¶
Initially, a rough estimate of the dispersion for gene () is computed using Equation (1). Here, is an offset correction factor, defined as the reciprocal of the average exponentiated offset () across all samples. Since the offset in this context is the natural logarithm of the total counts for each sample, , where is the mean total count across samples.
The rough dispersion estimator is derived from the mean–variance relationship of the Gamma-Poisson distribution () Ahlmann-Eltze & Huber, 2021, adjusted by the factor and constrained to be non-negative.
Here, denotes the vector of counts for gene , while and represent the variance and mean functions, respectively.
Beta estimation¶
At the beginning, rough beta of each gene () is estimated by Equation (2), defined as the logarithm of the gene-oriented mean of normalised counts (), which are proportion of count on total counts of each sample ( is the number of genes).
Beta is estimated using the Newton-Raphson method Akram & Ann, 2015, which iterates Equation (3) until the value of beta converges. is the derivative of likelihood function that count values of gene is of Negative Binomial (NB) distribution.
Starting with an initial rough estimate of for gene , the sample-specific expected count is updated in each iteration by combining the biological parameter () and technical sampling offset (). Even though represents the theoretical mean of the NB distribution, incorporating these sample-specific offsets allows the model to account for variation in sequencing depth across the samples. This helps strip away library-size biases while computing the log-likelihood function and its derivative according to Equation (4).
Overdispersion (theta) estimation¶
Hence using the likelihood function to model NB distribution for each gene, the overdispersion parameter is estimated after determination of derived from . The vector of mean count of gene is deduced via the equation in (4), which stands for constant count mean across samples during optimizing .
The likelihood function presented in Equation (10) is derived from general likelihood function of NB distribution (7). Here the factorial components in the combination term is substituted with Gamma functions to generalize the domain to continuous real numbers (), while any additive terms independent of are omitted.
To maximize the log-likelihood function, we first compute its derivative with respect to , as shown in Equation (11), where denotes the digamma function (the first derivative of ).
Setting yields the root-finding problem in Equation (12), which can be separated into two distinct components. The first part, , accounts for the digamma terms and involves intensive computation. To eliminate redundant calculations for identical count values, glmGamPoi optimizes this step by utilizing a count frequency table Ahlmann-Eltze & Huber, 2021. Meanwhile, the remaining log-mean component, , is more straightforward to compute.
Structurally, the gradient defined in Equation (13) governs the direction of the variation of . When , the log-likelihood slope is positive, indicating that must be increased. Conversely, when , the slope is negative, meaning must be decreased. A state of indicates that the log-likelihood has reached a local extremum.
To verify whether this stationary point corresponds to a local maximum or minimum. The second-derivative of the gradient is tested, if , the curvature is concave down, confirming that the extremum is a local maximum representing the Maximum Likelihood Estimate (MLE) of .
Shrinkage¶
Even though NB distribution is able to obtain flexible variance-mean relationship, it is proved virtually being uncertainty in parameter estimation. Quasi-likelihood (QL) comes as a solution to adjust dispersion Lund et al., 2012. The variance-mean equation of quasi-distribution by genes is shown as (16).
Initially, the trend dispersion () is derived from the vector of likelihood estimated dispersion (), which is performed local median regression to stablize dispersion. Specifically, the dispersion according to each mean count value () would be performed weighted median Cormen et al., 2022 with neighbors (sorted by mean, analyzing 100 neighbors by default), where the weight range originates from the range of probability in the domain of standard normal distribution.
is defined by (17), which derived from (16) and mean-variance equation of NB distribution, where likelihood dispersion was smoothed into .
The shrunken quasi-likelihood overdispersion () for each gene is estimated by Equation (18). Particularly, is the residual degree of freedom - DOF (), while and are prior parameters representing DOF and dispersion scaler respectively. These prior parameters are estimated by modeling the values using a scaled Chi-squared distribution via a natural cubic spline framework. The process successfully yields a theoretical pseudo-sample size () and a denoised central dispersion trend (). Ultimately, the resulting reflects the true amount of informative dispersion captured from the data.
Under the intercept-only model (~1), all samples are treated as a single group. The coefficient vector is re-estimated using the trend dispersion (), which is then used to recalculate the expected mean counts.
Summary¶
The Gamma-Poisson model is a good fit for overdispersed scRNA-seq data. Ultimately, the function glm_gp() of the glmGamPoi package, which models NB distribution, targets essential regression coefficients (relative log-scaled count mean and overdispersion ), by maximizing their likelihood estimations.
- Ahlmann-Eltze, C., & Huber, W. (2021). glmGamPoi: Fitting Gamma-Poisson Generalized Linear Models on Single Cell Count Data. Bioinformatics, 36(24), 5701–5702. 10.1093/bioinformatics/btaa1009
- Akram, S., & Ann, Q. U. (2015). Newton raphson method. International Journal of Scientific & Engineering Research, 6(7), 1748–1752.
- Sinharay, S. (2010). Discrete Probability Distributions. In International Encyclopedia of Education (pp. 132–134). Elsevier. 10.1016/B978-0-08-044894-7.01721-8
- Cox, D. R., & Reid, N. (1987). Parameter Orthogonality and Approximate Conditional Inference. Journal of the Royal Statistical Society Series B: Statistical Methodology, 49(1), 1–18. 10.1111/j.2517-6161.1987.tb01422.x
- Love, M. I., Huber, W., & Anders, S. (2014). Moderated Estimation of Fold Change and Dispersion for RNA-seq Data with DESeq2. Genome Biology, 15(12), 550. 10.1186/s13059-014-0550-8
- Lund, S. P., Nettleton, D., McCarthy, D. J., & Smyth, G. K. (2012). Detecting Differential Expression in RNA-sequence Data Using Quasi-likelihood with Shrunken Dispersion Estimates. Statistical Applications in Genetics and Molecular Biology, 11(5). 10.1515/1544-6115.1826
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2022). Introduction to algorithms. MIT press.