Tutorials › High-Dimensional Genomic Data Analysis › Upper-Quartile Scaling and Other Count-Scaling Choices

Normalization and Batch Effects · Tutorial 82 of 795

Upper-Quartile Scaling and Other Count-Scaling Choices

Learn to calculate and compare three count-scaling factors, identify when zeros or highly expressed genes make them unreliable, and choose a method that fits the library composition.

Intermediate 10 min read

What You'll Learn

  • Define total-count, median, and upper-quartile summaries for a count library.
  • Center scaling factors so their geometric mean is one.
  • Compare how a highly expressed gene can affect total-count scaling.
  • Recognize when sparse counts make median scaling unusable.
  • Assess whether the upper quartile is stable given the prevalence of highly expressed genes.
  • Choose and diagnose a scaling method using the assumptions behind its reference summary.

Why Compare Count-Scaling Choices?

Sequencing libraries can contain different numbers of reads, but their totals can also differ because their reads are distributed differently across genes. A few very highly expressed genes may account for a large share of one library. In that situation, dividing every count by the library total can make genes with unchanged counts appear to have changed. Median and upper-quartile scaling use other summaries of the count distribution, but they are not automatically reliable: each needs its reference summary to behave consistently across samples.

The introductory material on library size factors establishes the purpose of scaling: to account for sample-level differences in sequencing opportunity before comparing gene counts. Here the focus is on three ways to define the reference summary. The appropriate choice depends on the pattern of counts, especially the number of zeros and how prevalent the highly expressed genes are.

Definition: Let \(Y_{gj}\) be the observed count for gene \(g\) in library \(j\), and let \(G\) be the number of measured genes. The total count is \(L_j=\sum_{g=1}^{G}Y_{gj}\). The median summary \(M_j\) is the median of the \(G\) counts in library \(j\). For upper-quartile scaling, \(U_j\) is the 75th percentile of the positive counts in library \(j\); zero counts are excluded. For a positive summary \(S_j\), its centered scaling factor is \(f_j=S_j/\exp\{J^{-1}\sum_{j=1}^{J}\log(S_j)\}\), where \(J\) is the number of libraries. The scaled count is \(Y_{gj}/f_j\).

For quartiles in this tutorial, use linear interpolation between adjacent ordered positive counts when the percentile falls between them. Software packages may use different quantile conventions or include zeros; state the convention when reporting an analysis. Centering a set of summaries makes the geometric mean of the factors one. It changes their scale, not their relative ratios.

What Each Summary Assumes

A useful sampling model is that the expected count for gene \(g\) in library \(j\) is proportional to an effective sequencing depth \(d_j\) times the gene's relative abundance \(a_{gj}\): \(E(Y_{gj})=d_j a_{gj}\). A scaling summary can estimate relative depth if it responds to \(d_j\) while its underlying abundance reference is sufficiently stable across samples. This is an assumption about the data, not a property guaranteed by the formula.

Total-count scaling uses \(L_j\), so it is simple and incorporates all reads. It works well when library totals mainly reflect sequencing depth and the overall composition is comparable. However, since counts contribute to their own denominator, a small number of exceptionally large counts can dominate \(L_j\). Median scaling uses the center of the gene-count distribution. It can resist a minority of extreme counts, provided that the median is positive and the central part of the distribution is a stable reference. With many zeros, its median can be zero and cannot define a positive factor.

Upper-quartile scaling uses a high, but not maximal, point in the distribution of positive counts. It is less affected than the total by one or a few extreme genes, and excluding zeros avoids a quartile that is zero merely because of sparsity. It still assumes that the upper part of the positive-count distribution is comparable across libraries. If a large fraction of genes are highly expressed or change together, that quartile can itself shift for biological reasons. No one of these summaries can, from counts alone, distinguish a global change in RNA abundance from a change in sequencing depth.

A Short Justification for Centering and Comparison

The reason for centering is to express each library's summary relative to the geometric mean summary. For two libraries \(A\) and \(B\), the common geometric-mean denominator cancels:

$$ \frac{f_B}{f_A}=\frac{S_B}{S_A}. $$

Thus the scaled-count ratio for a gene is

$$ \frac{Y_{gB}/f_B}{Y_{gA}/f_A} = \frac{Y_{gB}}{Y_{gA}}\frac{S_A}{S_B}. $$

If gene \(g\)'s counts are unchanged but the chosen summary doubles from library \(A\) to library \(B\), scaling makes its ratio one-half. That is appropriate only if the summary's doubling represents a twofold technical depth difference. If instead the summary doubled because many genes or a group of highly expressed genes changed biologically, that adjustment can obscure or distort the biological signal.

Worked Example: One Highly Expressed Gene and Three Scaling Choices

Suppose five hypothetical genes have counts \((10,10,10,10,960)\) in library A and \((10,10,10,10,1960)\) in library B. The first four counts are unchanged; the last gene is highly expressed. Compare the factors and the normalized counts for an unchanged gene.

The totals are \(L_A=1000\) and \(L_B=2000\). Their geometric mean is \(\sqrt{1000\times2000}=1414.214\), giving centered total-count factors \(f_A=1000/1414.214=0.7071\) and \(f_B=2000/1414.214=1.4142\). For gene 1, the scaled counts are \(10/0.7071068=14.142\) and \(10/1.414214=7.071\). The resulting ratio is \(0.5000\), even though the observed counts for that gene are equal.

The median is 10 in both libraries. The upper quartile is also 10 in both: with five ordered counts, the 75th-percentile position is \(1+4(0.75)=4\), and the fourth count is 10. Both methods therefore give factors of 1 in each library. The unchanged gene remains at 10 in both scaled libraries. In this hypothetical composition, total-count scaling treats the increase in the highly expressed gene as if it were greater sequencing depth; the median and upper quartile are less affected. Whether that increase is biological or technical cannot be decided from this calculation alone.

Worked Example: Sparse Counts and a Zero Median

Consider hypothetical libraries with six gene counts each: A has \((0,0,0,0,8,10)\), and B has \((0,0,0,0,16,20)\). The total counts are 18 and 36. The median of all six counts is the average of the third and fourth ordered values, so it is 0 in both libraries. Median-based factors cannot be formed by dividing by these zero summaries.

For upper-quartile scaling, the positive counts are \((8,10)\) and \((16,20)\). With two values, the 75th-percentile position is \(1+1(0.75)=1.75\). Thus \(U_A=8+0.75(10-8)=9.5\), and \(U_B=16+0.75(20-16)=19\). Their geometric mean is \(\sqrt{9.5\times19}=13.435\), giving factors \(f_A=9.5/13.435=0.7071\) and \(f_B=19/13.435=1.4142\). The scaled positive counts match: \(8/0.7071068=11.314\) and \(16/1.414214=11.314\); likewise, \(10/0.7071068=14.142\) and \(20/1.414214=14.142\).

The total-count factors here have the same ratio, because the total counts also double. This is a deliberately simple example: both usable summaries agree, while the median is undefined as a scaling reference. It illustrates why the median must be checked rather than assumed to be positive.

When the Upper Quartile Can Be Misleading

Worked Example: Highly Expressed Genes Affect the Upper Quartile

In two hypothetical libraries, eight genes have counts \((10,10,10,10,10,100,100,100)\) and \((10,10,10,10,10,200,200,200)\), respectively. Five of the eight genes are stable, while three highly expressed genes double. The totals are 350 and 650, so the geometric mean of the totals is \(\sqrt{350\times650}=476.9696\). The total-count factors are \(350/476.9696=0.7338\) and \(650/476.9696=1.3628\). An unchanged count of 10 becomes \(10/0.7338=13.63\) and \(10/1.3628=7.338\), using the unrounded factors in the divisions.

The median is 10 in both libraries, because the fourth and fifth ordered counts are both 10. It therefore leaves the stable counts unchanged. For the upper quartile, the position is \(1+7(0.75)=6.25\). Both the sixth and seventh counts are 100 in library A, and 200 in library B, so the upper quartiles are 100 and 200. The centered factors are \(0.7071\) and \(1.4142\). An unchanged count of 10 then becomes 14.142 and 7.071. Here three of eight genes (37.5%) are in the highly expressed group, enough for that group to determine the upper quartile. The median better represents the unchanged majority in this constructed example; a different pattern could favor another summary.

Choosing and Checking a Method

A practical choice starts with the shape and composition of the libraries, not a universal ranking. Total-count scaling is a reasonable reference when library composition is broadly similar and no small group of genes dominates the totals. Median scaling can be useful when the central gene-count distribution is positive and most genes provide a stable reference. Upper-quartile scaling is attractive when a few large counts dominate totals but the upper quartile of positive counts remains stable. It is less suitable when highly expressed genes are numerous enough to move that quartile, or when the positive-count distribution differs substantially across samples.

Check the summaries themselves before interpreting scaled values. Record each library's total, median, upper quartile, and fraction of zero counts; inspect whether large totals are driven by a few genes and whether the positive-count distributions have comparable shapes. Factors that differ sharply between methods are a reason to investigate composition and biological design, not a reason to select whichever produces the preferred result. A zero median makes median scaling unavailable; a library with no positive counts also makes upper-quartile scaling unavailable. Differences in detection prevalence can shift the positive-count quartile even without a simple depth difference.

These methods are scalar adjustments: one factor applies to every gene in a library. They cannot correct gene-specific biases or resolve a global biological shift from technical depth using the same count table alone. The earlier material on TMM normalization and median-ratio normalization provides alternatives designed to estimate relative scaling from more selectively chosen gene information. Those alternatives also rely on assumptions about which genes provide a stable reference; they do not remove the need to assess composition and study design.

Common Mistakes

  • Assuming the largest library total means uniformly greater sequencing depth. A few highly expressed genes can increase the total. Check the distribution and contribution of the largest counts.
  • Calling the median zero whenever half the counts are zero. For nonnegative counts, the median is guaranteed to be zero when strictly more than half are zero. With an even number of values and exactly half zero, the median may be positive: for \((0,0,1,1)\), it is \((0+1)/2=0.5\).
  • Treating upper-quartile scaling as immune to highly expressed genes. It is resistant to a few extremes only while those genes do not determine the quartile.
  • Interpreting scaled counts as an absolute measure of RNA per cell. These factors adjust relative library counts; without additional information, they do not identify absolute global RNA changes.
Key takeaway: Total-count, median, and upper-quartile scaling differ in which part of a library's count distribution they treat as a depth reference. Choose only after checking whether that reference is positive and plausibly stable across the libraries being compared.

Check Your Understanding

Answer each question, then compare with the brief solutions.

  1. For counts \((2,2,2,2,200)\), which summary is most directly affected by the extreme count: the total, median, or upper quartile?
  2. For \((0,0,1,1)\), calculate the median and explain why “half the counts are zero” does not imply a zero median.
  3. A library has more than 75% zero counts. Under the upper-quartile convention used here, what issue arises?
  4. In a two-library comparison, the chosen summary doubles from A to B. What factor ratio follows, and what condition makes that a suitable depth adjustment?

Solutions. (1) The total is 208 and includes the full extreme value; the median is 2 and the 75th percentile is also 2 under the stated interpolation convention, so both are unchanged by this one upper extreme. (2) The median is \((0+1)/2=0.5\), since the two middle ordered values are 0 and 1. (3) There may be too few positive counts to define the 75th percentile reliably; if there are no positive counts, it is undefined. (4) Since \(f_B/f_A=S_B/S_A\), the factor ratio is 2. It is suitable when the summary's doubling reflects a twofold technical depth difference rather than a shift in biological composition.

Clinical Biostats