Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Simulation-Based Calibration of Donor Inference

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

Simulation-Based Calibration of Donor Inference

Use a known data-generating process and repeated simulated studies to check whether donor-aware estimates, intervals, and tests perform as intended.

Advanced 12 min read

What You'll Learn

  • Set up a nested donor-and-cell simulation with a known treatment effect and intraclass correlation.
  • Calculate simulation bias, empirical interval coverage, and false-positive rates.
  • Quantify Monte Carlo uncertainty so simulation noise is not mistaken for method failure.
  • Compare methods across donor counts, cells per donor, and donor heterogeneity.
  • Diagnose misleading results caused by model failure, convergence problems, or an inadequate simulation design.

Why Calibrate Donor Inference by Simulation?

A donor-aware analysis is intended to respect the fact that cells from the same donor are related. But whether a method does so adequately depends on the design, the assumptions, and the quantity being estimated. With few donors, unequal cell counts, or substantial between-donor variation, a method that appears reasonable can still produce biased estimates, intervals that miss too often, or tests that reject a true null hypothesis too frequently.

Simulation-based calibration evaluates these properties under repeated data sets whose generating process is specified in advance. Because the simulated truth is known, performance can be compared directly with that truth. This is not proof that a method will work for every biological study: it shows how the method behaves under the simulated conditions, and therefore makes the assumptions and limitations of the evaluation explicit.

Here, “calibration” means agreement between a procedure’s repeated-sampling behavior and its advertised behavior. For example, a nominal 95% confidence interval is calibrated in a scenario if it contains the true parameter in about 95% of independently simulated studies. A false-positive rate is calibrated at level \(\alpha\) if a test rejects the null in about an \(\alpha\) fraction of studies generated under that null.

A Nested Data-Generating Model

A useful starting point is a simple continuous-outcome model with cells nested within donors. Let \(j=1,\ldots,D\) index donors and \(i=1,\ldots,m_j\) index cells from donor \(j\). Let \(T_j\) indicate the donor’s condition, with \(T_j=0\) for control and \(T_j=1\) for treatment. One possible data-generating model is

$$ Y_{ij}=\beta_0+\beta_1T_j+b_j+\epsilon_{ij}, \qquad b_j\sim N(0,\tau^2), \qquad \epsilon_{ij}\sim N(0,\sigma^2). $$

Here, \(Y_{ij}\) is the outcome for a cell, \(\beta_0\) is the control mean, and \(\beta_1\) is the treatment-minus-control difference in the cell-level mean. The donor random effects \(b_j\) are independent across donors, and the cell errors \(\epsilon_{ij}\) are independent across cells and independent of the donor effects. In this model, cells from one donor share \(b_j\), while cells from different donors do not share a donor effect. The total marginal variance of a cell outcome is \(\tau^2+\sigma^2\), giving intraclass correlation

$$ \rho=\frac{\tau^2}{\tau^2+\sigma^2}. $$

To use this simulation to evaluate an analysis, the simulated design must represent the feature being studied. Specify the number of donors per condition, how condition is assigned, and the cell counts \(m_j\). Hold these choices fixed or deliberately vary them across scenarios. The donor effects and cell errors should be generated according to the stated model; the analysis method should then be applied to each simulated data set as it would be to observed data.

Definition: A simulation scenario is a fully specified set of data-generating assumptions and design conditions, including the target parameter, donor allocation, cell-count pattern, and variation within and between donors. A method’s performance is conditional on the scenario used to evaluate it.

This model is a deliberate simplification. It assumes a continuous outcome, normal donor effects and cell errors, and a common treatment effect across donors. A simulation intended to assess an analysis for another outcome type or design must generate data with assumptions appropriate to that setting. In every case, the analysis is fitted separately to each simulated study; it must not be given the simulated truth as if it were observed.

Worked Example: Setting the Intraclass Correlation

Suppose a hypothetical simulation uses \(\tau^2=0.36\) and \(\sigma^2=0.64\), in squared outcome units. The total variance is \(0.36+0.64=1.00\), so

$$ \rho=\frac{0.36}{0.36+0.64}=0.36. $$

Thus, 36% of the marginal variance is attributable to the donor component under this model. The remaining 64% is cell-level residual variance. This does not mean that 36% of each observed outcome is a donor effect; it is a variance decomposition. If the simulation instead used \(\tau^2=0\), its ICC would be zero, and there would be no donor-level clustering in this model.

For instance, setting \(D=12\) donors, six per condition, and \(m_j=50\) cells per donor defines one design scenario. The treatment effect could be set to \(\beta_1=0\) for evaluating false positives, or to a nonzero value such as \(\beta_1=0.5\) outcome units for evaluating estimation and power.

Performance Measures Across Repeated Studies

Let \(B\) denote the number of simulated studies in a scenario. In study \(r\), let \(\hat{\beta}_{1r}\) be the method’s estimate, \(L_r\) and \(U_r\) the endpoints of its nominal 95% interval, and \(R_r\) equal 1 if its test rejects \(H_0:\beta_1=0\) and 0 otherwise. The same simulation can assess several distinct properties; none should be treated as a substitute for the others.

Definition: The simulation estimate of bias is the average estimated effect minus the known effect. Empirical coverage is the fraction of intervals containing the known effect. Under a scenario with \(\beta_1=0\), the empirical false-positive rate is the fraction of tests rejecting \(H_0:\beta_1=0\).
$$ \widehat{\operatorname{Bias}} = \frac{1}{B}\sum_{r=1}^{B}\hat{\beta}_{1r}-\beta_1, \qquad \widehat{\operatorname{Coverage}} = \frac{1}{B}\sum_{r=1}^{B} I(L_r\leq \beta_1\leq U_r), \qquad \widehat{\operatorname{FPR}} = \frac{1}{B}\sum_{r=1}^{B}R_r \quad\text{when }\beta_1=0. $$

The indicator \(I(\cdot)\) equals 1 when its condition is true and 0 otherwise. Bias is measured in the units of the effect estimate. Coverage is a proportion. False-positive rate is also a proportion and should be compared with the prespecified significance level \(\alpha\). A method may have small bias but poor coverage, for example if its standard errors are too small. It is therefore important to report these measures separately.

Simulation results themselves are noisy because they use a finite number of replications. If a binary outcome occurs in \(K\) of \(B\) independent replications, its estimated proportion is \(\hat{q}=K/B\), with approximate Monte Carlo standard error

$$ SE_{\mathrm{MC}}(\hat{q}) \approx \sqrt{\frac{\hat{q}(1-\hat{q})}{B}}. $$

For estimated bias, an estimate of Monte Carlo standard error is \(s_{\hat{\beta}_1}/\sqrt{B}\), where \(s_{\hat{\beta}_1}\) is the sample standard deviation of the \(B\) estimates. This uncertainty describes the precision of the simulation summary, not the uncertainty in an estimate from an actual biological study.

Worked Example: Evaluating False-Positive Rate

In a hypothetical null scenario, suppose \(B=2{,}000\) studies are simulated with \(\beta_1=0\), and the method rejects \(H_0\) in 138 studies. The estimated false-positive rate is

$$ \widehat{\operatorname{FPR}}=\frac{138}{2{,}000}=0.069. $$

The estimated Monte Carlo standard error is

$$ SE_{\mathrm{MC}} \approx \sqrt{\frac{0.069(1-0.069)}{2{,}000}} = \sqrt{0.00003212} \approx 0.00567. $$

If the intended test level is \(\alpha=0.05\), the estimate exceeds that target by 0.019, or 1.9 percentage points. That is a signal to investigate, not by itself proof of a systematic failure: Monte Carlo variability and details of the scenario matter. Repeating the simulation with more replications can reduce Monte Carlo noise, but it cannot correct an inappropriate data-generating model.

A Calibration Workflow and Its Justification

The core logic is repeated sampling under known conditions. A complete evaluation specifies the truth and design first, generates data from that specification, applies the analysis without changing its rules after seeing results, and summarizes repeated performance. The flow below is useful because it separates a method’s behavior from random variation in any single simulated data set.

1
Define the target and scenario.
Set the true effect, donor counts, cell counts, variation, condition allocation, and any departures from the intended model.
2
Generate one study.
Draw donor effects and cell errors according to the scenario, then construct the cell-level outcomes and recorded condition labels.
3
Fit the method as planned.
Save its estimate, interval, test result, and whether fitting converged. Do not omit failed fits without recording them.
4
Repeat and summarize.
Repeat for \(B\) studies, then calculate bias, coverage, false-positive rate under the null, and Monte Carlo uncertainty.

The justification for the coverage calculation follows directly from its definition. In a repeated-sampling scenario, each interval either contains the fixed true value \(\beta_1\) or does not. The indicator \(I(L_r\leq\beta_1\leq U_r)\) is therefore a binary observation of coverage in replication \(r\). Averaging these indicators estimates the probability of coverage under that scenario; with independent replications, its expected value is the scenario’s true coverage probability.

$$ E\left[ \frac{1}{B}\sum_{r=1}^{B}I(L_r\leq\beta_1\leq U_r) \right] = \frac{1}{B}\sum_{r=1}^{B} P(L_r\leq\beta_1\leq U_r). $$

When all replications use the same procedure and scenario, each probability on the right is the same, so the expected empirical coverage equals that probability. If the procedure produces 95% coverage under the scenario, the empirical coverage fluctuates around 0.95 rather than equaling it exactly in every run.

Worked Example: Interpreting Bias and Coverage Together

Suppose a hypothetical alternative-effect scenario has \(\beta_1=0.50\) expression units and \(B=2{,}000\) replications. The average estimate is \(0.53\) units, and 1,834 intervals contain the true effect. Then the estimated bias is

$$ \widehat{\operatorname{Bias}}=0.53-0.50=0.03 \quad\text{expression units}. $$

The empirical coverage is \(1{,}834/2{,}000=0.917\), or 91.7%. Its approximate Monte Carlo standard error is

$$ SE_{\mathrm{MC}} \approx \sqrt{\frac{0.917(1-0.917)}{2{,}000}} \approx 0.00617. $$

The point estimates average 0.03 units above the truth, while the nominal 95% intervals cover only 91.7% of the time in this scenario. These are different findings: a modest average bias does not ensure well-calibrated intervals. Further investigation might examine standard-error accuracy, small-sample behavior, and fitting failures. The interval statement is about repeated coverage under this specified simulation, not a 91.7% probability that the fixed effect lies in any one computed interval.

Varying Donors, Cells, and Donor Correlation

A single scenario answers a narrow question. A useful calibration study varies the features that plausibly alter performance. For example, compare low and higher donor counts, several cell counts per donor, and several ICC values. Change one factor at a time for clear comparisons, or use a planned grid to assess combinations. Keep the target effect and analysis rules fixed when the purpose is to isolate design effects.

The number of donors and the number of cells answer different information questions. More cells can reduce the cell-sampling component of uncertainty in donor summaries, but do not create more independent donors. As \(\rho\) rises, cells from one donor share more of their variation, making the effective information gain from additional cells smaller. A simulation that increases only cells per donor may therefore show limited improvement in coverage or test calibration when donor count is small.

Consider evaluating a donor-level summary analysis and a random-intercept analysis under the same generated studies. Each method should be assessed using the same outcomes and target parameter, and the simulation should record the precise interval and test procedure used. A cell-level analysis that treats all cells as independent can be included as a contrast, but it does not become donor-aware simply because the underlying data were simulated with donor effects.

Results can differ across methods and scenarios. A donor-level summary may be transparent and robust to some cell-level distribution details, but may discard information or behave differently when cell counts vary. A mixed model can represent within-donor dependence directly, but relies on its specified random-effects and residual structure and can encounter estimation problems with few donors. Neither method should be declared universally superior from one favorable scenario.

Worked Example: Comparing Two Design Scenarios

Suppose two hypothetical scenarios have the same \(\beta_1=0.40\) units and total marginal variance of 1.00 squared units. Scenario A has 8 donors per condition, 40 cells per donor, and \(\rho=0.10\). Scenario B has the same donor and cell counts but \(\rho=0.50\). For the model above, the corresponding variance components are:

In Scenario A, \(\tau^2=0.10\) and \(\sigma^2=0.90\), since \(0.10/(0.10+0.90)=0.10\). In Scenario B, \(\tau^2=0.50\) and \(\sigma^2=0.50\), since \(0.50/(0.50+0.50)=0.50\).

The variance of a donor’s cell mean, conditional on a fixed cell count \(m=40\), is \(\tau^2+\sigma^2/m\). Thus it is \(0.10+0.90/40=0.1225\) in Scenario A, compared with \(0.50+0.50/40=0.5125\) in Scenario B. This calculation shows why equal cell counts do not make the scenarios equally informative: Scenario B has much greater donor-mean variation.

The simulation should fit each candidate method in both scenarios and separately report bias, coverage, and null rejection rates. The variance calculation motivates the comparison, but it does not predetermine the empirical results for a particular finite-sample procedure.

Diagnostics, Failure Modes, and Limits

Calibration results are only as useful as the simulation that produced them. Check the generated data before interpreting method performance: verify the intended donor counts, condition allocation, cell-count distribution, mean, variance components, and ICC. In a small pilot run, donor summaries and empirical within-donor correlations can reveal coding errors such as accidentally drawing a new donor effect for every cell.

Record convergence and other warnings in every replication. If a method fails to fit in a nontrivial fraction of studies, reporting performance only among successful fits can be misleading: the retained studies may be systematically easier. Report the failure frequency and describe the rule used for failed fits. Also inspect whether extreme estimates, boundary variance estimates, or unusually wide intervals are concentrated in particular scenarios.

Monte Carlo uncertainty is another diagnostic. If two estimated coverage rates differ by less than their simulation noise, the evidence for a performance difference is weak. Increasing \(B\) improves precision of the simulation summaries, with Monte Carlo standard error decreasing approximately in proportion to \(1/\sqrt{B}\). It does not add biological donors to the simulated study, and it does not make a misspecified data-generating process more realistic.

A common mistake is to simulate many cells from a small number of donors, observe a narrow interval, and conclude that the method has abundant independent information. The number of simulated replications \(B\) is also sometimes confused with the number of biological replicates. Neither large cell counts nor a large \(B\) changes the donor count within each study. The correction is to define the independent sampling units in the data-generating process and evaluate the method at the donor counts relevant to the intended application.

Key limitation: Simulation establishes performance only for the scenarios it represents. Calibration under a normal random-intercept model does not guarantee calibration under unmodeled donor heterogeneity, informative missingness, condition-dependent cell sampling, or a different outcome distribution. Use a set of scientifically plausible scenarios, state their assumptions, and interpret conclusions within that range.

Check Your Understanding

Work through each question, then compare your reasoning with the solutions.

  1. In a null simulation with 5,000 replications, a method rejects 265 times. What is the estimated false-positive rate, and how does it compare with \(\alpha=0.05\)?
  2. A method has estimated bias near zero but only 88% coverage for nominal 95% intervals. Is it calibrated in all relevant respects? Explain.
  3. Why can increasing cells per donor fail to resolve poor inference when the number of donors remains small?
  4. What does increasing the number of simulation replications \(B\) improve, and what does it not improve?
  5. A method fails to converge in 8% of simulated studies. Why is it problematic to report coverage only for the remaining studies without mentioning these failures?

Solutions. (1) The estimated rate is \(265/5{,}000=0.053\), or 5.3%, which is 0.3 percentage points above 5%; Monte Carlo uncertainty should be considered before judging that difference. (2) No. Near-zero bias concerns the average estimate, whereas 88% coverage indicates substantial undercoverage relative to the nominal 95% target in that scenario. (3) Additional cells can reduce within-donor sampling variation, but cells from the same donor are correlated and do not replace independent donors for estimating between-donor variation. (4) Increasing \(B\) reduces Monte Carlo error in performance summaries; it does not increase donors per simulated study or correct a misspecified simulation model. (5) Failed fits may occur more often in difficult data sets, so excluding them can make the reported coverage unrepresentative. The failure rate and the handling of unsuccessful fits must be reported.

Clinical Biostats