Why Restrict the Permutations?
In genomic experiments, outcomes may be measured across many features, but treatment assignment often follows a design with structure: samples are paired, or units are grouped into blocks before treatment is assigned. A permutation test must respect that structure. If outcomes are exchangeable only within pairs or blocks, shuffling treatment labels across the entire experiment creates assignments that the design could not have produced and may compare units that are not exchangeable under the null.
The key task is therefore to specify the set of treatment assignments allowed by the design, and then calculate the reference distribution using only that set. The earlier material on exchangeability and exact permutation tests gives the general principle: under the null, the data distribution must be invariant under the transformations used to generate the reference distribution. Here, the transformations are restricted by the pairing or blocking structure.
Paired Designs: Swap Labels Within Each Pair
Suppose each pair contains two units, one assigned treatment and one assigned control. Under a sharp null hypothesis that treatment has no effect on any unit, the two outcomes within a pair would be unchanged if their treatment labels were swapped. If treatment was randomized within each pair with equal probability, the two labelings are equally likely. Thus, for each pair, the treatment-minus-control difference can either retain its observed sign or have its sign reversed.
For \(n\) independent pairs, there are \(2^n\) possible within-pair swap patterns. For a single genomic feature, let \(d_i\) denote the observed treatment-minus-control difference for pair \(i\). A natural statistic is the mean paired difference, \(\bar{d}=n^{-1}\sum_{i=1}^n d_i\). Under the restricted scheme, each reference value is \(\bar{d}^*=n^{-1}\sum_{i=1}^n s_i d_i\), where each \(s_i\) is either \(+1\) or \(-1\). This sign-flip interpretation requires the pairwise label swaps to be permitted by the design. It is not a general license to flip signs whenever data happen to be paired.
Worked Example: An Exact Paired Sign-Flip Test
Consider hypothetical expression differences, measured in log2 expression units, from four treatment-control pairs: \(3, 2, 1,\) and \(0\). Suppose treatment was randomized with equal probability within every pair, and test the sharp null of no treatment effect using the absolute mean difference as the two-sided statistic. The observed mean is
There are \(2^4=16\) allowed sign patterns. For any pattern, the signed sum is \(3s_1+2s_2+s_3+0s_4\). The absolute value is at least the observed absolute sum, \(4(1.5)=6\), only when the first three signs are all positive or all negative. The sign on the zero difference can be either way, so four of the 16 assignments meet the tail condition. Therefore,
The result is not statistically significant at \(\alpha=0.05\). This calculation is exact for the stated sharp null and equal-probability within-pair randomization; it does not establish that the null is true. With only four pairs, the attainable p-values are coarse.
Blocked Designs: Preserve the Allocation Within Every Block
A block may contain more than two units. If the design assigns \(m_b\) of the \(N_b\) units in block \(b\) to treatment, the allowed assignments must keep exactly \(m_b\) treated units in that block. Under uniform random allocation subject to these counts, there are \(\binom{N_b}{m_b}\) allowed allocations for block \(b\). If blocks are randomized independently, the total number of assignments is the product of these counts across blocks.
A useful statistic should reflect the comparison intended by the design. One option is to calculate a treatment-control contrast within each block and then average those contrasts, giving each block equal weight. Another option may weight blocks according to their sizes or a prespecified analysis plan. The choice affects the statistic, not the allowed assignments: every reference value must still be calculated using the same statistic and the design-permitted treatment allocations.
Worked Example: Unequal Treatment Counts Within Blocks
Suppose a hypothetical experiment has two blocks. In each block, one of three units is assigned treatment and the other two are controls. The measured outcomes for a single feature are \(9, 6, 3\) in block A and \(8, 5, 2\) in block B. The observed assignment treats the unit with outcome 9 in A and the unit with outcome 8 in B. Use the average of the two within-block contrasts, where each contrast is the treated outcome minus the mean control outcome.
For the observed assignment, block A's contrast is \(9-(6+3)/2=4.5\), and block B's is \(8-(5+2)/2=4.5\). Thus the observed statistic is \((4.5+4.5)/2=4.5\) outcome units. Each block has three possible assignments, so the restricted reference set has \(3\times3=9\) assignments.
In either block, treating the highest, middle, or lowest outcome gives a contrast of \(4.5\), \(0\), or \(-4.5\), respectively. Averaging the two block contrasts gives statistics \(-4.5,-2.25,0,2.25,\) or \(4.5\). Only the assignments giving both blocks \(4.5\), or both blocks \(-4.5\), have absolute statistic at least 4.5. There are two such assignments, so the exact two-sided p-value is \(2/9=0.2222\). The comparison is not significant at \(\alpha=0.05\).
An unrestricted shuffle could place both treated units in one block and neither in the other. Those assignments contradict the design and are excluded. The restricted test conditions on the treatment count in each block.
Validity: Randomization and Exchangeability Are Not the Same Claim
In a randomized experiment, exactness can follow from the assignment mechanism. Under the sharp null, each unit's outcome is fixed regardless of its treatment label. If the design chooses uniformly from the allowed assignments, the observed assignment is uniform over that set under the null. Counting assignments at least as extreme as the observed one therefore gives an exact randomization p-value (with the usual conservative handling of ties).
In observational or model-based settings, there may be no treatment randomization. A permutation test then needs a distributional assumption: conditional on the blocks and the null, the outcomes must be exchangeable under the particular within-block rearrangements. Exchangeability means that applying any permitted rearrangement leaves the joint null distribution unchanged. Merely having matched samples does not guarantee this condition. Differences in variances, time trends, batch effects, or unmodeled structure can make within-group rearrangements invalid.
There is also a distinction between a sharp null and a weaker null such as zero average treatment effect. A sharp null specifies no effect for every unit and permits the randomization argument above directly. A null about only an average effect does not, by itself, fix every unit's unobserved outcome under the alternative assignment. A permutation test based on the sharp-null reference distribution should not automatically be described as exact for every weaker null.
Respect the Actual Assignment Probabilities
Not every restricted design assigns all permissible arrangements with equal probability. For instance, a paired trial might favor one orientation in each pair. In that case, counting every assignment once gives the wrong reference distribution. The correct randomization distribution weights each assignment by its probability under the actual design. This principle also applies when blocks are randomized with unequal probabilities or when some assignments are prohibited.
Worked Example: A Nonuniform Paired Randomization
Consider two hypothetical pairs with fixed outcomes under the sharp null. In each pair, the unit labeled first has an outcome one or two units higher than the second, respectively: the within-pair outcome gaps are 2 and 1 units. Independently in each pair, the first unit receives treatment with probability 0.8 and the second with probability 0.2. Suppose both first units were assigned treatment. The observed mean paired difference is \((2+1)/2=1.5\) units.
The four possible sign patterns give mean differences \(1.5, 0.5, -0.5,\) and \(-1.5\). For the one-sided alternative of a positive treatment effect, only \(1.5\) is at least as large as the observed statistic. Its assignment probability is \(0.8\times0.8=0.64\), so the exact one-sided p-value is 0.64. If one incorrectly treated the four patterns as equally likely, the p-value would be \(1/4=0.25\). That answer uses a different assignment mechanism and is invalid for this design.
Multiple Features, Diagnostics, and Alternatives
When testing many genomic features, the design restriction applies to the sample labels, not separately to each feature. For a given allowed assignment, apply the same within-pair swaps or within-block allocation to all features. This preserves the feature-by-feature dependence induced by measuring the same samples across the genomic panel. Separate feature-wise tests can then use the resulting marginal reference distributions; constructing a joint multiple-testing procedure is a separate step.
Before trusting a restricted test, verify the design record: identify the pairs or blocks, confirm the treatment counts, and check whether assignments were uniform or weighted. Confirm that the statistic is recomputed after each allowed assignment and that no unit crosses a design-defined boundary. In model-based applications, examine whether important patterns remain within blocks under the null. Strong batch trends, heterogeneous variability, or pairwise differences driven by time order can undermine an exchangeability argument even when the code preserves pair membership.
A common mistake is to say, “The samples are related, so I will shuffle all treatment labels and then account for pairing in the statistic.” A paired statistic does not repair an invalid reference set: global shuffling can break pairs and generate assignments unavailable under the design. The correction is to define the allowable assignments first and compute the statistic only over those assignments.
Restricted permutation is attractive because it can give an exact test under a known randomization scheme without requiring a parametric outcome distribution. Its limitations are equally important: small numbers of pairs or blocks produce few distinct assignments and coarse p-values; validity depends on the sharp null for the randomization argument or exchangeability for a model-based argument; and a poorly chosen statistic may have low power for the effect pattern of interest. Model-based analyses can be useful when covariates or unequal variances matter, but they rely on their own assumptions. Residual permutation with nuisance covariates requires separate conditions and is not obtained merely by adding covariates to this label-shuffling procedure.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A study has five randomized pairs. How many within-pair treatment-label assignments are possible?
- In a block of six units, two are assigned treatment uniformly. How many permitted assignments are there in that block?
- Why can a paired statistic still have an invalid permutation p-value if treatment labels are shuffled across all samples?
- In a paired design, the observed one-sided statistic is positive. The assignment mechanism gives the observed orientation probability 0.7 in each of two independent pairs. If only the assignment with both observed orientations is at least as extreme, what is the exact p-value?
Solutions: (1) There are \(2^5=32\) assignments because each pair can retain or swap its labels. (2) There are \(\binom{6}{2}=15\) assignments, since the two treated units must remain in that block. (3) A statistic that uses pairs does not change the assignment mechanism: unrestricted shuffling can break pairs and include labelings the design could not produce, so its reference distribution is not the design-based one. (4) Independence gives probability \(0.7\times0.7=0.49\) for the only assignment in the one-sided tail, so the exact p-value is 0.49.