Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Effective Sample Size Under Cell Clustering

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

Effective Sample Size Under Cell Clustering

You will calculate effective sample size from donor counts, cell counts, and within-donor correlation, and interpret what that number does—and does not—tell you.

Advanced 11 min read

What You'll Learn

  • Define effective sample size by matching the variance of a clustered cell mean to that of independent cells.
  • Calculate effective sample size for equal and unequal numbers of cells per donor.
  • Explain why even modest within-donor correlation can sharply reduce independent-cell equivalents.
  • Distinguish effective sample size from the number of biological donors.
  • Check assumptions and recognize when a single effective-size calculation may be misleading.

Why the Number of Cells Can Overstate Information

A single-cell experiment may measure thousands of cells, but cells from the same donor tend to resemble one another. Consequently, observing more cells from a donor does not generally add as much independent information as observing the same number of cells from new donors. Effective sample size expresses this loss of information as an equivalent number of independent cells for a particular mean and correlation model.

This quantity is useful for understanding the effect of clustering, but it is not a substitute for the number of biological replicates. It answers a narrower question: how large would a sample of independent cells need to be to have the same variance as the clustered cell mean, under specified assumptions?

Definition: Suppose \(N\) cells have common marginal variance \(\sigma^2\), and let \(\bar{X}\) be their cell-weighted mean. The effective sample size, \(N_{\mathrm{eff}}\), is defined by matching the variance of \(\bar{X}\) to the variance \(\sigma^2/N_{\mathrm{eff}}\) of a mean from \(N_{\mathrm{eff}}\) independent cells: $$ \operatorname{Var}(\bar{X})=\frac{\sigma^2}{N_{\mathrm{eff}}}. $$ When within-donor correlation is positive, \(N_{\mathrm{eff}}\) is usually smaller than the raw cell count \(N\). It is an independent-cell equivalent for this variance calculation, not a count of donors.

Model and Effective-Size Formula

Suppose there are \(J\) donors, with \(m_j\) measured cells from donor \(j\), so that \(N=\sum_{j=1}^{J}m_j\). Let \(X_{ij}\) denote the outcome for cell \(i\) from donor \(j\). For this calculation, assume the following:

  • Each cell outcome has the same marginal variance \(\sigma^2\).
  • Cells from different donors are independent.
  • Within a donor, every pair of distinct cells has the same correlation \(\rho\), the intraclass correlation coefficient (ICC).
  • The cell-weighted mean is the quantity of interest, and the donor cell counts are treated as fixed for the variance calculation.

These assumptions give a simple exchangeable within-donor covariance model: the covariance of two distinct cells from the same donor is \(\rho\sigma^2\). A variance is nonnegative and the full correlation matrix must be valid; in the usual application here, \(\rho\) is nonnegative. The ICC is specific to the outcome being analyzed and should not automatically be shared across genes or cell populations.

1
Start with the cell-weighted mean.
\(\bar{X}=N^{-1}\sum_{j=1}^{J}\sum_{i=1}^{m_j}X_{ij}\). Its variance is the sum of the variances and covariances of all cell outcomes, divided by \(N^2\).
2
Count variance and covariance terms.
There are \(N\) individual-cell variance terms, each \(\sigma^2\). Donor \(j\) contributes \(m_j(m_j-1)\) ordered covariance terms, each \(\rho\sigma^2\).
3
Divide by the squared total count.
Independence across donors means there are no cross-donor covariance terms. Thus \(\operatorname{Var}(\bar{X})=\frac{\sigma^2}{N^2}\left[N+\rho\sum_{j=1}^{J}m_j(m_j-1)\right]\).
4
Match to independent-cell variance.
Factoring out \(\sigma^2/N\) gives the design effect \(D=1+\frac{\rho}{N}\sum_{j=1}^{J}m_j(m_j-1)\). Equating \(\sigma^2/N_{\mathrm{eff}}\) to \(D\sigma^2/N\) yields \(N_{\mathrm{eff}}=N/D\).

The ordered-pair count matters. Among \(m_j\) cells there are \(m_j(m_j-1)\) ordered pairs of distinct cells: each of the \(m_j\) cells is paired with each of the other \(m_j-1\) cells. Equivalently, there are \(m_j(m_j-1)/2\) unordered pairs, and each covariance appears twice in the variance of a sum. Either counting convention gives the same formula when used consistently.

Result: For the cell-weighted mean under the assumptions above, $$ D=1+\frac{\rho}{N}\sum_{j=1}^{J}m_j(m_j-1), \qquad N_{\mathrm{eff}}=\frac{N}{D}. $$ If every donor contributes the same number \(m\) of cells, then \(N=Jm\) and the formula simplifies to \(D=1+(m-1)\rho\), so \(N_{\mathrm{eff}}=Jm/[1+(m-1)\rho]\).

Worked Calculations

Worked Example: Equal Cell Counts and a Small ICC

Suppose five hypothetical donors each contribute 50 cells, for \(N=250\). For a specified gene outcome, assume the within-donor ICC is \(\rho=0.02\). Under the equal-count model, each cell is correlated with 49 other cells from the same donor, so $$ D=1+(m-1)\rho=1+(50-1)(0.02)=1+0.98=1.98. $$

Therefore, $$ N_{\mathrm{eff}}=\frac{250}{1.98}=126.2626\ldots\approx126.3. $$

The clustered mean has the same variance, under this model, as a mean from about 126.3 independent cells with the same marginal variance. The experiment still has five biological donors and 250 measured cells; the effective size is neither of those counts.

Worked Example: Unequal Cell Counts

Consider three hypothetical donors contributing 10, 20, and 30 cells, respectively. The total is \(N=60\). Suppose the outcome-specific ICC is \(\rho=0.10\). First calculate the within-donor pair total: $$ \sum_{j=1}^{3}m_j(m_j-1)=10(9)+20(19)+30(29)=90+380+870=1340. $$

Then the design effect is $$ D=1+0.10\left(\frac{1340}{60}\right) =1+2.2333\ldots =3.2333\ldots. $$

The effective sample size is $$ N_{\mathrm{eff}}=\frac{60}{3.2333\ldots}=18.5567\ldots\approx18.56. $$

Thus, 60 clustered cells provide about 18.56 independent-cell equivalents for this mean under the assumed ICC and covariance model. The smaller donors contribute fewer within-donor pairs than the donor with 30 cells; replacing the unequal counts with an unexamined “average cluster size” can obscure that structure.

Worked Example: Unequal Counts Versus Equal Counts

Compare two hypothetical designs with 120 cells, four donors, and \(\rho=0.05\). In the first design, each donor contributes 30 cells. Then $$ D=1+(30-1)(0.05)=2.45, \qquad N_{\mathrm{eff}}=\frac{120}{2.45}\approx48.98. $$

In the second design, the four donors contribute 15, 25, 35, and 45 cells. The pair total is $$ 15(14)+25(24)+35(34)+45(44)=210+600+1190+1980=3980. $$ Thus, $$ D=1+0.05\left(\frac{3980}{120}\right) =2.6583\ldots, \qquad N_{\mathrm{eff}}=\frac{120}{2.6583\ldots}\approx45.14. $$

Although both designs have 120 cells and four donors, the unequal design has a larger design effect and a smaller effective size for this cell-weighted mean. More of its cells are concentrated in the largest donor, creating more within-donor cell pairs. This is a variance comparison under the stated model, not a claim that one design necessarily answers every biological question better.

Interpreting the Number and Checking the Model

With positive \(\rho\), each within-donor covariance adds to the variance of the mean, making \(D\geq1\) and \(N_{\mathrm{eff}}\leq N\). If \(\rho=0\), the model gives \(D=1\) and \(N_{\mathrm{eff}}=N\): clustering adds no variance relative to independent cells. With equal cluster sizes and \(\rho=1\), \(N_{\mathrm{eff}}=J\), since cells within each donor are perfectly correlated in this model. With unequal sizes and \(\rho=1\), \(N_{\mathrm{eff}}=N^2/\sum_jm_j^2\), which reflects how unevenly the cell-weighted mean weights the donors.

An effective size is not a degrees-of-freedom calculation, a confidence interval, or a replacement for the number of donors. It does not make the observed cells independent, and it does not by itself specify an inferential procedure. In particular, a study with five donors does not become a study with 126 biological replicates because its effective size is 126 independent-cell equivalents for a selected mean.

Before using the calculation, check that the cluster counts are correct, that the outcome and cell population match the ICC being used, and that the assumed within-donor correlation is a reasonable summary. If correlation varies greatly across donors or cell pairs, the exchangeable model may be too simple. If donor-specific means or other dependence structures are important, a single ICC may not capture all sources of variation. Effective size can also be sensitive to \(\rho\), especially when donors contribute many cells, so it is often informative to show results over a plausible range of ICC values rather than report one number as exact.

QuantityWhat it describesWhat it does not mean
Raw cell count \(N\)Number of measured cellsNumber of independent observations when cells are correlated
Donor count \(J\)Number of biological donors representedEffective number of independent cells for every cell-level mean
Effective sample size \(N_{\mathrm{eff}}\)Independent-cell equivalent for the variance of a specified mean under a specified modelNumber of biological replicates or inferential degrees of freedom

Common Mistakes and Alternatives

  • Using the raw cell count as if all cells were independent. This ignores positive within-donor covariance. Use the design effect to describe the variance inflation for the specified mean.
  • Calling the effective size the number of donors. It is a variance-matched cell equivalent. Report the actual donor count separately.
  • Using one ICC for every gene without justification. Correlation can differ by outcome and cell population. The value used should be appropriate to the analysis, with uncertainty or sensitivity considered where relevant.
  • Ignoring unequal cluster sizes. When cell counts differ, use \(\sum_jm_j(m_j-1)\) for this cell-weighted mean rather than assuming the equal-cluster formula applies exactly.

The effective-size calculation is a compact summary of variance inflation, not the only way to account for clustered data. An analysis that models the clustered covariance can retain the actual observations and dependence structure rather than replacing them with an equivalent count. A donor-level summary instead changes how observations are weighted and can target a different estimand; it should not be treated as a mechanical conversion from \(N_{\mathrm{eff}}\).

A common error is to argue, “There are hundreds of cells, so the estimate must be precise,” without considering their dependence. The correction is to specify the mean, cluster sizes, and within-donor correlation, then compare its modeled variance with the independent-cell variance. The result quantifies information loss for that setup; it does not erase the biological replication structure.

Check Your Understanding

Try each calculation before reading the solutions. Assume the exchangeable within-donor model and a cell-weighted mean unless a question says otherwise.

  1. Eight donors each contribute 25 cells. If \(\rho=0.04\), calculate the design effect and effective sample size.
  2. There are 250 cells and the assumed within-donor correlation is zero. What is the effective sample size, and why?
  3. Three donors contribute 10, 20, and 30 cells, and \(\rho=0.10\). Calculate the ordered pair total, design effect, and effective sample size.
  4. An experiment has \(N_{\mathrm{eff}}=40\) under a chosen model. Does this mean that the study has 40 biological donors? Explain.
  5. Why might the effective size calculated for one gene not apply to another gene?

Solutions. (1) \(N=8(25)=200\), \(D=1+(25-1)(0.04)=1.96\), and \(N_{\mathrm{eff}}=200/1.96\approx102.0\) independent-cell equivalents. (2) \(D=1\), so \(N_{\mathrm{eff}}=250\); with zero within-donor correlation under the model, clustering adds no variance relative to independent cells. (3) The pair total is \(10(9)+20(19)+30(29)=90+380+870=1340\). Thus \(D=1+0.10(1340/60)\approx3.233\), and \(N_{\mathrm{eff}}=60/3.233\approx18.56\). (4) No. Effective size matches the variance of a specified mean to that of independent cells; the number of biological donors remains the observed donor count. (5) A gene may have a different within-donor correlation, cell-level variance, or relevant cell population, so the model and correlation should be considered for the outcome being analyzed.

Clinical Biostats