Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Random Slopes for Donor-Specific Responses

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

Random Slopes for Donor-Specific Responses

Interpret donor-specific random slopes, distinguish response heterogeneity from measurement noise, and identify the design information needed to estimate it.

Advanced 10 min read

What You'll Learn

  • Interpret the fixed condition effect and donor-specific random slopes.
  • Read the random-intercept and random-slope covariance components.
  • Derive the variance of a paired donor response.
  • Distinguish between-donor response variation and sampling noise within donors.
  • Identify design features and diagnostics relevant to estimating slope heterogeneity.

Why Let the Condition Effect Vary by Donor?

A model with a single condition effect assumes that the average response is the same for every donor, apart from measurement noise and any donor-specific baseline differences. In biological studies, however, donors may differ not only in baseline expression but also in how strongly expression changes between conditions. A random-slope model represents this donor-to-donor variation in response.

Here, consider a continuous expression outcome measured for a specified gene and cell population, with condition coded \(x=0\) or \(x=1\). The outcome might be a donor-condition summary or a measurement in a model that appropriately accounts for cells nested within donors. The model below focuses on the donor-level response; treating cells as independent donors would not estimate donor heterogeneity correctly.

Definition: A random-slope model allows the effect of a predictor to vary across groups. For donor \(i\) in condition \(c\), a basic random-intercept, random-slope model is $$ Y_{ic}=\beta_0+\beta_1x_c+b_{0i}+b_{1i}x_c+\varepsilon_{ic}. $$ Here \(\beta_0\) is the population-average mean in condition 0, \(\beta_1\) is the population-average condition response, \(b_{0i}\) is donor \(i\)'s deviation in baseline, and \(b_{1i}\) is donor \(i\)'s deviation in response. The donor-specific response is \(\beta_1+b_{1i}\).

The usual model assumes donor effects have mean zero and a common covariance matrix across donors:

$$ \begin{pmatrix}b_{0i}\\b_{1i}\end{pmatrix} \sim N\!\left( \begin{pmatrix}0\\0\end{pmatrix}, \begin{pmatrix}\tau_{00}&\tau_{01}\\\tau_{01}&\tau_{11}\end{pmatrix} \right). $$

Donor effects are assumed independent across donors. The residuals \(\varepsilon_{ic}\) have mean zero, are independent across the modeled observations conditional on the donor effects, and are independent of those effects. In the simplest version, their variance is \(\sigma^2\). More complex data may need a residual structure that reflects different precision across donor-condition measurements. In all cases, the model's distributional and independence assumptions should be plausible for the chosen outcome and sampling design.

The quantity \(\tau_{11}\) is the between-donor variance in condition responses; its square root, \(\sqrt{\tau_{11}}\), is the standard deviation of donor-specific responses around \(\beta_1\). It is not the standard error of \(\beta_1\), nor is it the residual variance. The covariance \(\tau_{01}\) describes whether donors with higher-than-average baselines tend to have higher or lower-than-average responses.

What the Model Implies for a Paired Response

With binary condition coding, each donor's latent response is the difference between that donor's condition 1 and condition 0 means. Subtracting the two model equations cancels the random intercept:

$$ Y_{i1}-Y_{i0}=\beta_1+b_{1i}+\varepsilon_{i1}-\varepsilon_{i0}. $$

Thus the random slope directly represents a donor's deviation from the population-average paired response. If the two residuals are independent and each has variance \(\sigma^2\), the observed paired difference has variance \(\tau_{11}+2\sigma^2\). The first component is true response heterogeneity in the model; the second is measurement or residual variation.

If \(Y_{ic}\) is an average based on \(n_{ic}\) cells and the cell-level residual variance is \(\sigma^2\), a simple independent-cell model gives that average a residual variance \(\sigma^2/n_{ic}\). The noise variance of the paired difference is then \(\sigma^2/n_{i1}+\sigma^2/n_{i0}\), not \(2\sigma^2\). This illustrates why cell counts and measurement precision matter: they affect how clearly each donor's response is observed, but they do not create additional independent donors.

Key interpretation: A random-slope variance describes how much donor-specific condition responses vary in the population represented by the model. A large number of cells can reduce uncertainty in each donor's response, but the number and response diversity of independent donors remain central to estimating this population variance.

Worked Examples

Worked Example: Separating Observed Response Variation From Measurement Noise

Suppose four hypothetical donors have condition summaries (in arbitrary normalized-expression units) as follows: donor A has 5 in condition 0 and 6 in condition 1; B has 4 and 7; C has 6 and 8; D has 3 and 3. Their paired differences are \(1,3,2,0\).

The mean observed response is

$$ \bar D=\frac{1+3+2+0}{4}=\frac{6}{4}=1.5 $$

expression units. The sample variance of those four observed differences is

$$ s_D^2=\frac{(1-1.5)^2+(3-1.5)^2+(2-1.5)^2+(0-1.5)^2}{4-1} =\frac{5}{3}=1.667. $$

Now suppose, for illustration, that each donor-condition summary has an independently known measurement-error variance of \(0.20\) expression-units squared. The paired-difference measurement-error variance is \(0.20+0.20=0.40\). A simple method-of-moments estimate of response heterogeneity is therefore

$$ \widehat{\tau}_{11}=s_D^2-0.40=1.667-0.40=1.267, \qquad \sqrt{\widehat{\tau}_{11}}=\sqrt{1.267}=1.126. $$

Under this simplified calculation, estimated between-donor response variation has a standard deviation of about 1.126 expression units. This is not a reliable estimate from only four donors; it is an illustration of the distinction between variation in observed differences and variation attributed to true donor responses. A fitted mixed model would estimate variance components using the full model and account for the data structure.

Worked Example: How Cell Sampling Precision Changes a Donor Response

Consider a hypothetical donor with cell-level residual variance \(\sigma^2=4\) expression-units squared. There are 25 sampled cells in condition 0 and 16 in condition 1. Under independent residual sampling within each condition, the variance of the difference between the two donor means due to cell sampling is

$$ \operatorname{Var}(\bar Y_{i1}-\bar Y_{i0}\mid b_{0i},b_{1i}) =\frac{4}{16}+\frac{4}{25} =0.25+0.16=0.41. $$

The sampling standard error for this donor's observed response is \(\sqrt{0.41}=0.6403\) expression units. If the population random-slope variance were \(\tau_{11}=1\), the marginal variance of the observed paired response would be \(1+0.41=1.41\), before considering any additional sources of uncertainty.

Increasing the cell counts would lower the \(0.41\) sampling component, making this donor's response more precise. It would not change the fact that the response-heterogeneity parameter describes variation across donors. For example, collecting many more cells from this same donor does not provide the same information about \(\tau_{11}\) as recruiting additional independent donors.

Worked Example: Why a Continuous Predictor Must Vary Within Donor

Suppose the predictor is a continuous dose, and a donor-specific line is fitted as \(Y_{ij}=a_i+s_i x_{ij}+\text{error}\). With measurements at doses \(x=0,1,2\), one hypothetical donor has outcomes \(2,4,7\). The within-donor least-squares slope is

$$ \hat s_i= \frac{\sum_j(x_{ij}-\bar x_i)(Y_{ij}-\bar Y_i)} {\sum_j(x_{ij}-\bar x_i)^2} = \frac{(-1)(2-13/3)+0(4-13/3)+(1)(7-13/3)} {(-1)^2+0^2+1^2} =\frac{5}{2}=2.5. $$

The estimated response for this donor is 2.5 expression units per dose unit. A second hypothetical donor with outcomes \(1,2,3\) at the same doses has slope \(1\) expression unit per dose unit. These observed slopes differ, but their difference alone does not prove different latent donor responses: both slope estimates have measurement uncertainty.

If every donor were measured at only one dose, a donor-specific intercept and slope could not be separated from that donor's outcome: there would be no within-donor dose change from which to estimate a response. With repeated measurements at distinct doses, slope information depends on the within-donor spread of dose values, as shown by the denominator \(\sum_j(x_{ij}-\bar x_i)^2\). A narrow dose range makes slopes imprecise even if the number of measurements is substantial.

What Information Is Needed to Estimate Response Heterogeneity?

A variance component is estimated from how donor-specific response information varies across independent donors, after accounting for the uncertainty of those responses. The design therefore needs information at two levels:

  • Across donors: enough independent donors to learn about a population distribution of responses. More donors generally provide more information about the spread of that distribution.
  • Within donors: measurements that distinguish the predictor conditions or levels, so each donor's response can be informed by within-donor change rather than baseline differences alone.
  • Measurement precision: sufficient cells or other measurements per donor-condition to avoid having observed response differences dominated by sampling noise.
  • Predictor coverage: for a continuous predictor, meaningful within-donor variation in predictor values. A slope cannot be learned from repeated outcomes at an unchanged predictor value.

The assumptions also matter. Donors should be independent sampling units for the intended population inference, the random-effects distribution should be a reasonable approximation, and residual variation should be modeled well enough that it is not mistaken for slope variation. Unequal cell counts can give donor responses different precision; a model that ignores this may misrepresent how much each response contributes.

Justification: For paired binary conditions with independent residual errors of equal variance, \(D_i=Y_{i1}-Y_{i0}=\beta_1+b_{1i}+\varepsilon_{i1}-\varepsilon_{i0}\). Independence gives \(\operatorname{Var}(\varepsilon_{i1}-\varepsilon_{i0})=\sigma^2+\sigma^2=2\sigma^2\). Since \(b_{1i}\) is independent of the residuals and has variance \(\tau_{11}\), the variance-addition rule yields \(\operatorname{Var}(D_i)=\tau_{11}+2\sigma^2\). Consequently, the spread of observed paired differences combines response heterogeneity and measurement noise; it cannot automatically be interpreted as \(\tau_{11}\).

In practice, mixed-model likelihood or restricted maximum likelihood is commonly used to estimate the fixed effects and variance components jointly. These methods use the model's covariance structure rather than simply taking the sample variance of noisy donor-specific estimates. They cannot, however, manufacture information absent from the design. With very few donors, or very imprecise donor responses, estimates of \(\tau_{11}\) may be unstable or lie at the boundary \(\widehat{\tau}_{11}=0\). A boundary estimate means the fitted model has not found evidence of positive slope variance at its available resolution; it does not establish that all donors have identical responses.

Interpretation, Diagnostics, and Alternatives

For binary condition coding, the fixed effect \(\beta_1\) is the model's population-average condition response, in the outcome's units. The random-slope standard deviation \(\sqrt{\tau_{11}}\) is the across-donor standard deviation of responses, in the same units. The intercept-slope covariance helps describe how baseline and response vary together. These are model-based population summaries, not causal effects unless the study design and causal assumptions support a causal interpretation.

Useful checks include examining whether the model converged, whether the estimated slope variance is at or near zero, and whether the intercept-slope correlation is extreme or poorly determined. Plotting donor-specific response estimates with their uncertainty can reveal whether apparent heterogeneity is driven by a few donors or by broad variation. Leave-one-donor-out changes can also flag sensitivity. Such plots are diagnostic aids, not substitutes for the model or for biological replication. A highly uncertain covariance estimate or a variance estimate that changes sharply under small modeling choices should be reported as weakly determined.

ApproachWhat it representsMain trade-off
Random-intercept-only modelAllows donor baselines to vary but constrains the condition response to be common.Simpler, but does not represent donor response heterogeneity.
Random-intercept and random-slope modelModels donor baselines and donor-specific deviations in response as a population distribution.Matches a heterogeneity question, but needs enough informative donors and within-donor data.
Separate response estimate for each donorReports donor-specific slopes without assuming they come from a shared distribution.Can be transparent, but noisy estimates are not themselves a stable estimate of population heterogeneity.

The random-slope model is not automatically preferable merely because it is more flexible. If the design contains little information about within-donor response, adding a slope variance can produce a boundary estimate, an unstable covariance estimate, or a result driven by a few observations. Conversely, forcing a common response when donors genuinely differ can conceal biologically relevant variation. The model choice should follow the scientific question and the information the design supplies.

Common Mistakes

  • Confusing slope variance with residual variance. Residual variance describes unexplained observation-level variation under the model; \(\tau_{11}\) describes variation in donor responses.
  • Calling a noisy spread of donor differences the heterogeneity estimate. Observed differences include measurement error. Their variance is not \(\tau_{11}\) unless that error contribution is negligible or accounted for.
  • Counting cells as independent donors. Many cells can sharpen a donor's response estimate, but the random-slope distribution is learned across donors.
  • Interpreting a zero estimate as proof of identical responses. A variance estimate at zero can reflect limited information or the model's boundary, not certainty that true heterogeneity is absent.
  • Fitting donor-specific slopes without within-donor predictor variation. Repeated outcomes at one predictor value do not identify a donor-specific response slope.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. In a binary-condition random-slope model, what does \(\tau_{11}\) measure, and what are its units?
  2. If each condition mean has independent sampling variance \(0.30\), what is the sampling variance of their paired difference?
  3. Why can collecting more cells from existing donors fail to provide the information needed to estimate population response heterogeneity?
  4. For a continuous predictor, what feature of the within-donor design informs that donor's slope?
  5. What does a fitted random-slope variance of zero establish?

Solutions. (1) \(\tau_{11}\) is the between-donor variance of condition responses around the population-average response; its units are squared outcome units. (2) Independence gives \(0.30+0.30=0.60\), in squared outcome units. (3) More cells can reduce measurement noise in each donor's response, but response heterogeneity is variation across independent donors, so additional donors are needed to learn that distribution well. (4) The predictor must vary within donor; greater spread in predictor values generally provides more slope information, as reflected in \(\sum_j(x_{ij}-\bar x_i)^2\). (5) It establishes only that the fitted model's estimate is at the zero boundary. It does not prove that true donor responses are identical.

Clinical Biostats