Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Binned Dispersion for Highly Variable Gene Selection

Highly Variable Genes and Feature Selection · Tutorial 113 of 700

Binned Dispersion for Highly Variable Gene Selection

Learn to calculate and interpret within-bin standardized dispersion scores, then use them to rank genes without confusing relative variability with statistical significance.

Intermediate 12 min read

What You'll Learn

  • Define mean-expression bins and a dispersion measure on a specified expression scale.
  • Calculate within-bin standardized dispersion scores using a consistent standard-deviation convention.
  • Interpret a gene’s score relative to other genes with similar mean expression.
  • Compare binned standardization with raw-dispersion ranking and a smooth mean-variance trend.
  • Diagnose unstable bins, zero dispersion, and inappropriate interpretations of scores.

Why Standardize Dispersion Within Expression Bins?

Genes with higher average expression often have larger raw variability simply because they are more abundant. Ranking genes by raw dispersion can therefore favor high-mean genes, even when their variability is typical for genes at that expression level. Binned dispersion addresses this problem by comparing each gene with genes of similar mean expression, then expressing its dispersion as a within-bin standardized score.

The result is a relative ranking measure, not a test of whether a gene is statistically significant or biologically important. The interpretation depends on the expression scale, dispersion measure, bins, and standardization convention chosen for the analysis.

Definition: Let \(x_{gc}\) be the expression value for gene \(g\) in cell \(c\), measured on a specified analysis scale. Let \(\bar{x}_g\) be that gene’s mean across the cells and \(\hat d_g\) its estimated dispersion on the chosen scale. Partition genes into bins according to \(\bar{x}_g\). Within bin \(b\), transform dispersion to \(y_g\) (often \(y_g=\log(\hat d_g)\) when \(\hat d_g>0\)). The binned standardized dispersion score is \(z_g=(y_g-\bar y_b)/s_b\), where \(\bar y_b\) and \(s_b\) are the mean and sample standard deviation of the transformed dispersions in bin \(b\). A high positive score means the gene is more dispersed than the average gene in its own bin.

Inputs, Bins, and the Standardization Rule

First fix the expression values to be analyzed. The cells should be sufficiently comparable for a gene’s across-cell variation to be interpretable; for example, library-size differences should not dominate the values. Use an expression scale and dispersion estimate appropriate to the analysis. On nonnegative linear-scale measurements, one possible descriptive measure is the variance-to-mean ratio, but other dispersion estimates may be used. The binned procedure does not make different measures interchangeable: the chosen measure and scale must be stated and applied consistently.

Next calculate each gene’s mean expression and assign genes to bins. Bins may be fixed-width intervals or, commonly, intervals chosen to contain roughly similar numbers of genes. The mean can be used directly or transformed for bin assignment, provided the choice is consistent. Binning by mean is intended to compare genes with similar abundance; it does not assume that all genes within a bin have exactly the same mean.

For positive dispersions, taking logs is often useful because dispersion values can span a wide range and their raw distribution can be strongly right-skewed. If the analysis instead uses untransformed dispersion, the same within-bin formula applies to that value. Do not silently mix transformed and untransformed values. A zero dispersion cannot be logged; the analyst must use a defined alternative, such as a suitable dispersion measure that is positive, or treat zero values explicitly rather than adding an arbitrary constant without justification.

For clarity, this tutorial uses the sample standard deviation within each bin. If bin \(b\) contains \(m_b\) genes, its transformed-dispersion mean and standard deviation are:

$$ \bar y_b=\frac{1}{m_b}\sum_{g\in b} y_g, \qquad s_b=\sqrt{\frac{\sum_{g\in b}(y_g-\bar y_b)^2}{m_b-1}}. $$

A bin needs at least two genes for this sample standard deviation to be defined, and in practice needs enough genes for the estimate to be reasonably stable. Some implementations use a population standard deviation or other conventions. Scores from different conventions are not exactly identical, so the convention should be kept consistent when reproducing or comparing rankings.

Worked Example: Standardizing Dispersion in One Bin

Suppose four hypothetical genes fall in the same mean-expression bin. Their log-dispersions are \(-0.2,\ 0,\ 0.2,\ 0.4\). Calculate the standardized score for the gene with log-dispersion \(0.4\).

The bin mean is \(\bar y_b=(-0.2+0+0.2+0.4)/4=0.1\). The deviations from this mean are \(-0.3,\ -0.1,\ 0.1,\ 0.3\), so their squared sum is \(0.09+0.01+0.01+0.09=0.20\). With \(m_b=4\), the sample standard deviation is \(s_b=\sqrt{0.20/(4-1)}=\sqrt{0.06667}\approx0.2582\).

The gene’s score is \(z_g=(0.4-0.1)/0.2582=0.3/0.2582\approx1.162\). Thus its log-dispersion is about 1.162 within-bin sample standard deviations above the bin mean. This is a relative description, not a p-value.

Why the Score Compares Like With Like

Within each bin, the calculation subtracts the bin’s average transformed dispersion and divides by its within-bin spread. This puts genes with different mean expression on a comparable, dimensionless scale. It does not estimate a universal dispersion expected at every possible mean; it standardizes relative to the genes that happen to be assigned to each bin.

The standardization has a direct algebraic justification. Provided \(s_b>0\), the scores within bin \(b\) have mean zero because:

$$ \frac{1}{m_b}\sum_{g\in b}z_g = \frac{1}{m_b s_b}\sum_{g\in b}(y_g-\bar y_b) =0. $$

Their sample variance is one because:

$$ \frac{\sum_{g\in b}(z_g-0)^2}{m_b-1} = \frac{\sum_{g\in b}(y_g-\bar y_b)^2}{(m_b-1)s_b^2} =1. $$

These identities describe the arithmetic of the standardized values. They do not mean that scores follow a normal distribution, that a score of 2 has a particular tail probability, or that the score measures uncertainty about a gene’s true dispersion.

Worked Example: Comparing Genes Across Two Mean Bins

Consider two hypothetical bins of four genes each. The first bin has log-dispersions \(0.20,\ 0.25,\ 0.25,\ 0.35\); the second has \(-0.2,\ 0,\ 0.2,\ 0.4\). Calculate the standardized score for the largest log-dispersion in each bin and compare them.

In the first bin, the mean is \((0.20+0.25+0.25+0.35)/4=0.2625\). The deviations are \(-0.0625,\ -0.0125,\ -0.0125,\ 0.0875\). The squared deviations sum to \(0.00390625+0.00015625+0.00015625+0.00765625=0.011875\). Therefore \(s_b=\sqrt{0.011875/3}\approx0.06292\), and the gene at \(0.35\) has score \((0.35-0.2625)/0.06292\approx1.390\).

For the second bin, the mean is \(0.1\) and the sample standard deviation is \(\sqrt{0.20/3}\approx0.2582\). The gene at \(0.4\) has score \((0.4-0.1)/0.2582\approx1.162\). The first-bin gene has the lower log-dispersion, \(0.35\) rather than \(0.4\), but the higher within-bin score, approximately \(1.390\) rather than \(1.162\). Its dispersion is more unusual relative to its own bin. These are different mean-expression bins, so the comparison is relative, not a claim that the first gene has greater absolute variability.

Using Scores to Select Highly Variable Genes

A ranking can be formed by ordering genes from highest to lowest \(z_g\). A selection rule must then be specified: for example, retain scores above a chosen cutoff, or select a fixed number of genes. Neither the binned formula nor the score itself supplies a universally correct cutoff. The choice depends on the analysis goal and should be reported along with the binning and dispersion choices.

Worked Example: Applying a Score Threshold

Suppose five hypothetical genes in one bin have log-dispersions \(-0.3,\ -0.1,\ 0,\ 0.1,\ 0.5\). A preliminary analysis specifies a rule to retain genes with a score greater than \(1.5\). Determine whether the gene at \(0.5\) passes.

The mean is \(\bar y_b=(-0.3-0.1+0+0.1+0.5)/5=0.04\). The deviations are \(-0.34,\ -0.14,\ -0.04,\ 0.06,\ 0.46\), and the squared deviations sum to \(0.1156+0.0196+0.0016+0.0036+0.2116=0.352\). Thus \(s_b=\sqrt{0.352/(5-1)}=\sqrt{0.088}\approx0.2966\).

The gene’s score is \(z_g=(0.5-0.04)/0.2966=0.46/0.2966\approx1.551\). It passes the stated \(1.5\) threshold. This conclusion means only that it meets this particular ranking rule; it is not evidence from a hypothesis test.

1
Specify the inputs.
Choose the expression scale, a suitable gene-level dispersion measure, and a handling rule for zero or undefined values.
2
Assign bins by mean.
Use a stated binning rule, check the number of genes in each bin, and avoid bins too small to estimate dispersion reliably.
3
Standardize within bins.
Apply the same transformation and standard-deviation convention in every bin, then calculate \(z_g\) for each gene.
4
Rank and inspect.
Apply a clearly stated selection rule and examine both the selected genes and the mean-dispersion pattern before interpreting the set.

Diagnostics, Alternatives, and Limitations

Inspect a plot of dispersion against mean expression, with bin boundaries and standardized scores available for review. The raw dispersion should generally show why adjustment is needed: its level or spread may change with mean. Also inspect bin sizes and score distributions. A bin with only a few genes, a very small \(s_b\), or nearly identical dispersion values can produce unstable or extreme scores. If \(s_b=0\), the score is undefined; do not divide by zero or assign an arbitrary large value.

Other warning signs include abrupt changes in scores at bin boundaries, many zero dispersions, or a selected set dominated by genes in one narrow mean range. These can arise from sparse data, a poorly chosen scale, a small number of genes per bin, or a dispersion estimate that is unreliable for the data. Check whether library-size effects or other technical structure remain: standardizing by mean bins does not correct such effects. The earlier material on estimating a smooth mean-variance trend provides a related way to describe how variability changes with mean.

ApproachWhat it doesMain consideration
Raw-dispersion rankingRanks genes using dispersion without mean adjustment.Can prioritize high-mean genes when dispersion depends on mean.
Binned standardizationCenters and scales dispersion separately among genes in each mean bin.Simple and interpretable, but depends on bin boundaries and bin-specific estimates.
Smooth mean-variance trendEstimates a continuous relationship between mean and variability.Avoids discrete bin boundaries but depends on the fitted trend and its assumptions.

Binned scores are descriptive and data-dependent. They do not account automatically for uncertainty in each gene’s dispersion estimate, correlations among genes, batch effects, or biological design. A high score does not establish differential expression, causality, or relevance to a particular cell type. Small bins and very sparse data are especially limiting, and changing the dataset can change both the bin reference distributions and the resulting ranks.

Common Mistakes

  • Using raw dispersion as if it were mean-independent. A high raw value may reflect high average expression; compare with genes in a similar mean bin.
  • Confusing a standardized score with a test statistic. A score of 2 is not automatically a p-value or evidence against a null hypothesis.
  • Mixing conventions. Changing the transformation, bin assignments, or sample-versus-population SD changes scores; keep the choices explicit and consistent.
  • Ignoring a small or zero-spread bin. Scores can be unstable or undefined when the within-bin standard deviation is poorly estimated or zero.
  • Calling a selected gene biologically important from its score alone. The score ranks relative variability in the analyzed data; interpretation requires context and follow-up.
Key takeaway: Binned dispersion adjusts a gene’s variability relative to genes with similar mean expression. A standardized score is useful for ranking, but its meaning is conditional on the scale, dispersion measure, bins, and within-bin standardization rule.

Check Your Understanding

Answer the questions, then compare your reasoning with the solutions below.

  1. A gene has a large raw dispersion but a score near zero in its mean bin. What does that imply about its dispersion relative to genes of similar mean?
  2. Why is a within-bin score not automatically a p-value?
  3. Four log-dispersions in a bin are \(-0.1,\ 0,\ 0.1,\ 0.4\). Find the mean, sample standard deviation, and score for \(0.4\).
  4. What should be done if a bin contains only one gene or has zero dispersion spread?

Solutions. (1) Its raw dispersion is close to the average transformed dispersion of genes in its bin, so it is not especially high relative to similar-mean genes. (2) The score is a descriptive standardization, not a statistic calibrated under a null distribution; it supplies no tail probability by itself. (3) The mean is \((-0.1+0+0.1+0.4)/4=0.1\). Deviations are \(-0.2,-0.1,0,0.3\), with squared sum \(0.04+0.01+0+0.09=0.14\). Thus \(s_b=\sqrt{0.14/3}\approx0.2160\), and the score is \((0.4-0.1)/0.2160\approx1.389\). (4) A single gene has no within-bin sample standard deviation, and zero spread makes the score denominator zero. Reconsider the binning or explicitly handle the case; do not calculate a score by dividing by zero.

Clinical Biostats