Introduction¶
Normalization and preprocessing are the key challenges affecting directly to downstream scRNA-seq results, in which technically sequencing bias is cut down while biological variation is reserved. An effective workflow would eliminate technical bias among cells/samples and keep genewise heterogeneity without being overwhelmed by dominant genes Hafemeister & Satija, 2019Choudhary & Satija, 2022.
Based on that, SCTransform is introduced as a probabilistic approach stabilizing variation in the count matrix Hafemeister & Satija, 2019. When there is a significant difference in cell expression originally, the SCTransform method is able to replace Seurat standard preprocessing workflow (normalization, feature selection, and scaling), mentioned in pbmc3k_tutorial.
Workflow¶

Overall, the raw count matrix is utilized for Negative Binomial (NB) model estimate to determine the expected mean and overdispersion parameters for each gene. After the estimating, the raw likelihood parameters are highly variable across genes, a regulation step is applied to stabilize variance and reduce the sampling noise.
Next, the contribution of each element in the count matrix to the Chi-square dependence between genes and samples is quantified via Pearson residuals. Subsequently, the count matrix is corrected by eliminating technical noise across samples, and reconstructing normalized expression counts from the stabilized residuals.
Finally, the Pearson residuals undergo post-processing, where highly variable features are identified, and confounding biological or technical covariates (such as cell viability indicated by the percentage of mitochondrial reads) can be regressed out, yielding a polished residual matrix ready for downstream analysis (e.g., PCA and clustering).
Fitting model¶
At the beginning, only genes obtaining an overdispersion factor () are used to train. A number of genes is randomly selected (default is 2,000) across their expression levels, and the total count of selected genes must be greater than 5 by default. Subsequently, their raw count matrix are modeled by Gamma-Poisson general linear model (Gamma-Poisson GLM), i.e Negative Binomial (NB) model, to properly obtain overdispersion. See Gamma-Poisson GLM for more detail about the model-fitting process.
Briefly, it uses the Maximum Likelihood Estimates (MLE) method to estimate coefficients of the model according to the count values of each gene. The coefficients include relative log-scaled count mean , and overdispersion . Note that the definition of overdispersion between sctransform and Gamma-Poisson GLM are reciprocal.
Next, theoretical overdispersion , which is derived from mean-variance relationship of NB model, shown as Equation (1). is the ratio of expected overdispersion () over observed overdispersion (), which originates from estimation above. If , the model for that gene is assumed to follow the Poisson distribution (, and ).
Regularizing model¶
Geometric mean¶
For each gene, logarithmic geometric mean () computed by Equation (2), represents as a centric count without affected by outlier samples. With is the count value of sample in total samples, and (default is 1) is a small fixed number to avoid Hafemeister & Satija, 2019.
Local outlier detection¶
Local outlier genes along the -axis are detected based on the matrices of the log-scaled overdispersion factor () and estimated from Gamma-Poisson GLM. These parameters serve for variance and mean outlier indicators, respectively.
Initially, the genes are assigned to bins according to their value. The binwidth is determined using a heuristic rescale from the optimal bandwidth featured by Sheather & Jones (1991) to ensure data is fairly distributed across bins (satijalab
For each evaluated matrix ( representing either or ), the outlier scores () are computed for the points within each bin following Equation (3), which measures the distance to the median and eliminates deviation by Median Absolute Deviation (MAD) to enable comparability. For enhancing reliability, the measurement is processed on two overlapping grids, offset by half a binwidth. A gene is flagged as an outlier within a specific matrix when its absolute score on both grids exceeds a threshold, which defaults to 10.
Ultimately, a gene is marked as an outlier if it is flagged by either of the evaluated matrices (variance or mean).
Kernel smoothing¶
The estimated parameters ( and ) are sequentially smoothed across gene expression levels (log geometric mean) using the Nadaraya-Watson kernel regression estimator Nadaraya, 1964. To avoid overfitting, this smoothing is anchored by the subset comprising overdispersion genes which exclude the previously flagged outliers and Poisson-like genes.
The smoothed value (in or matrix) of any gene is computed by weighted average of anchored genes, as defined in Equation (4). Particularly, the weight () is the density determined by the Gaussian kernel function at the distance between the current gene and anchored gene in the level. In overdispersion genes, the employed subset starts from anchored gene , which is nearest to the boundary, four times the bandwidth h, from the targeted range.

The interquartile of the distance distribution is assumed to be the range , where is the optimal bandwidth of overdispersion genes by the method of Sheather & Jones (1991), see SJ bandwidth estimation for details. Noticeably, the optimized is tripled by default. All together, this ensures that anchor genes lying closer to the expected range obtained higher weight.
Based on the assumption, standard deviation of the distance distribution () used in Equation (4) computed by Equation (5) with being the inverse cumulative distribution function of 75th percentile.
By the end, smoothed and , which is recoverd from smoothed , are utilized for the next process.
Pearson residuals¶
While Chi-square test evaluates the global association between two categorical variables in a contingency table, Pearson residuals isolate the explicit contribution of each individual component (here, each gene-cell pair) to that overall dependence. The computation of specific Pearson residual () for gene in cell is outlined in Equation (6).
First, the expected count () is calculated analogously to the expected frequency in Chi-square test with the gene-specific log-scaled mean estimated in the smoothing step and the total count for each cell.
Hence count data assumably follows NB distribution, the variance () for residuals is derived from as the mean, and smoothed overdispersion .
Finally, the specific Pearson residual is measured from the deviation between the observe (, the actual count) and the expected value (), and scaled by standard deviation to ensure comparability.
In practice, the variance is bound by a lower threshold defined in Equation (7), where the deviation is expected to be always greater than the general median, and the maximum of residual is 5.
Count correction¶
Using the stabilized Pearson residuals, the raw count matrix is corrected following Equation (8).
The gene-specific baseline mean and variance used for this correction step are calculated similarly to and in Equation (6), excepting that specifying the median of log-scaled total count of samples.
Ultimately, the corrected count value () is computed by the combination of the baseline mean count across samples, and the specific expectation deviation derived from the specific residual. Finally, the corrected values are polished by rounding, and the minimum floor set at 0.
Post-processing¶
Feature selection¶
The top variable features (genes) are determined by ranking the variance of Pearson residuals across cells.
In detail, after computing the raw residuals, they are practically clipped by the range (where is the total number of cells) to mitigate the distorting impact of extreme outliers. Next, genewise variance of these clipped residuals is calculated and the genes are sorted to select the top variable features (capped at 3,000 features by default).
Residualization¶
Subsequently, based on the parameter vars.to.regress, Pearson residuals are residualized against the percentage of mitochondrial genes, which reflects cell survival status. This step eliminates additional unwanted variance arising from technical errors or cell damage.
This dependency is modeled linearly, as shown in Equation (9), where the Pearson residual vector of gene () depends on a linear model of the mitochondrial gene percentage () and an independent residual vector ().
Finally, the resulting residuals are mean-centered within each gene.
Summary¶
To reduce technical noise without losing statistical variance, sctransform fits and regularizes a negative binomial model to stabilize variance across genes. Technical bias across cells is removed via Pearson residualization while preserving true biological variation. Furthermore, top variable features are selected, and dependence on confounding covariates is regressed out.
Notably, the corrected count matrix is reconstructed directly from the initial Pearson residuals before post-processing. Consequently, the corrected counts remain independent of additional covariate regressions, thereby preserving the baseline biological variance of the raw counts.
- Hafemeister, C., & Satija, R. (2019). Normalization and Variance Stabilization of Single-Cell RNA-seq Data Using Regularized Negative Binomial Regression. Genome Biology, 20(1), 296. 10.1186/s13059-019-1874-1
- Choudhary, S., & Satija, R. (2022). Comparison and Evaluation of Statistical Error Models for scRNA-seq. Genome Biology, 23(1), 27. 10.1186/s13059-021-02584-9
- Sheather, S. J., & Jones, M. C. (1991). A Reliable Data-Based Bandwidth Selection Method for Kernel Density Estimation. Journal of the Royal Statistical Society Series B: Statistical Methodology, 53(3), 683–690. 10.1111/j.2517-6161.1991.tb01857.x
- Nadaraya, E. A. (1964). On Estimating Regression. Theory of Probability & Its Applications, 9(1), 141–142. 10.1137/1109020