Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Separating Within- and Between-Donor Variance

Biological Replication and Donor-Level Inference · Tutorial 452 of 700

Separating Within- and Between-Donor Variance

Decompose variability among cells into donor-level differences and variation among cells from the same donor, then interpret the estimates and their limitations.

Advanced 10 min read

What You'll Learn

  • Define within-donor and between-donor variation for a nested single-cell outcome.
  • Derive the variance decomposition implied by a random-intercept model.
  • Calculate the exact within/between sum-of-squares decomposition from donor cell measurements.
  • Estimate variance components in a balanced nested design using mean squares.
  • Interpret variance components in context, including what residual variation does not establish.
  • Identify assumptions, diagnostics, and limitations of donor-level variance decomposition.

Why Separate the Sources of Variation?

Cells from one donor are not simply interchangeable with cells from another donor. Cells from the same donor share a biological background and may also share collection, processing, and measurement conditions. Consequently, observed cell-to-cell variation combines differences among donors with differences among cells within a donor. Separating these sources helps describe the data at the level relevant to the scientific question: how much do donors differ, and how variable are cells within a donor?

The decomposition is descriptive and model-based, not a claim that every source of variation has a single biological cause. For a given gene or other cell-level outcome, the within-donor component can include cell-state heterogeneity, measurement error, and unmodelled cell-level factors. The between-donor component can reflect donor biology as well as donor-associated technical or clinical differences. Interpretation therefore depends on study design and the outcome scale.

Definition: Within-donor variance describes variability among cell outcomes from the same donor, after accounting for the donor’s mean outcome. Between-donor variance describes variability among donor-specific mean outcomes in a target donor population. Both components are variances on the outcome scale and therefore have squared outcome units.

A Nested Random-Intercept Model

Let \(Y_{ij}\) denote the outcome for cell \(j\) from donor \(i\), where \(i=1,\ldots,D\). A simple model that represents the two sources of variation is

$$ Y_{ij}=\mu+b_i+\varepsilon_{ij}. $$

Here, \(\mu\) is the population mean, \(b_i\) is donor \(i\)’s deviation from that mean, and \(\varepsilon_{ij}\) is the cell’s deviation from its donor’s mean. The random-effects assumptions are \(E(b_i)=0\), \(\operatorname{Var}(b_i)=\tau^2\), \(E(\varepsilon_{ij})=0\), and \(\operatorname{Var}(\varepsilon_{ij})=\sigma^2\). Donor effects are independent across donors; cell residuals are independent across cells conditional on the donor effects; and the residuals are independent of the donor effects. The simplest model also assumes a common residual variance across donors.

Under this model, \(\tau^2\) is the between-donor variance component and \(\sigma^2\) is the within-donor variance component. Normality of the random effects and residuals is an additional assumption when using normal-theory likelihood or exact small-sample procedures; it is not required for the variance identity below. The model also presumes donors are meaningfully viewed as sampled from a population. If the scientific target is only the particular donors observed, a population-level random-effects interpretation may not be appropriate.

Result: If the random donor effect and cell residual are independent, then the marginal variance of a cell outcome is the sum of the two components:
$$ \operatorname{Var}(Y_{ij})=\tau^2+\sigma^2. $$

This identity does not say that the components are equally important, nor does it identify their biological causes. It says that, under the model, the variance of a randomly selected cell outcome consists of variation in the donor mean plus variation around that donor mean.

Deriving the Decomposition

The variance identity follows from conditioning on the donor. Given donor \(i\), the donor effect is fixed, so the conditional mean is \(\mu+b_i\) and the conditional variance is \(\sigma^2\). The law of total variance states that the marginal variance equals the expected conditional variance plus the variance of the conditional mean. Applying it gives

$$ \begin{aligned} \operatorname{Var}(Y_{ij}) &=E\{\operatorname{Var}(Y_{ij}\mid b_i)\} +\operatorname{Var}\{E(Y_{ij}\mid b_i)\}\\ &=E(\sigma^2)+\operatorname{Var}(\mu+b_i)\\ &=\sigma^2+\tau^2. \end{aligned} $$

There is also an exact sum-of-squares identity for observed data. Let \(n_i\) be the number of measured cells from donor \(i\), \(\bar{Y}_i\) the mean outcome for that donor, and \(\bar{Y}\) the mean across all observed cells. Then

$$ \sum_{i=1}^{D}\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y})^2 = \sum_{i=1}^{D}\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_i)^2 + \sum_{i=1}^{D}n_i(\bar{Y}_i-\bar{Y})^2. $$

To see why, write \(Y_{ij}-\bar{Y}=(Y_{ij}-\bar{Y}_i)+(\bar{Y}_i-\bar{Y})\), square, and sum. The cross-product for donor \(i\) is zero because \(\sum_j(Y_{ij}-\bar{Y}_i)=0\). The first sum on the right is the within-donor sum of squares; the second is the between-donor sum of squares, with each donor mean weighted by its cell count. This identity describes the observed data exactly. Turning these sums into estimates of population variance components requires additional assumptions and an estimation method.

Worked Example: Exact Decomposition in a Balanced Dataset

Suppose a hypothetical experiment measures one outcome in three cells from each of three donors. The values are: donor A, 2, 4, 6; donor B, 4, 6, 8; donor C, 6, 8, 10. These are illustrative data, not results from a real study.

The donor means are \(\bar{Y}_A=4\), \(\bar{Y}_B=6\), and \(\bar{Y}_C=8\). The grand mean is \(\bar{Y}=6\). For donor A, the within-donor sum of squares is \((2-4)^2+(4-4)^2+(6-4)^2=8\); donors B and C also each contribute 8. Thus the total within-donor sum of squares is \(24\).

For the between-donor sum of squares, each donor has three cells:

$$ SS_{\text{between}}=3(4-6)^2+3(6-6)^2+3(8-6)^2=24. $$

The total sum of squares is \(24+24=48\). Directly, the sample variance across all nine cell values is \(48/(9-1)=6\) outcome-units squared. The exact decomposition is useful descriptively, but the between-donor sum of squares is not itself the between-donor variance estimate: it also reflects cell counts and sampling variability.

Estimating Components in a Balanced Design

For a balanced design, suppose every donor contributes the same number \(m\) of cells. Define \(SS_{\text{within}}\) and \(SS_{\text{between}}\) as in the preceding decomposition. Their mean squares are

$$ MS_{\text{within}}=\frac{SS_{\text{within}}}{D(m-1)}, \qquad MS_{\text{between}}=\frac{SS_{\text{between}}}{D-1}. $$

Under the random-intercept assumptions, the expected mean squares are

$$ E(MS_{\text{within}})=\sigma^2, \qquad E(MS_{\text{between}})=\sigma^2+m\tau^2. $$

The reason for the second expectation is that a donor mean averages \(m\) residuals: its residual contribution has variance \(\sigma^2/m\), while its donor effect has variance \(\tau^2\). The between-donor sum of squares is based on deviations of donor means from their overall mean. Its mean square therefore has expectation \(m\tau^2+\sigma^2\). Subtracting the within mean square removes the residual contribution in expectation, and dividing by \(m\) gives the method-of-moments estimate

$$ \widehat{\sigma^2}=MS_{\text{within}}, \qquad \widehat{\tau^2}=\frac{MS_{\text{between}}-MS_{\text{within}}}{m}. $$

This simple formula applies to a balanced one-way nested design under the stated model. In unbalanced designs, unequal cell counts affect the expected mean squares; do not substitute an average cell count into this formula and assume the result is valid. A mixed-model estimation method can accommodate unequal counts, provided the design and assumptions support that model.

Worked Example: Estimating Variance Components

Use the nine hypothetical values from the balanced example. There are \(D=3\) donors and \(m=3\) cells per donor. We found \(SS_{\text{within}}=24\) and \(SS_{\text{between}}=24\). The within degrees of freedom are \(D(m-1)=3(2)=6\), and the between degrees of freedom are \(D-1=2\). Therefore,

$$ MS_{\text{within}}=\frac{24}{6}=4, \qquad MS_{\text{between}}=\frac{24}{2}=12. $$

The method-of-moments estimates are

$$ \widehat{\sigma^2}=4, \qquad \widehat{\tau^2}=\frac{12-4}{3}=\frac{8}{3}\approx 2.667. $$

On this outcome scale, the estimated within-donor component is 4 outcome-units squared, and the estimated between-donor component is about 2.667 outcome-units squared. The estimated total variance is their sum, approximately 6.667 outcome-units squared. It need not equal the observed sample variance of 6 exactly: the component estimates are model-based estimates with sampling variation.

The arithmetic also shows a limitation of this estimator. If \(MS_{\text{between}}<MS_{\text{within}}\), the formula gives a negative estimate of \(\tau^2\), even though a true variance cannot be negative. This can occur through sampling variation, especially with few donors. It is a warning about estimation uncertainty, not evidence for a negative biological variance.

Worked Example: Unequal Cell Counts and the Exact Identity

Consider another hypothetical dataset: donor A has values 1 and 3; donor B has 4, 6, and 8; donor C has 7 and 9. The donor means are 2, 6, and 8, and the total of all seven observations is 38, so \(\bar{Y}=38/7\approx5.429\).

The within-donor sum of squares is \(2+8+2=12\). The between-donor sum of squares uses each donor’s actual cell count:

$$ \begin{aligned} SS_{\text{between}} &=2(2-38/7)^2+3(6-38/7)^2+2(8-38/7)^2\\ &=1848/49\approx37.714. \end{aligned} $$

Thus the total sum of squares is \(12+37.714\approx49.714\), exactly the decomposition of the total observed variation, apart from rounding. The unequal counts make clear that the overall cell mean and the decomposition weight donors according to their observed number of cells. This exact identity remains true, but the balanced-design variance-component estimator above does not apply directly to this dataset.

Biological Interpretation, Diagnostics, and Alternatives

Suppose the outcome is log-normalized expression for a gene. A substantial estimated \(\tau^2\) means donor-specific average expression differs appreciably on the log-expression scale, relative to the model’s residual variation. It does not show that donor identity caused the differences: age, treatment, disease status, cell composition, batch, and other donor-associated factors may contribute. A substantial \(\sigma^2\) means cells from a donor vary around that donor’s mean; it does not establish that this entire variation is biological. It may include technical noise, unmeasured cell states, and departures from the assumed model.

The components depend on the outcome and the design. A log transformation, a different normalization, or adjustment for covariates can change the variance split. If donors differ systematically in cell type composition, a cell-level outcome may show a large within-donor component that reflects a mixture of distinct cell states rather than random fluctuation within one homogeneous population. Define the cell population and outcome carefully before interpreting either component.

Useful diagnostics include plotting cell outcomes by donor, checking donor means and within-donor spreads, and examining residuals against fitted values and technical variables. Look for donors with markedly different spreads, outliers, strong batch alignment, or patterns across donors that a single common residual variance cannot represent. A variance estimate at zero or a negative unconstrained method-of-moments estimate is also a signal to report uncertainty and inspect the data, not to force a biological story. With few donors, the between-donor component can be imprecise even when each donor contributes many cells.

The principal alternatives answer related but distinct questions. Donor-level summaries, followed by inference across donors, put the donor at the unit of analysis and avoid treating cells as independent biological replicates; they may not directly estimate a within-donor component. A fixed-donor-effects model estimates a separate mean for each observed donor and can control for those donor-specific levels, but it does not by itself estimate a population distribution of donor effects. A random-intercept model represents that distribution and separates the two variance components, but depends on its population and variance assumptions. The appropriate choice follows the target of inference, not a preference for a more elaborate model.

Common pitfall: “There are thousands of cells, so the between-donor variance must be estimated precisely.” More cells can improve information about each observed donor’s mean and within-donor spread, but they do not create more independent donors. Precision about a population of donor effects depends importantly on the number and diversity of donors.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In the random-intercept model, which component describes variability among cells from the same donor, and what are its units?
  2. For a balanced design with \(D=4\), \(m=5\), \(MS_{\text{within}}=9\), and \(MS_{\text{between}}=19\), calculate the method-of-moments estimates of both components.
  3. Why does the exact sum-of-squares decomposition weight each donor mean by that donor’s cell count?
  4. A large within-donor estimate is found for a gene. Name two different sources it may contain besides biological variation among cells.
  5. What does a negative unconstrained estimate of the between-donor variance mean?

Solutions. (1) \(\sigma^2\), with units equal to the square of the outcome units. (2) \(\widehat{\sigma^2}=9\); \(\widehat{\tau^2}=(19-9)/5=2\), in squared outcome units. (3) Each cell contributes to the overall cell-level sum of squares, so a donor with more observed cells contributes more terms; algebraically, the group-mean deviation is repeated \(n_i\) times. (4) Examples include measurement error and unmeasured cell-state heterogeneity. (5) The sample mean squares fluctuated so their difference was negative; a true variance cannot be negative, so the estimate signals uncertainty or poor fit rather than a negative population variance.

Clinical Biostats