Why TMM Uses More Than Total Counts
A library with more recorded counts does not necessarily contain proportionally more information about every gene. If a small number of genes account for a large share of one library, the proportions of many other genes can be pushed downward even when their underlying expression has not changed. Total-count scaling treats that compositional shift as if it were a uniform difference in depth.
The trimmed mean of M-values method, usually called TMM, estimates a relative scaling factor by comparing gene-wise proportions between a sample and a reference library. It excludes extreme log-ratios and extreme abundances, then averages the remaining log-ratios with greater weight given to estimates that are more precise. Its central assumption is that, after accounting for library size, most genes provide a reasonably stable comparison or that increases and decreases are sufficiently balanced.
The \(M\)-value measures a difference in relative abundance: \(M_{ij}=0\) means the gene has the same fraction of the two libraries, while a positive value means its fraction is larger in sample \(j\). The \(A\)-value describes the average relative abundance of the gene across the pair. Both are on a base-2 logarithmic scale. TMM ordinarily compares only genes with positive counts in both libraries; the earlier material on handling zeros in median-ratio estimation discusses why zero-containing ratios need special treatment.
Reference Selection, Trimming, and Weighting
TMM is a pairwise calculation, so one library serves as the reference for each comparison. The reference should be reasonably representative rather than unusually compositionally skewed. In common implementations, a reference is selected using the library whose upper-quartile count is closest to the mean upper-quartile count across libraries. This is a practical selection rule, not a guarantee that the chosen library is biologically unchanged. Using a different reasonable reference can change intermediate pairwise factors; after the factors are centered, results are often similar when the comparison is well behaved.
Before averaging, TMM trims the gene-wise values. It removes genes with extreme \(M\)-values, which could reflect strong differential expression or unusual count behavior, and also trims by \(A\)-value, which limits the influence of very low- and very high-abundance genes. A commonly used setting trims 30% from each tail of the \(M\)-value distribution and 5% from each tail of the \(A\)-value distribution. These percentages describe the tails removed, not the fraction retained. Exact settings are implementation choices and should be reported when they matter.
Among the retained genes, TMM uses approximate inverse-variance weights. Under a binomial sampling approximation for each library’s gene proportion, the variance of a proportion is approximately \(p(1-p)/N\). Substituting the observed proportion \(Y/N\) gives a variance contribution of approximately \((N-Y)/(NY)\). The two-library contributions add for a log-ratio, giving the standard TMM weight:
Larger weights therefore generally go to ratios supported by more counts, which tend to be more precise. This is an approximation, not a full model of all biological or technical variation. Trimming and weighting address different concerns: trimming reduces the influence of extreme ratios or abundances, while weighting gives retained ratios different influence according to their estimated sampling precision.
From Weighted Log-Ratios to a Size Factor
Let \(R_j\) be the genes that remain after positive-count filtering and the chosen \(M\)- and \(A\)-value trimming. TMM estimates the central log-ratio as the weighted mean of the retained \(M\)-values. The factor is then obtained by converting back from the log base 2 scale.
The weighted-mean formula follows directly from a weighted least-squares criterion. If a common log-ratio \(\theta\) is used to summarize the retained genes, choose it to minimize the weighted squared deviations. Differentiating that criterion and setting the derivative to zero gives the formula:
A positive estimated mean gives a factor above 1; a negative mean gives a factor below 1. Since factors are relative, implementations commonly center them so their geometric mean is 1. If \(f_j^{\mathrm{raw}}\) are the raw factors, this rescaling is
The effective library size \(N_j^{\mathrm{eff}}\) is the library-size exposure after TMM scaling. It can be used in downstream normalization or as an offset in an appropriate count model. A factor below 1 reduces the effective library size and, for a fixed count, corresponds to a larger normalized value than using the raw library size alone. Centering changes the common scale of the factors but preserves their relative values.
Worked Example: A Gene-Wise Log-Ratio and Its Weight
Suppose a hypothetical sample has \(N_j=2{,}000\) counts and a reference has \(N_r=1{,}000\). For one gene, the counts are \(Y_{ij}=300\) and \(Y_{ir}=100\). Both counts are positive, so this gene can enter the pairwise calculation, subject to trimming.
The two observed proportions are \(300/2{,}000=0.15\) and \(100/1{,}000=0.10\). Thus $$ M_{ij}=\log_2(0.15/0.10)=\log_2(1.5)\approx 0.5850. $$ The gene’s fraction is 1.5 times as large in the sample as in the reference. Its average abundance is $$ A_{ij}=\tfrac12\log_2(0.15\times0.10) =\tfrac12\log_2(0.015)\approx -3.029. $$
The approximate variance contributions are $$ \frac{2{,}000-300}{2{,}000(300)}=0.002833, \qquad \frac{1{,}000-100}{1{,}000(100)}=0.009000. $$ Therefore \(w_{ij}=1/(0.002833+0.009000)\approx84.51\). This weight describes the gene’s approximate precision in the pairwise comparison; by itself, it does not determine the sample’s TMM factor.
Worked Example: Combining Retained Ratios With Their Weights
Suppose a hypothetical pairwise comparison has two genes left after filtering and trimming. Their \(M\)-values and weights, calculated from the count proportions and library sizes, are as follows.
| Retained gene | \(M_{ij}\) | \(w_{ij}\) |
|---|---|---|
| Gene 1 | 0.5850 | 75.85 |
| Gene 2 | -0.4150 | 122.2 |
The weighted mean is $$ \widehat{M}_{TMM} = \frac{75.85(0.5850)+122.2(-0.4150)}{75.85+122.2} = \frac{44.37225-50.713}{198.05} \approx -0.03202. $$ The corresponding raw factor is \(2^{-0.03202}\approx0.9781\). The negative estimate means the weighted center of the retained sample-to-reference proportions is slightly below zero on the log-ratio scale. The result is not the simple average of the two \(M\)-values: the second gene has greater weight and pulls the estimate downward.
Worked Example: Centering Factors and Computing Effective Library Sizes
Suppose three hypothetical libraries have raw relative factors \(1.00\), \(0.80\), and \(1.20\), with library sizes \(10{,}000\), \(8{,}000\), and \(12{,}000\) counts. The geometric mean of the raw factors is $$ g=(1.00\times0.80\times1.20)^{1/3}=0.96^{1/3}\approx0.9865. $$ Dividing each raw factor by \(g\) gives centered factors of approximately \(1.0137\), \(0.8110\), and \(1.2164\). Their product is approximately 1, as required by geometric-mean centering.
The effective library sizes are \(10{,}000(1.0137)=10{,}137\), \(8{,}000(0.8110)=6{,}488\), and \(12{,}000(1.2164)=14{,}597\) counts, to the nearest count. These exposures incorporate both the recorded library sizes and the relative TMM adjustments. They are not new observed counts.
Diagnostics, Alternatives, and Limitations
A TMM estimate can become unstable when the pairwise comparison is supported by very few genes. Sparse single-cell libraries often have many zero counts, so the number of genes positive in both libraries may be small, especially for low-depth cells. Check how many genes remain after positive-count filtering and how many survive trimming. Also inspect whether the retained ratios cover a useful abundance range and whether a small number of large weights dominates the weighted mean. Such checks identify warning signs; they do not establish that the normalization assumption is biologically correct.
TMM and median-ratio normalization both estimate relative scaling using genes rather than assuming that all counts should be scaled solely by the total. Median-ratio normalization uses ratios to geometric-mean references and a median across genes; TMM uses a selected library reference, trims in both log-ratio and abundance space, and weights retained ratios. Total-count scaling is simpler and uses each library’s total directly, but can be distorted when a few genes dominate the composition. No endogenous factor method can, from the count matrix alone, distinguish a global change in RNA content per cell from a change in sequencing depth without further assumptions or external information.
Select a reasonably representative library using a stated rule, such as closeness of its upper quartile to the mean upper quartile.
For positive counts in both libraries, calculate each gene’s \(M\)-value, \(A\)-value, and approximate inverse-variance weight.
Remove genes that fail the positive-count requirement, then exclude extreme log-ratios and abundances according to the selected trimming settings.
Compute the weighted mean retained log-ratio, exponentiate base 2 to obtain a raw factor, and center factors to geometric mean 1.
Check Your Understanding
Answer each question, then compare with the solutions below.
- If a gene has the same proportion in a sample and its reference, what is its \(M\)-value?
- A retained gene has \(M=0.3219\). What is its gene-wise sample-to-reference proportion ratio?
- Why does TMM trim \(A\)-values as well as \(M\)-values?
- If a centered TMM factor is \(0.90\), what is the effective library size for a library of 20,000 counts?
- Name one condition that can make a cell-level TMM comparison unreliable.
Solutions. (1) \(M=\log_2(1)=0\). (2) The ratio is \(2^{0.3219}\approx1.25\), so the gene’s fraction is about 1.25 times as large in the sample. (3) Abundance trimming limits the influence of genes at the very low or high ends of the average-abundance range; it complements, rather than replaces, log-ratio trimming. (4) \(20{,}000(0.90)=18{,}000\) counts. (5) For example, very few genes may be positive in both libraries after filtering, leaving too little information for a stable trimmed comparison.