Tutorials › High-Dimensional Genomic Data Analysis › Zero Counts And Geometric-Mean References

Count-Based Differential Expression for RNA-seq · Tutorial 425 of 795

Zero Counts And Geometric-Mean References

See how zero counts change geometric-mean references, work through alternative size-factor calculations, and assess what each strategy can and cannot establish.

Intermediate 10 min read

What You'll Learn

  • Define the geometric-mean reference used in median-ratio size-factor estimation.
  • Explain why a zero in any sample makes the ordinary geometric mean zero.
  • Calculate size factors using complete-case and positive-count geometric means.
  • Identify how adding a pseudocount changes ratios for low counts and zeros.
  • Diagnose when sparse data make a size-factor estimate unstable or uninformative.

Why Zero Counts Matter

In RNA-seq, a gene can have a recorded count of zero in one sample and positive counts in others. That zero may occur because the gene is not expressed in that sample, or because expression is low enough that sequencing did not record a read. Either way, zero counts create a specific difficulty for the median-ratio size-factor method: its ordinary gene-wise geometric mean becomes zero if even one sample has a zero count. The resulting reference cannot be used to form ratios.

The issue is not just computational. The geometric-mean reference lets a gene contribute a ratio for each sample, while canceling that gene’s expression level when counts differ only by sample scale. With zeros, some strategies discard a gene, some define a modified reference using only positive counts, and some add a pseudocount. These choices do not produce interchangeable estimates.

Definition: Let \(K_{ij}\) denote the count for gene \(i\) in sample \(j\), with \(m\) samples. The ordinary geometric mean for gene \(i\) is \(g_i=(\prod_{j=1}^{m}K_{ij})^{1/m}\). If all counts are positive, its ratio in sample \(j\) is \(r_{ij}=K_{ij}/g_i\). The median of the usable gene ratios within each sample gives an uncentered size factor; size factors are commonly centered so their geometric mean across samples is 1.

This procedure relies on a normalization assumption: across the genes used to construct the reference, most genes are not changing in a coordinated way that would be mistaken for a sample-wide scale difference. It also needs enough usable genes to form informative sample-wise medians. As in the earlier material on median-ratio estimation, the factors describe relative sample scale, not an absolute amount of RNA. Centering fixes their arbitrary common scale but does not establish that the normalization assumption is true.

Three Ways to Handle Zeros

With positive counts, the ordinary geometric mean gives every gene one reference value across the samples. If any count for that gene is zero, then the product is zero and \(g_i=0\). Dividing by that reference is undefined. The standard complete-case approach therefore uses only genes with positive counts in every sample. This is straightforward, but it can leave few genes when the data are sparse.

A modified option is the positive-count geometric mean. For a gene with at least one positive count, let \(P_i\) be the set of samples in which its count is positive, and let \(m_i\) be the number of such samples. Define its positive-count reference as the geometric mean over that set. Ratios can then be formed in every sample, with a zero count producing a ratio of zero. A gene that is zero in every sample has no positive-count reference and contributes nothing. This method uses more genes than the complete-case method, but the reference for each gene is based on a different subset of samples.

$$ g_i^+ = \exp\left(\frac{1}{m_i}\sum_{j\in P_i}\log K_{ij}\right), \qquad r_{ij} = \frac{K_{ij}}{g_i^+}. $$

A third choice is to add a pseudocount, such as 1, before computing geometric means and ratios. This makes all adjusted counts positive, but it changes the data: a zero becomes 1, and a count of 1 becomes 2. The resulting ratios depend on the chosen pseudocount, particularly for genes with small counts. It is therefore not a neutral fix for an undefined reference.

Worked Example: Finding Which Genes Have Ordinary References

Suppose a hypothetical count matrix has three samples and these four genes: \(g_1=(100,200,100)\), \(g_2=(40,0,20)\), \(g_3=(0,30,15)\), and \(g_4=(0,0,0)\). Which genes have a positive ordinary geometric mean?

For \(g_1\), all three counts are positive, so \(g_1=(100\cdot200\cdot100)^{1/3}=\sqrt[3]{2{,}000{,}000}\approx125.99\). Its ordinary ratios are approximately \(100/125.99=0.7937\), \(200/125.99=1.587\), and \(100/125.99=0.7937\).

For \(g_2\), the product includes a zero: \(40\cdot0\cdot20=0\), so its ordinary geometric mean is zero. The same reasoning gives zero for \(g_3\) and \(g_4\). Thus, under the complete-case approach, only \(g_1\) can supply ordinary ratios. The all-zero gene \(g_4\) also has no positive-count reference: it contains no information for this calculation.

Worked Comparison on a Sparse Toy Matrix

The positive-count strategy can recover contributions from \(g_2\) and \(g_3\), but that does not guarantee more reliable size factors. The following calculation shows exactly how the extra ratios affect the result.

Worked Example: Complete-Case and Positive-Count Factors

Use the hypothetical matrix from the previous example. First calculate the complete-case estimates. Only \(g_1\) is eligible, so the raw sample factors are the three ratios from that gene: \(0.7937,\ 1.587,\ 0.7937\). Their product is approximately 1, so their geometric mean is approximately 1; centering leaves the factors at \(0.7937,\ 1.587,\ 0.7937\).

Now calculate positive-count references. For \(g_2\), the positive counts are 40 and 20: \(g_2^+=(40\cdot20)^{1/2}=\sqrt{800}\approx28.28\). Its ratios for samples 1, 2 and 3 are approximately \(1.414,\ 0,\ 0.7071\).

For \(g_3\), the positive counts are 30 and 15: \(g_3^+=(30\cdot15)^{1/2}=\sqrt{450}\approx21.21\). Its ratios are \(0,\ 1.414,\ 0.7071\). The ratio for \(g_1\) remains \(0.7937,\ 1.587,\ 0.7937\).

Take the median within each sample. The three uncentered factors are \(\operatorname{median}(0.7937,1.414,0)=0.7937\), \(\operatorname{median}(1.587,0,1.414)=1.414\), and \(\operatorname{median}(0.7937,0.7071,0.7071)=0.7071\). Their geometric mean is \((0.7937\cdot1.414\cdot0.7071)^{1/3}\approx0.9259\). Dividing each raw factor by 0.9259 gives centered estimates of approximately \(0.857,\ 1.528,\ 0.764\).

The two strategies differ: the complete-case factors are approximately \(0.7937,\ 1.587,\ 0.7937\), whereas the positive-count factors are approximately \(0.857,\ 1.528,\ 0.764\). In this small example, the positive-count method has more gene ratios available, but its additional, zero-containing patterns shift the medians. The calculation alone cannot establish which set better reflects the sample scales.

Why the Modified Reference Is Not the Same Reference

A short algebraic argument clarifies the trade-off. Suppose, as an idealized model for a stable gene, that its counts are exactly \(K_{ij}=s_jq_i\), where \(s_j\) is the sample scale and \(q_i\) is the gene’s stable abundance. With positive counts in every sample, the ordinary geometric mean is \(g_i=q_i(\prod_{j=1}^{m}s_j)^{1/m}\). Consequently, \(K_{ij}/g_i=s_j/(\prod_{k=1}^{m}s_k)^{1/m}\). The gene-specific abundance \(q_i\) cancels, and every stable gene gives the same relative sample scale.

For the positive-count reference, let \(P_i\) be the positive samples for gene \(i\). Under the same idealized expression, its reference uses only the sample scales in \(P_i\), so for a positive count, \(K_{ij}/g_i^+=s_j/(\prod_{k\in P_i}s_k)^{1/m_i}\). That denominator can differ across genes because their positive-sample sets differ. A zero in sample \(j\) also gives a zero ratio rather than the common positive scale ratio. Thus, the exact cancellation that motivates ordinary median ratios no longer holds gene by gene. The method may still give useful robust estimates, but it does not restore the ordinary method’s ideal property.

$$ \frac{K_{ij}}{g_i} = \frac{s_jq_i}{q_i(\prod_{k=1}^{m}s_k)^{1/m}} = \frac{s_j}{(\prod_{k=1}^{m}s_k)^{1/m}}. $$

Worked Example: What a Pseudocount Changes

Consider one hypothetical gene with counts \((1,0,4)\). Its positive-count geometric mean is \(\sqrt{1\cdot4}=2\), producing ratios \(0.5,\ 0,\ 2\). If instead a pseudocount of 1 is added to each count, the adjusted counts are \((2,1,5)\). Their geometric mean is \(\sqrt[3]{2\cdot1\cdot5}=\sqrt[3]{10}\approx2.154\), giving ratios \(2/2.154\approx0.9283\), \(1/2.154\approx0.4642\), and \(5/2.154\approx2.321\).

The zero sample now contributes a positive ratio, and the original count of 1 contributes a substantially different ratio. This is the direct consequence of changing the counts before computing the reference. These are ratios for one gene, not dependable sample-wide normalization factors; in an actual estimation procedure, medians across genes and the chosen pseudocount would matter.

Diagnostics, Alternatives, and Limitations

A practical check is to count how many genes can contribute ratios under the chosen rule and inspect whether each sample has enough informative ratios to form a stable median. If only a small number of genes qualify, or if the estimates change substantially when the zero-handling rule changes, report that sensitivity rather than treating a single factor as unquestionable. A sample with no positive counts at all cannot receive a meaningful factor from these gene-wise ratios: there are no observed positive counts from which to construct a reference.

Zero frequency and zero pattern both matter. If nearly every gene is positive in every sample, the complete-case approach may be adequate. If many genes contain some zeros but there are still broad, overlapping sets of positive counts, the positive-count approach can retain more information, while remaining sensitive to the gene-specific subsets. If very few genes overlap across samples, the ratios may be dominated by a limited and unrepresentative set. In all cases, the assumption that most genes used for normalization are not changing in a coordinated direction remains important.

The main alternatives have different trade-offs. Complete-case median ratios use the ordinary reference and are easy to interpret, but discard every gene with any zero. Positive-count references retain sparse genes but no longer yield a common scale ratio for every gene under the idealized stable-gene argument. Pseudocounts make ratios finite but introduce a chosen offset that has a large relative effect on small counts. TMM, introduced in the earlier material on TMM estimation, uses trimmed and weighted log-ratios between samples rather than a gene-wise geometric-mean reference. It too requires usable positive-count comparisons; extensive sparsity can limit the genes contributing to those comparisons. None of these methods can infer a meaningful global scale from a dataset that provides too little shared information.

Common Mistake

Wrong reasoning: “A zero makes the geometric mean unusable, so I will add 1; the normalization is then valid because every ratio is finite.” A finite calculation does not show that the chosen reference is appropriate. Adding 1 changes low counts disproportionately and can affect the resulting factors.

Correction: State which zero-handling rule is being used, check how many genes and samples contribute, and examine whether conclusions about the factors are sensitive to that rule. Treat pseudocount addition as a substantive choice, not as a mathematically neutral repair. An all-zero gene supplies no positive-count reference under the positive-count strategy, and no zero-handling rule creates information that was not observed.

Key takeaway: Ordinary geometric-mean references require positive counts in every sample for a gene. Positive-count references and pseudocounts can make additional ratios calculable, but they change what those ratios mean. More calculable ratios do not automatically mean more reliable size factors.

Check Your Understanding

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

  1. For counts \((8,0,18)\), what is the ordinary geometric mean, and what is the positive-count geometric mean?
  2. Why can the positive-count reference fail to give the same ideal sample-scale ratio for every stable gene?
  3. What happens to the ordinary geometric mean of an all-zero gene? Can it supply a positive-count reference?
  4. Why is adding 1 to every count not a neutral way to handle zeros?
  5. If only one gene remains eligible under the complete-case rule, what should you be cautious about when interpreting the resulting factors?

Solutions. (1) The ordinary geometric mean is zero because the product \(8\cdot0\cdot18\) is zero. The positive-count geometric mean is \(\sqrt{8\cdot18}=\sqrt{144}=12\). (2) Different genes can be positive in different sample subsets, so their geometric-mean denominators involve different sample scales; a zero count also produces a zero ratio. (3) Its ordinary geometric mean is zero, and it has no positive-count reference because it has no positive observations. (4) Adding 1 changes the counts, with a larger relative effect on small counts; it also turns zero counts into positive ratios. (5) A median based on one gene is highly dependent on that gene and provides little protection against an unrepresentative or changing gene. The normalization assumption and sensitivity to the chosen rule need careful attention.

Clinical Biostats