Why Estimate Median-Ratio Size Factors?
Sequencing libraries can differ in their overall scale: a sample with more reads may have larger counts for many genes even when the underlying expression pattern is similar. Size-factor normalization estimates a sample-specific scale so that counts can be compared on a relative scale. The earlier material on library size factors introduced this general purpose; here the focus is the DESeq median-ratio calculation and its treatment of zeros.
The method compares each gene’s count in a sample with a geometric mean for that gene across samples. It then summarizes those ratios separately for each sample using a median. This is not the same as dividing every count by the sample’s total library count: it uses gene-wise comparisons to construct the scaling estimate.
A positive size factor is available only if the chosen estimator has usable genes and its sample-wise estimates are finite and positive. In the standard calculation, genes with one or more zero counts are excluded because their geometric mean is zero, making the ratio undefined. If no genes remain, the standard method cannot estimate the size factors. Even when the standard median exists, too few or unrepresentative eligible genes can make the estimates unreliable.
Calculation and Interpretation
Write the unrescaled sample estimates as \(s_j^{*}\). With the standard estimator, \(s_j^{*}\) is the sample-wise median of the eligible gene ratios. To use the geometric-mean-one convention, calculate \(c=(\prod_{j=1}^{m}s_j^{*})^{1/m}\) and set \(s_j=s_j^{*}/c\). This rescaling changes the common reference scale, not the relative factors between samples. A normalized count is \(K_{ij}/s_j\).
The factors are relative: they compare samples within the data set, and their geometric mean is one by convention. A factor of 2 means that the sample’s estimated scale is twice the geometric-mean reference scale; it does not mean that every gene is expressed at twice the level. Normalization also does not establish absolute RNA output per cell.
Worked Example: All Counts Positive
Suppose four genes are measured in three hypothetical samples with the following counts:
| Gene | Sample 1 | Sample 2 | Sample 3 |
|---|---|---|---|
| A | 10 | 20 | 40 |
| B | 20 | 40 | 80 |
| C | 40 | 80 | 160 |
| D | 80 | 160 | 320 |
All counts are positive, so all four genes are eligible. For gene A, the geometric mean is \(g_A=(10\times20\times40)^{1/3}=20\), giving ratios \(10/20=0.5\), \(20/20=1\), and \(40/20=2\). The same ratio pattern holds for each gene: each row is a constant multiple of the first row, so its geometric mean is the middle sample’s count.
Thus the four ratios for each sample are identical, and the raw median estimates are \(s_1^{*}=0.5\), \(s_2^{*}=1\), and \(s_3^{*}=2\). Their geometric mean is \(c=(0.5\times1\times2)^{1/3}=1\), so the rescaled factors are also \(0.5,1,2\). For gene A, the normalized counts are \(10/0.5=20\), \(20/1=20\), and \(40/2=20\). This deliberately simple example shows how the estimated scale removes the common sample-level multiplication in these counts.
Why the Ratios Estimate Relative Scale
A simple multiplicative model explains the construction. Suppose, ideally, that \(K_{ij}=q_j a_i\), where \(a_i>0\) represents the level for gene \(i\) and \(q_j>0\) is a sample-specific scale. This is a simplifying model for understanding the estimator, not a claim that real counts are exactly noiseless products. Under this model, every gene is positive, and its geometric mean across the \(m\) samples is:
Consequently, the ratio for gene \(i\) in sample \(j\) is:
In this ideal case, the ratio does not depend on the gene. Every eligible gene gives the same relative scale for a given sample, and the median recovers it. In real data, counts vary across genes and include sampling noise, so ratios differ. The median summarizes their central value. Its interpretation depends on the assumption that the genes available for comparison provide a representative reference: broad, systematic expression shifts can make the estimated scale reflect those shifts rather than technical scale alone.
Zero Counts and Estimator Choices
In the standard method, any gene with a zero in any sample is omitted from the geometric-mean and ratio calculation. This is a mathematical requirement of the stated geometric mean: a product containing zero has geometric mean zero, and division by that mean is undefined. A zero is not replaced by a small number in the standard calculation. Adding a pseudocount would define a different procedure and could substantially affect ratios for low-count genes.
Some implementations provide a positive-count variant: for each gene, the geometric mean is calculated using only its positive counts, and its ratio in a sample with a zero count is still zero. This allows genes with some zeros to contribute, but does not guarantee usable size factors. If at least half of a sample’s ratios are zero, its median can be zero (with an even number of ratios, the median is the average of the two middle ordered values). A zero median cannot serve as a positive divisor for normalized counts. The estimator used must therefore be stated, and its resulting factors checked.
Worked Example: Standard Calculation With Zero Counts
Consider these hypothetical counts. The standard DESeq calculation excludes any gene with a zero in any sample.
| Gene | Sample 1 | Sample 2 | Sample 3 | Standard-method status |
|---|---|---|---|---|
| A | 10 | 20 | 40 | Eligible |
| B | 30 | 60 | 120 | Eligible |
| C | 0 | 15 | 30 | Excluded |
| D | 8 | 0 | 32 | Excluded |
For gene A, \(g_A=(10\times20\times40)^{1/3}=20\), so its ratios are \(0.5,1,2\). For gene B, \(g_B=(30\times60\times120)^{1/3}=60\), giving the same ratios. Genes C and D have zero counts and are excluded, rather than assigned a zero geometric mean and used in a division.
There are two eligible ratios per sample, and each pair is identical. The raw medians are therefore \(0.5,1,2\). Their geometric mean is \((0.5\times1\times2)^{1/3}=1\), so the rescaled size factors remain \(0.5,1,2\). The calculation is defined, but only two genes contribute; that small reference set would not generally provide a dependable estimate.
Worked Example: Zero Median Under a Positive-Count Variant
Use the positive-count variant on the following hypothetical counts. For each gene, take the geometric mean of its positive counts only, then retain a zero ratio for a sample where that gene’s count is zero.
| Gene | Sample 1 | Sample 2 | Positive-count geometric mean |
|---|---|---|---|
| A | 0 | 10 | 10 |
| B | 0 | 20 | 20 |
| C | 5 | 10 | \(\sqrt{50}\approx7.071\) |
| D | 0 | 40 | 40 |
The Sample 1 ratios are \(0/10=0\), \(0/20=0\), \(5/7.071\approx0.7071\), and \(0/40=0\). Ordered, these are \(0,0,0,0.7071\), so the median is \((0+0)/2=0\). For Sample 2, the ratios are \(1,1,10/7.071\approx1.414,1\), whose median is \(1\). The positive-count variant therefore yields a zero raw estimate for Sample 1 and cannot produce a positive size factor for that sample by geometric-mean rescaling. This example shows why including zero ratios is not a guarantee of a usable estimate.
Assumptions, Checks, and Alternatives
Before using the size factors, verify that samples contain counts for the same defined set of genes and that the count matrix has not been transformed in a way that changes the count scale. The standard calculation requires at least one gene positive in every sample to form any ratios; a useful estimate additionally needs enough eligible, representative genes. Its relative-scale interpretation relies on the comparison genes not being dominated by a systematic shift in one direction. If nearly all genes change together, the data alone cannot cleanly distinguish that biological change from a sample-wide scale difference.
Check how many genes are eligible under the standard rule, whether each sample’s raw median is finite and positive, and whether the resulting factors are plausible relative to one another. Very few eligible genes, a zero median in a variant that retains zeros, or factors driven by a narrow subset of genes are warnings that the method may not be estimating a stable scale. A sample with too few positive counts can also leave the standard method with no usable comparisons. Do not silently substitute pseudocounts or change the zero rule without identifying that as a different estimator.
Library-size scaling uses each sample’s total count as its scale estimate. Median-ratio scaling instead compares counts to gene-wise geometric means and takes a median across genes. They can give different factors because the totals can be strongly influenced by a small number of highly abundant genes. Other count-scaling approaches are also available; their assumptions and calculations differ, so they should not be treated as interchangeable without checking whether their reference assumptions suit the data. No size-factor method can recover absolute expression per cell from relative sequencing counts without additional information.
Common Mistakes
- Including a zero in the standard geometric mean. A zero makes that mean zero and the ratio undefined. The standard calculation excludes the entire gene if any sample has a zero.
- Assuming every count matrix produces positive factors. The standard estimator may have no eligible genes. A positive-count variant can produce a zero sample median. Confirm that usable positive estimates exist before dividing counts by them.
- Confusing the factor with a gene’s expression change. A size factor is a sample-level relative scale estimate, not a fold change for every gene.
- Interpreting the geometric-mean-one convention as an absolute scale. Rescaling sets a convenient reference across the samples; it does not establish absolute RNA abundance.
- Using too few eligible genes without qualification. A median can be computed from a small set, but mathematical computability alone does not make the estimate representative or reliable.
Check Your Understanding
Answer each question, then compare with the solutions below.
- A gene has counts 4, 16, and 64. What is its geometric mean and its three ratios?
- Under the standard method, a gene has counts 12, 0, and 24. Is it eligible? Why?
- For one sample, an alternative estimator gives ratios \(0,0,0.8,1.2\). What is the median, and can it be used as a positive size factor?
- Why are raw median estimates rescaled to have geometric mean one?
Solutions. (1) The geometric mean is \((4\times16\times64)^{1/3}=16\); the ratios are \(4/16=0.25\), \(16/16=1\), and \(64/16=4\). (2) No. The zero makes the gene’s geometric mean zero, so its standard ratios are undefined; the gene is excluded. (3) The ordered ratios are unchanged, and the median is \((0+0.8)/2=0.4\). It is positive, so it can be a positive factor for this sample, though broader data checks are still needed. (4) Rescaling gives a convenient common reference and leaves relative factor ratios unchanged; it does not convert the estimates into absolute expression scales.