Tutorials › Multi-Omics Data Integration › Library-Size Normalization for Sequencing Counts

Preprocessing, Scaling and Block Weighting · Tutorial 32 of 597

Library-Size Normalization for Sequencing Counts

You will calculate library-size offsets and composition-aware size factors, assess their assumptions, and distinguish normalization from transforming the resulting measurements.

Intermediate 11 min read

What You'll Learn

  • Explain why raw sequencing counts can differ because of library depth as well as relative feature abundance.
  • Calculate counts per million and use a library-size offset in a count model.
  • Derive median-of-ratios size factors from a small count matrix.
  • Work through a trimmed mean of M-values (TMM) normalization example.
  • Diagnose composition bias and recognize when size-factor assumptions may fail.
  • Distinguish normalization from transformations such as taking logarithms.

Why Sequencing Counts Need Normalization

A sequencing count is affected both by how abundant a feature is in a sample and by how many reads were obtained for that sample. If one library has twice as many reads as another, many features may have roughly twice the observed counts even when their relative abundances are similar. Comparing the raw counts directly would then confound sequencing depth with the feature-level differences of interest.

Library-size normalization adjusts for differences in the scale of sequencing counts. A simple adjustment uses each sample's total count. But total counts can themselves be distorted by a few highly abundant features, so composition-aware methods estimate a scaling factor from many features. The resulting factors are commonly used as offsets in count models or as denominators when calculating normalized counts.

Definition: Let \(Y_{ij}\) be the observed count for feature \(i\) in sample \(j\), and let \(N_j=\sum_i Y_{ij}\) be the total count across the features included in the count matrix for that sample. A size factor \(f_j\) is a positive sample-specific scaling factor. The effective library size is \(E_j=N_j f_j\). A normalized count is \(Y_{ij}/E_j\), often multiplied by a fixed constant for display. In a count model, \(\log(E_j)\) can be used as an offset: a known term with coefficient fixed at 1.

Simple Total-Count Scaling and Its Limits

Counts per million (CPM) divides each count by its sample total and multiplies by one million:

$$ \operatorname{CPM}_{ij}=\frac{Y_{ij}}{N_j}\times 10^6. $$

This makes the total count scale comparable across samples. It is useful for descriptive summaries, but it assumes total counts are an adequate measure of the relevant sequencing scale. If one or a few features take up a much larger share of reads in a sample, the remaining features can appear artificially reduced as proportions of that total. This is a composition effect: a change in the share taken by some features changes the shares available to others, even if their underlying abundances did not change.

Worked Example: CPM and a Library-Size Offset

Suppose a hypothetical feature has 50 reads in a sample with \(N_1=10{,}000\), and 80 reads in a second sample with \(N_2=20{,}000\). Calculate the CPM values and compare them with the raw counts.

For sample 1,

$$ \operatorname{CPM}_{i1}=\frac{50}{10{,}000}\times10^6=5{,}000. $$

For sample 2,

$$ \operatorname{CPM}_{i2}=\frac{80}{20{,}000}\times10^6=4{,}000. $$

The raw count is higher in sample 2, but its library is twice as large; after total-count scaling, the feature has lower relative abundance in sample 2. For a Poisson or negative-binomial count model with mean \(\mu_{ij}\), a basic depth-adjusted mean specification is

$$ \log(\mu_{ij})=\log(N_j)+\beta_{ij}, $$

where \(\log(N_j)\) is an offset and \(\beta_{ij}\) represents the modeled log rate for the feature. This specification assumes total library size captures the relevant scale difference. The CPM comparison is descriptive; it does not by itself establish a statistical difference between samples.

Composition-Aware Size Factors

Composition-aware methods seek a scaling factor that is less sensitive to a small set of unusually abundant features. Their central working assumption is that a sufficiently large, representative set of features is not changing in a coordinated way between samples, or that increases and decreases among changing features are balanced enough for a stable reference to be estimated. Factors are relative: multiplying every factor by the same positive constant does not change comparisons among samples. Implementations therefore commonly center factors, for example so their geometric mean is 1.

Definition: The median-of-ratios method first computes, for each feature with positive counts in every included sample, its geometric mean across samples. It divides each sample's count for that feature by the feature's geometric mean, then takes the median of those ratios for each sample. The resulting sample-specific medians are size factors; they are commonly rescaled to have geometric mean 1.

The median limits the influence of a minority of features with very large or very small ratios. The method's standard geometric-mean calculation requires positive counts for the features used. Features with a zero in any sample have a zero geometric mean and cannot contribute to that calculation; sparse data may require a suitable implementation or alternative estimator rather than treating undefined ratios as ordinary values.

Worked Example: Median-of-Ratios Factors

Consider these hypothetical counts for three features across three samples:

FeatureSample 1Sample 2Sample 3
1102040
2204080
3303060

The geometric means are 20 for feature 1, 40 for feature 2, and \(\sqrt[3]{30(30)(60)}\approx37.80\) for feature 3. Thus the ratios for sample 1 are \(10/20=0.5\), \(20/40=0.5\), and \(30/37.80\approx0.7937\). Their median is \(f_1=0.5\).

For sample 2, the ratios are \(20/20=1\), \(40/40=1\), and \(30/37.80\approx0.7937\), with median \(f_2=1\). For sample 3, they are \(40/20=2\), \(80/40=2\), and \(60/37.80\approx1.587\), with median \(f_3=2\). Since the geometric mean of \(0.5,1,2\) is 1, these factors are already centered. Sample 3's effective library size is \(N_3f_3=180(2)=360\) counts. These factors estimate relative scaling from the features collectively; they are not estimates of absolute molecule counts.

TMM: Trimming Extreme Composition Ratios

The trimmed mean of M-values (TMM) is another composition-aware approach. It compares a sample with a reference sample. For feature \(i\), the log ratio \(M_i\) measures the difference between the feature's proportions in the two libraries. TMM trims features with extreme log ratios and, in common implementations, also trims on average abundance; it then takes a precision-weighted mean of the retained log ratios. The exponentiated result gives a relative scaling factor. The specific trimming and weighting details depend on the implementation.

For a sample \(j\) and reference \(r\), the log ratio and a commonly used approximate inverse-variance weight are

$$ M_i=\log_2\left(\frac{Y_{ij}/N_j}{Y_{ir}/N_r}\right), \qquad w_i=\left(\frac{1}{Y_{ij}}-\frac{1}{N_j}+\frac{1}{Y_{ir}}-\frac{1}{N_r}\right)^{-1}. $$

After trimming, the weighted mean is \(\bar M_w=\sum_i w_iM_i/\sum_i w_i\), and the sample's relative TMM factor against that reference is \(2^{\bar M_w}\). Factors are then centered across samples. The calculation relies on enough retained features to provide a stable reference; it cannot fix a dataset in which most features shift in the same direction for biological reasons.

Worked Example: TMM Under a Dominant-Feature Shift

Suppose a hypothetical reference library has counts \((100,200,300,400,500)\), with total \(N_r=1{,}500\). A second library has counts \((100,200,300,400,2{,}500)\), with total \(N_j=3{,}500\). The last feature is much more abundant in the second sample. For each of features 1–4, the ratio of sample proportion to reference proportion is \((3/7)\), so

$$ M_i=\log_2(3/7)\approx-1.2224. $$

For feature 5, the proportion ratio is \((2{,}500/3{,}500)/(500/1{,}500)=15/7\), giving \(M_5=\log_2(15/7)\approx1.0995\). As an intentionally small illustration of trimming, suppose the trimming rule retains features 2–4 and removes the extreme-abundance features 1 and 5. The retained log ratios are all \(-1.2224\), so their precision-weighted mean is also \(-1.2224\), regardless of the positive weights. For example, the weights for features 2, 3, and 4 from the displayed formula are approximately 110.5, 175.0, and 247.1.

The uncentered factor for the second library relative to the reference is

$$ 2^{-1.2224}\approx\frac{3}{7}=0.4286. $$

Centering the two factors to have geometric mean 1 gives \(f_r=\sqrt{7/3}\approx1.5275\) and \(f_j=\sqrt{3/7}\approx0.6547\). The effective library sizes are \(1{,}500\sqrt{7/3}\approx2{,}291\) and \(3{,}500(0.6547)\approx2{,}291\) counts. Thus a feature with count 100 in each library has equal normalized counts, \(100/2{,}291\), under this adjustment. This toy calculation demonstrates the trimming logic; actual analyses should use a validated implementation and its specified trimming rules.

Offsets, Normalized Counts, and Transformations

Normalization and transformation answer different questions. Normalization changes the scale used to account for sample-specific sequencing depth or composition. A count model can retain the integer counts \(Y_{ij}\) and include \(\log(E_j)\) as an offset, for example \(\log(\mu_{ij})=\log(E_j)+\beta_{ij}\). For plots or some downstream procedures, analysts may instead calculate normalized counts \(Y_{ij}/E_j\), often multiplied by a constant such as one million.

A transformation changes the numerical representation of the data, for example by taking a logarithm of normalized measurements. Transformations can alter skewness and the relationship between mean and variance; they do not estimate or replace library-size factors. In particular, taking a logarithm of raw counts does not by itself correct unequal sequencing depth. Conversely, applying a size factor does not make count data normally distributed or remove all mean-dependent variability.

Assumptions, Diagnostics, and Failure Modes

Before using a size-factor method, check that the count matrix represents comparable features and that differences in sequencing depth are a plausible source of scale variation. The method also needs a defensible reference: typically, most features are stable or changes are sufficiently balanced that a robust center represents the technical scale. These assumptions are not guaranteed merely because an algorithm returns factors.

  • Inspect estimated factors. Extremely large or small factors relative to library totals can signal a strong composition shift, an unusual sample, or a mismatch between the data and the estimator's assumptions.
  • Compare factors with total counts. A marked discrepancy can be reasonable when a few features dominate, but it merits investigation rather than automatic acceptance.
  • Inspect normalized values and sample profiles. Look for samples still dominated by a small number of features, systematic sample-wide shifts, or other patterns suggesting that a single scalar factor is inadequate.
  • Check zero patterns and filtering choices. Geometric-mean ratios require usable positive counts for the contributing features. Changing which features enter the estimate can change the factors, particularly in sparse data.
  • Investigate global biological shifts. If most features truly increase or decrease together, a method that assumes a stable majority can interpret that biology as a scale difference and remove it.

Total-count scaling is simple and transparent, but sensitive to dominant features. Median-of-ratios uses a robust median of feature-wise ratios and is convenient when enough features have suitable positive counts. TMM uses trimming and precision weights and can be useful when composition differences make total-count scaling misleading. Neither composition-aware method provides absolute abundance without additional information, such as an external reference or measured input scale. The choice should reflect the experimental design, the count matrix, and the biological question.

Common Mistake

Common pitfall: “Sample 2 has twice the total reads, so every feature must have twice the abundance; dividing by the total solves the problem.” The correction is that total reads are a scale measure, not a guarantee of equal composition or absolute abundance. A few dominant features can distort total-count scaling, and a global biological change can violate the stable-reference assumptions of composition-aware factors. Inspect the data and state what kind of abundance comparison the normalization supports.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. A feature has 120 reads in a library of 30,000 reads. What is its CPM?
  2. In a median-of-ratios calculation, the feature-wise ratios for one sample are 0.8, 1.0, 1.1, 1.2, and 5.0. What is the uncentered size factor, and why is the largest ratio not decisive?
  3. What does \(\log(E_j)\) do when included as an offset in a count model?
  4. Why might total-count scaling be misleading when a small number of features dominate one sample?
  5. Does dividing counts by size factors transform the data to a normal distribution? Explain.

Solutions. (1) \((120/30{,}000)\times10^6=4{,}000\) CPM. (2) The median is 1.1; the single ratio of 5.0 does not determine the median because the median is resistant to a minority of extreme values. (3) It adjusts the modeled mean for the sample's effective library size, with its coefficient fixed at 1. (4) Dominant features can take a disproportionate share of reads, making the total a distorted reference for the remaining features. (5) No. Dividing by size factors adjusts scale; it is not a distributional transformation and does not guarantee normality.

Clinical Biostats