Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Donor-Restricted Permutation Tests

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

Donor-Restricted Permutation Tests

Learn to construct donor-level permutation tests, identify when their p-values are valid, and avoid treating cells as independent replicates.

Advanced 11 min read

What You'll Learn

  • Define the exchangeability or randomization assumptions required for a donor-level permutation test.
  • Construct the allowed label assignments while preserving the observed group sizes.
  • Calculate an exact two-sided permutation p-value from donor summaries.
  • Use Monte Carlo permutations when enumerating all assignments is impractical.
  • Explain why shuffling cell labels can break the donor-level sampling structure.
  • Diagnose when a permutation test is unsuitable and compare it with donor-level alternatives.

Why Permute Donor Labels?

In a single-cell study, a condition may be measured in thousands of cells but represented by only a modest number of independent donors. If the scientific question concerns a difference between conditions across donors, the permutation procedure must reflect that sampling structure. The relevant units to reassign are the donors, not the cells within them.

A donor-restricted permutation test compares the observed group difference with the differences that could arise under other allowed assignments of group labels to the same donor-level summaries. It can provide an exact test when the assignment mechanism or a suitable exchangeability assumption makes those assignments equally plausible under the null. It does not make a small donor sample large, nor does it remove the need to specify the null hypothesis and design.

Definition: A donor-restricted permutation test computes a test statistic from donor-level observations, then recalculates it under allowable rearrangements of group labels across independent donors. The rearrangements preserve design restrictions, such as the number of donors in each group. Cells are not treated as independent units for this reassignment.

What Makes a Permutation Test Valid?

Let \(Y_i\) be a prespecified summary for donor \(i\), and let \(G_i\) be that donor's group label. For example, \(Y_i\) might be the mean expression of a gene among the donor's cells in a defined cell type. The summary should be computed by the same rule for every donor, and the analysis should use one row per donor. A common statistic for two groups is the difference in donor means:

$$ T_{\mathrm{obs}}=\bar{Y}_A-\bar{Y}_B. $$

The permutation test holds the observed donor summaries fixed and rearranges the group labels according to the study's assignment scheme. If group A has \(n_A\) donors and group B has \(n_B\), with \(n=n_A+n_B\), an unrestricted two-group allocation permits \(\binom{n}{n_A}\) assignments of the A label. The B label is assigned to the remaining donors. In this setting, the possible values of the statistic form the permutation distribution.

The validity condition is about assignments, not merely about having a numerical statistic. In a randomized study, the test is exact for a sharp null of no treatment effect on any donor if the permutations reproduce the actual randomization scheme. In an observational comparison, exactness instead requires that, under the null, donor outcomes be exchangeable with respect to the group labels, conditional on the restrictions used. For a simple unrestricted test, this means that the donor-level outcomes have the same distribution across groups under the null. Equality of group means alone does not generally imply exchangeability; groups could have different variances or shapes while sharing a mean.

Donors must be independent sampling units for the intended inference, and the allowed permutations must preserve relevant design features. If assignment was constrained, or if valid randomization was conducted within strata, the permutation scheme must preserve those constraints. Shuffling every label freely when the design did not allow that assignment does not reproduce the null distribution. Technical replicates or multiple samples from one donor do not become independent donors simply because they appear as separate rows.

Key condition: A permutation p-value is justified when the observed assignment and the allowed permuted assignments are equally plausible under the null, conditional on the design information being held fixed. For observational data, this requires an appropriate exchangeability assumption; it is not guaranteed by equal sample sizes or by computing a donor-level summary.

Exact P-Values and Their Justification

For a two-sided test using a statistic where larger absolute values indicate stronger disagreement with the null, the exact permutation p-value is the fraction of allowed assignments whose statistic is at least as extreme as the observed one. Ties count as at least as extreme. If \(\mathcal{A}\) is the set of allowed assignments and \(T(a)\) is the statistic under assignment \(a\), then:

$$ p_{\mathrm{perm}} = \frac{\#\{a\in\mathcal{A}:|T(a)|\geq |T_{\mathrm{obs}}|\}} {\#\mathcal{A}}. $$

The reason this calculation controls the test's type I error under the stated conditions is that, under the null, the observed assignment is uniformly distributed among the allowed assignments. The rank of its statistic within the permutation distribution is therefore itself determined by a uniform position, with ties handled conservatively by counting all equally extreme assignments. A test that rejects when this tail fraction is no greater than \(\alpha\) consequently has null rejection probability no greater than \(\alpha\). Because the number of assignments can be small, an exact test may have only a few attainable p-values.

Worked Example: Enumerating Every Assignment

Suppose four independent donors have hypothetical donor-level expression summaries of 2, 3, 5, and 6 normalized units. Two donors were assigned to group A and two to group B. Use the difference in group means, \(\bar{Y}_A-\bar{Y}_B\), and calculate the exact two-sided permutation p-value.

For the observed allocation, group A has summaries 2 and 3, and group B has 5 and 6. Thus \(\bar{Y}_A=(2+3)/2=2.5\), \(\bar{Y}_B=(5+6)/2=5.5\), and \(T_{\mathrm{obs}}=2.5-5.5=-3.0\) normalized units.

There are \(\binom{4}{2}=6\) possible choices of two donors for group A. The corresponding differences are \(-3,-1,0,0,1,3\) normalized units. The absolute value is at least \(|-3|=3\) for two of the six assignments. Therefore:

$$ p_{\mathrm{perm}}=\frac{2}{6}=0.3333. $$

At significance level \(\alpha=0.05\), this test does not reject the null. The result does not show that the groups are equivalent; with only four donors, the exact test has very limited resolution. The calculation is exact only under an assignment or exchangeability condition that makes the six allocations equally plausible under the null.

A Larger Exact Test and the Resolution Limit

As the number of donors increases, the number of possible allocations can grow quickly. Even so, when it is manageable, enumerating every allowed allocation gives the exact permutation distribution and avoids Monte Carlo approximation. The smallest possible p-value depends on the number and structure of the permitted assignments; it is not determined by the number of cells.

Worked Example: A Six-Donor Randomized Comparison

Consider a hypothetical randomized study assigning six independent donors, three to each condition. The donor summaries, in normalized units, are 1, 2, 4, 5, 7, and 8. The observed A group contains 1, 2, and 4; the B group contains 5, 7, and 8. Test the sharp null of no treatment effect on any donor using the difference in means.

The observed difference is:

$$ T_{\mathrm{obs}}=\frac{1+2+4}{3}-\frac{5+7+8}{3} =\frac{7}{3}-\frac{20}{3} =-4.333\text{ normalized units}. $$

There are \(\binom{6}{3}=20\) possible allocations of three donors to group A. The most negative possible difference is obtained by assigning the three smallest summaries to A and the three largest to B; it is \(-4.333\). The largest possible difference, \(4.333\), occurs when those assignments are reversed. No other allocation has an absolute difference as large as the observed one, so two of the 20 assignments are at least as extreme:

$$ p_{\mathrm{perm}}=\frac{2}{20}=0.1000. $$

At \(\alpha=0.05\), the test does not reject the sharp null. The group difference is the most extreme available, but the total of 20 assignments means even this result has a p-value of 0.10. This illustrates why donor count, not cell count, governs the possible resolution of this test.

Monte Carlo Permutations

If enumerating all allowed assignments is impractical, sample \(B\) assignments from the valid permutation scheme and recalculate the statistic for each. For a two-sided test, let \(b\) be the number of sampled statistics with absolute value at least \(|T_{\mathrm{obs}}|\). A commonly used finite-simulation estimate is:

$$ \hat{p}_{\mathrm{MC}}=\frac{b+1}{B+1}. $$

The added one treats the observed assignment as part of the reference set and prevents a reported Monte Carlo p-value of zero. This is an approximation based on the sampled assignments, not a full enumeration. With too few draws, the estimate can vary noticeably from run to run, especially for small tail probabilities. Report \(B\), the tail-count rule, and whether the p-value was exact or Monte Carlo. Increasing \(B\) reduces simulation error but does not repair an invalid permutation scheme.

For example, if \(B=999\) assignments are sampled and \(b=39\) have an absolute statistic at least as large as the observed one, then \(\hat{p}_{\mathrm{MC}}=(39+1)/(999+1)=0.0400\). This estimate is based on the donor-level statistic and valid donor-level assignments; using many simulated rearrangements cannot compensate for having few independent donors.

Why Cell-Level Shuffling Fails

Cells from the same donor share biological and technical features, so their measurements are not generally independent draws from a common population of cells. Unrestricted cell-level shuffling breaks the donor clusters: it can assign cells from one donor to both conditions and creates arrangements that were not possible under a design in which condition was assigned or observed at the donor level. The resulting reference distribution answers a different question and may make uncertainty appear much smaller than the donor-level evidence supports.

Worked Example: Unequal Cell Counts Do Not Change the Replication Unit

Suppose four hypothetical donors have donor-level expression summaries 1 and 3 in group A, and 5 and 7 in group B, all in normalized units. The donors contribute 100, 2, 2, and 100 cells, respectively. For equal donor weighting, the observed group means are \((1+3)/2=2\) for A and \((5+7)/2=6\) for B, so the difference is \(-4\) normalized units. There are six ways to assign two of these four donors to A. Only the allocations separating the two smallest from the two largest summaries have an absolute difference of 4, giving a two-sided donor-level permutation p-value of \(2/6=0.3333\).

By contrast, weighting each donor's summary by its cell count gives A's cell-weighted mean \((100\times1+2\times3)/102=1.039\) and B's \((2\times5+100\times7)/102=6.961\), a difference of \(-5.922\) normalized units. That is a different summary, dominated by the high-cell-count donors. Shuffling the 204 cells as if they were 204 independent replicates would additionally discard donor identity and the observed clustering. Neither a large number of cells nor a small cell-level p-value makes that cell-level shuffle a valid test of a donor-level condition effect.

Diagnostics, Alternatives, and Limits

Before interpreting a result, verify that the design and computation match the intended inference. Useful checks include:

  • Confirm that each independent donor contributes one analysis unit, or that any repeated measurements are handled according to the design rather than counted as new donors.
  • Check that the donor summary and cell-type definition were selected consistently across donors and were not changed after inspecting which choice produces the strongest result.
  • Verify the group sizes and any assignment restrictions in every permutation. If only certain assignments were possible, exclude all others.
  • Compare the observed statistic with the full or sampled permutation distribution. A reversed group coding should reverse the sign of a difference but leave a two-sided p-value unchanged.
  • Check whether a few donors dominate the summaries. A permutation test does not protect against outliers, influential donors, measurement errors, or poor donor summaries.

A donor-level two-sample \(t\)-test is a parametric alternative for comparing group means; it relies on its own assumptions about the donor-level data and reference distribution. A donor bootstrap, covered in the earlier material on bootstrapping donors rather than cells, resamples independent donors to estimate uncertainty rather than rearranging labels to test a null. These approaches answer related but distinct inferential questions. A cell-level permutation is not an appropriate shortcut when the intended unit is the donor.

Permutation tests also have important limits. They do not eliminate confounding in an observational study: exchangeability may be implausible if donor group membership is associated with other causes of the outcome. A test of a sharp no-effect null is not, without additional assumptions, a confidence interval for the size of an effect. In particular, a small p-value is not the probability that the null is true, and a large p-value does not establish no effect. Report the donor-level effect estimate and its units alongside the p-value, and interpret both in light of the design and limited donor sample.

Common mistake: “There are thousands of cells, so I can randomly shuffle thousands of condition labels and obtain a precise test.” This treats cells from the same donor as independently assignable replicates. The correction is to define the donor-level summary, preserve the actual number and arrangement of independent donors, and permute labels only among assignments allowed by the design.

Check Your Understanding

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

  1. In an unrestricted two-group test with five independent donors, two assigned to A and three to B, how many label assignments are possible?
  2. For a two-sided permutation test, the observed statistic is 2.1. Among 99 sampled valid permutations, 7 have absolute statistics at least 2.1. Calculate the Monte Carlo p-value using the plus-one formula.
  3. Why is equality of group means alone insufficient to guarantee an exact permutation test in an observational comparison?
  4. A study has many cells but only four independent donors. Which count governs the donor-level permutation distribution, and why?
  5. What does a donor-level two-sided permutation p-value of 0.04 mean, and what does it not mean?

Solutions. (1) There are \(\binom{5}{2}=10\) assignments for group A. (2) \(\hat{p}_{\mathrm{MC}}=(7+1)/(99+1)=0.0800\). (3) Equal means can coexist with different group distributions, such as different variances, so labels need not be exchangeable under a mean-only null. (4) The four donors govern the assignments because they are the independent units being relabeled; cells within a donor do not create new independent assignments. (5) Under the stated null and valid permutation assumptions, 4% of allowed assignments would produce a statistic at least as extreme as observed. It is not a 4% probability that the null is true, nor proof that the group difference is causal in an observational study.

Clinical Biostats