Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Residual and Overdispersion Diagnostics for Abundance Models

Differential Abundance and Compositional Effects · Tutorial 548 of 700

Residual and Overdispersion Diagnostics for Abundance Models

Learn how to interpret residual patterns, assess overdispersion, and identify donors that strongly affect fitted abundance effects.

Advanced 12 min read

What You'll Learn

  • Calculate Pearson residuals for binomial and multinomial abundance models.
  • Compare fitted and observed proportions across donors and cell types.
  • Estimate and interpret Pearson dispersion ratios with appropriate degrees of freedom.
  • Distinguish isolated unusual observations from systematic model misfit.
  • Assess donor influence by comparing full-data and leave-one-donor-out estimates.
  • Choose diagnostic follow-up that addresses the suspected failure without overstating what a diagnostic proves.

Why Diagnose Abundance Models?

A fitted abundance model summarizes how observed cell counts relate to covariates, but a plausible coefficient or small p-value does not establish that the model describes the data adequately. In single-cell studies, diagnostics are especially important because many cells may be measured for each donor while the number of independent biological replicates remains much smaller. A model that treats donors as independent replicates can still fit poorly if its variance assumptions, mean structure, or dependence assumptions are wrong.

This tutorial focuses on residuals, fitted proportions, dispersion, and donor influence in binomial and multinomial abundance models. These checks are not automatic pass-or-fail tests. They are ways to locate systematic departures from a model and decide what needs investigation.

Models and Diagnostic Quantities

For a binomial abundance analysis, let \(Y_i\) be the number of cells of a specified type among \(n_i\) captured cells from donor \(i\). A binomial regression specifies \(Y_i\mid n_i\sim\operatorname{Binomial}(n_i,p_i)\), with a regression model for \(p_i\), often \(\operatorname{logit}(p_i)=\mathbf{x}_i^\top\boldsymbol{\beta}\). Conditional on the model covariates, the binomial assumption says the count has mean \(n_i p_i\) and variance \(n_i p_i(1-p_i)\). It also assumes donors are independent; the binomial variance is appropriate only if within-donor cell dependence does not add extra variability beyond that model.

For a multinomial abundance analysis, let \(Y_{ik}\) be the count of cell type \(k\) for donor \(i\), with \(K\) cell types and total \(n_i=\sum_{k=1}^K Y_{ik}\). The model is \( (Y_{i1},\ldots,Y_{iK})\mid n_i\sim\operatorname{Multinomial}(n_i,\boldsymbol{p}_i)\), where the probabilities sum to one. It has expected count \(E_{ik}=n_i p_{ik}\) and variance \(n_i p_{ik}(1-p_{ik})\) for each component, with covariance \(-n_i p_{ik}p_{i\ell}\) between distinct components \(k\) and \(\ell\). Thus, component residuals are not independent: an excess in one part of a fixed total must be balanced by deficits elsewhere.

Definition: A Pearson residual is the observed-minus-fitted value divided by its model-based standard deviation. For a binomial donor count, \(r_i=(Y_i-n_i\hat p_i)/\sqrt{n_i\hat p_i(1-\hat p_i)}\). For a multinomial count, the cell contribution to the Pearson goodness-of-fit statistic is \((Y_{ik}-E_{ik})/\sqrt{E_{ik}}\). This is not the component residual divided by its multinomial marginal standard deviation, which is \((Y_{ik}-E_{ik})/\sqrt{n_i p_{ik}(1-p_{ik})}\); summing the squares of these marginally standardized residuals does not give the stated multinomial Pearson statistic. Large absolute Pearson cell contributions flag components that contribute unusually strongly to lack of fit; they do not by themselves identify the cause.

A fitted proportion \(\hat p_i\) or \(\hat p_{ik}\) should be considered alongside the observed proportion \(Y_i/n_i\) or \(Y_{ik}/n_i\). A useful diagnostic plot places observed proportions against fitted proportions, with donors identified and, where relevant, grouped or colored by condition or batch. A systematic trend in residuals across a covariate suggests that the mean structure may be inadequate. A few large residuals may instead indicate unusual donors, sparse categories, or data-quality problems.

Dispersion: Is the Variation Larger Than the Model Allows?

If the binomial or multinomial variance is appropriate, a Pearson goodness-of-fit statistic is the sum of squared Pearson residuals. Dividing it by the residual degrees of freedom gives a dispersion estimate. For grouped binomial observations with \(D\) donor-level counts and \(q\) fitted regression parameters, a common estimate is \(\hat\phi=X^2/(D-q)\), when \(D>q\). For multinomial counts, the denominator is the number of independent count contrasts minus the number of fitted parameters; with \(D\) donors, a common composition, and \(K\) categories, it is \((D-1)(K-1)\). For more complex models, the appropriate residual degrees of freedom depend on the model and design.

$$ X^2_{\mathrm{bin}}=\sum_{i=1}^{D}\frac{(Y_i-n_i\hat p_i)^2}{n_i\hat p_i(1-\hat p_i)}, \qquad X^2_{\mathrm{multi}}=\sum_{i=1}^{D}\sum_{k=1}^{K} \frac{(Y_{ik}-E_{ik})^2}{E_{ik}}. $$

Under adequate fit and suitable large-sample conditions, \(X^2\) is approximately chi-square distributed with the residual degrees of freedom. The ratio \(\hat\phi\) is then often near one. A ratio substantially above one is a warning that variation exceeds the fitted model’s expectation; a ratio below one can reflect less variability than expected or simply sampling variation. Neither ratio should be treated as a universal cutoff. The chi-square approximation is unreliable when expected counts are very small, and a few unusual donors can dominate the statistic.

Overdispersion can arise when donors differ in unmodeled ways, when cells within a donor are correlated, or when the mean model omits important predictors. It can also arise from technical variation or misspecified cell-type probabilities. Earlier material on beta-binomial and Dirichlet-multinomial models provides alternatives that explicitly allow extra-binomial or extra-multinomial variability. A larger standard error from an overdispersion adjustment may address uncertainty, but it does not repair a wrong mean structure.

Worked Example: Checking Binomial Residuals and Dispersion

Suppose eight hypothetical independent donors each contribute \(n_i=100\) cells to a specified cell type. An intercept-only binomial model is fitted, and the observed counts are 14, 18, 22, 25, 16, 21, 19, and 25. The pooled count is 160 among 800 cells, so \(\hat p=160/800=0.20\). The model predicts 20 cells of this type per donor, with standard deviation \(\sqrt{100(0.20)(0.80)}=4\).

The Pearson residuals are the count deviations from 20 divided by 4: \(-1.50,-0.50,0.50,1.25,-1.00,0.25,-0.25,1.25\). Therefore,

$$ X^2_{\mathrm{bin}}= \frac{(-6)^2+(-2)^2+2^2+5^2+(-4)^2+1^2+(-1)^2+5^2}{16} =\frac{112}{16}=7.00. $$

One parameter, the common proportion, was estimated, so \(df=8-1=7\) and \(\hat\phi=7/7=1.00\). No donor has a Pearson residual with absolute value above 1.50, and this summary shows no evident excess dispersion. It does not prove that the binomial assumptions are correct: eight donors provide limited diagnostic power, and patterns against covariates would still need inspection.

Multinomial Residual Patterns

For multinomial models, inspect residuals by both donor and cell type. One cell type may be persistently underpredicted, or donors may show coordinated shifts among several types. Because proportions sum to one, such shifts are linked: an overprediction of one category can appear alongside underpredictions in others. Looking only at a single component can therefore miss the composition-wide pattern.

A signed deviance residual can complement a Pearson residual. For a multinomial cell, it is the sign of \(Y_{ik}-E_{ik}\) multiplied by the square root of the cellwise deviance contribution \(2\{Y_{ik}\log(Y_{ik}/E_{ik})-(Y_{ik}-E_{ik})\}\), with \(Y_{ik}\log(Y_{ik}/E_{ik})\) defined as zero when \(Y_{ik}=0\). Deviance and Pearson residuals emphasize discrepancies differently, especially in sparse counts. If many expected counts are small, neither their usual approximations nor a simple dispersion ratio should be trusted without further assessment.

Worked Example: Reading a Multinomial Dispersion Summary

Consider four hypothetical independent donors, each with 100 cells and three cell types. A common-composition multinomial model estimates proportions \(0.50,0.30,0.20\), giving expected counts \(50,30,20\) per donor. Suppose the observed donor counts are (55, 28, 17), (45, 32, 23), (52, 25, 23), and (48, 35, 17). The observed totals across donors are 200, 120, and 80, so these fitted proportions agree with the pooled proportions.

For donor 1, the Pearson contribution is \(5^2/50+(-2)^2/30+(-3)^2/20=0.5000+0.1333+0.4500=1.0833\). Donor 2 contributes the same 1.0833. Donor 3 contributes \(2^2/50+(-5)^2/30+3^2/20=0.0800+0.8333+0.4500=1.3633\), and donor 4 contributes 1.3633. Thus \(X^2_{\mathrm{multi}}=4.893\). With a common composition, \(df=(4-1)(3-1)=6\), giving \(\hat\phi=4.893/6=0.8156\).

This value does not indicate excess dispersion in this small example. It is not evidence that the model is definitively adequate, particularly with only four donors. The donor-level residuals show modest imbalances, and each expected count is at least 20, making the usual approximation more reasonable than it would be for rare categories.

Influential Donors and Model Stability

A donor is influential when its inclusion substantially changes a fitted quantity of interest, such as a condition coefficient. Influence is not identical to having a large residual: a donor can be unusual but have little effect on an estimate, while a donor with substantial leverage in the design can affect the estimate even with a moderate residual. In abundance studies, the donor—not each cell—is generally the unit to remove for a leave-one-donor-out diagnostic.

For a coefficient \(\hat\beta_j\), define the deletion change as the full-data estimate minus the estimate after excluding donor \(i\):

$$ \Delta_{ij}=\hat\beta_j-\hat\beta_{j(-i)}. $$

Inspect both the size and direction of \(\Delta_{ij}\), preferably relative to the coefficient’s uncertainty and the range of changes across donors. A large change suggests sensitivity to that donor; it does not establish that the donor is erroneous. Check the donor’s counts, covariates, sequencing and annotation records, and representation in the design before deciding how to proceed. Do not remove a donor merely because deletion makes a result less statistically significant.

Worked Example: A Leave-One-Donor-Out Coefficient Change

Suppose a hypothetical binomial regression for a cell-type abundance estimates a condition coefficient of \(\hat\beta_j=1.4739\) on the log-odds scale using all donors. Refitting the same model after omitting donor 7 gives \(\hat\beta_{j(-7)}=0.7472\). The deletion change under the stated convention is

$$ \Delta_{7j}=1.4739-0.7472=+0.7267. $$

The positive change means the full-data coefficient is 0.7267 log-odds units larger than the coefficient without donor 7. Removing that donor reduces the estimated condition effect, so the full-data estimate is sensitive to donor 7 in this direction. The difference alone does not show whether the donor is erroneous or whether the model is misspecified. Review the donor-level residual, fitted proportion, covariate pattern, and underlying count data, then report the sensitivity transparently.

Diagnostics, Alternatives, and Limits

A practical diagnostic sequence is to check fitted proportions and residuals first, then assess aggregate dispersion, then investigate donors whose residuals or deletion changes stand out. Compare diagnostics across conditions and relevant covariates. If residuals systematically vary with a predictor, consider whether the mean model needs a different functional form or an omitted term. If residual variation is broadly larger than expected, consider an overdispersed model or an uncertainty method that respects donor-level replication. If a handful of categories have very small fitted counts, treat chi-square-based summaries cautiously.

The main alternatives address different concerns. A beta-binomial model can allow extra-binomial variability for a cell-type count; a Dirichlet-multinomial model can allow extra-multinomial variation across a composition; and a logistic-normal model can represent correlated variation in transformed proportions. These are not interchangeable fixes. A robust or resampling-based uncertainty analysis may reduce reliance on a particular variance assumption, but it does not correct a systematically wrong fitted mean. Model choice should reflect the data structure and scientific question, not just whichever option produces a preferred test result.

Diagnostics also have limits. With few donors, residual and dispersion estimates are noisy. With many cell types, rare categories can produce unstable residuals. A good-looking residual plot cannot establish that donors are representative, that annotation is correct, or that observed relative abundances equal absolute cell numbers. Nor does an unusual donor automatically invalidate a result. These checks identify where the model deserves scrutiny; they do not replace study-design judgment.

Common pitfall: Treating thousands of cells as thousands of independent replicates can make residuals appear precise and standard errors too small. The correction is to match the likelihood and diagnostics to the sampling unit and dependence structure. For donor-level comparative inference, inspect donor-level counts and evaluate variation across independent donors.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. A binomial fit has \(Y_i=30\), \(n_i=100\), and \(\hat p_i=0.20\). What is its Pearson residual?
  2. What does a Pearson dispersion ratio well above one suggest, and what does it not establish?
  3. In a multinomial model, why should residuals for separate cell types not be interpreted as independent?
  4. Using the definition in this tutorial, if the full-data coefficient is 0.60 and the estimate without donor \(i\) is 0.85, what is \(\Delta_{ij}\), and what does its sign mean?

Solutions. (1) \(r=(30-100(0.20))/\sqrt{100(0.20)(0.80)}=10/4=2.50\). (2) It suggests more variability than the fitted model expects, possibly from donor heterogeneity, dependence, or omitted structure; it does not identify the cause or prove which alternative model is correct. (3) The counts share a fixed total, so an increase in one component must be balanced by changes in others. (4) \(\Delta_{ij}=0.60-0.85=-0.25\). The full-data estimate is 0.25 units lower than the estimate after removing donor \(i\); excluding that donor increases the coefficient.

Clinical Biostats