Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Empirical Bayes moderation and TREAT

With a few samples, each gene’s residual variance sg2s_g^2 is a poor estimate: some genes look precise by chance and give large t-statistics. Empirical Bayes moderation borrows strength from all genes by shrinking each variance towards a common value Smyth, 2004. Every test of a linear model in CytePool moderates this way: moderated_statistics and treat on a fit, and the differential-expression, gene-set and composition functions inside.

The model

The residual variance of gene gg on dgd_g degrees of freedom, and the true variance σg2\sigma_g^2, follow

sg2∣σg2∼σg2 χdg2dg,1σg2∼χd02d0s02,s_g^2 \mid \sigma_g^2 \sim \frac{\sigma_g^2\, \chi^2_{d_g}}{d_g}, \qquad \frac{1}{\sigma_g^2} \sim \frac{\chi^2_{d_0}}{d_0 s_0^2},

so that sg2s_g^2 follows s02s_0^2 times an F(dg,d0)F(d_g, d_0) distribution. The prior (s02,d0)(s_0^2, d_0) is estimated from all genes, and each variance is replaced by its posterior value

s~g2=d0s02+dgsg2d0+dg.\tilde s_g^2 = \frac{d_0 s_0^2 + d_g s_g^2}{d_0 + d_g}.

The moderated t-statistic tg=β^g/(ugs~g)t_g = \hat\beta_g / (u_g \tilde s_g), with ugu_g the unscaled standard error of the coefficient or contrast, follows a t distribution on d0+dgd_0 + d_g degrees of freedom when the coefficient is zero; its two-sided p-value comes from the tail of that distribution (t_sf), on fractional degrees of freedom too. Large d0d_0 means the genes have similar variances and the prior counts for much; d0=0d_0 = 0 is the ordinary t-test. moderated_statistics returns them in a ModeratedFit, and squeeze_variances applies the same moderation to any set of variances (SqueezedVariances).

Estimating the prior

By default the likelihood estimator is used when the positive degrees of freedom differ between genes and the method of moments otherwise, as in limma since version 3.61.8 (legacy = NULL).

Moderated F and the B-statistic

The moderated F-statistic tests that all coefficients of a gene are zero: F=t′R+t/rF = t' R^{+} t / r, with RR the correlation matrix of the coefficients and rr its rank. CytePool uses each gene’s own correlation matrix when the fit has one (missing values or observation weights), which is the correct F-statistic [Smyth (2004), section 7]; limma uses the correlation of the unweighted design for every gene.

The B-statistic is the log-odds that a coefficient is non-zero Lönnstedt & Speed, 2002, in the form of Smyth (2004):

B=log⁡p1−p+12log⁡r+1+d2log⁡t2+dt2r+d,B = \log\frac{p}{1 - p} + \frac{1}{2}\log r + \frac{1 + d}{2}\log\frac{t^2 + d}{t^2 r + d},

with pp the assumed proportion of non-zero coefficients (0.01 by default), d=d0+dgd = d_0 + d_g, r=v/(v+v0)r = v / (v + v_0), vv the squared unscaled standard error and v0v_0 the prior variance of non-zero coefficients, estimated from the largest t-statistics. When every gene has the same degrees of freedom and unscaled standard error, as in a fit without weights or missing values, B orders the genes as ∣t∣|t| does.

Testing against a fold-change threshold

A small p-value says a fold change is not zero, not that it is large. TREAT tests H0:∣β∣≤τH_0: |\beta| \le \tau against ∣β∣>τ|\beta| > \tau McCarthy & Smyth, 2009. With the moderated t-statistic tt, its standard error se\mathrm{se} and δ=τ/se\delta = \tau / \mathrm{se}, the p-value is the worst case over the null interval,

p=P(T>∣t∣−δ)+P(T>∣t∣+δ),p = P(T > |t| - \delta) + P(T > |t| + \delta),

with TT on d0+dgd_0 + d_g degrees of freedom. treat returns a TreatFit and takes the threshold as a log2 fold change (lfc) or a fold change (fc, 1.2 by default, as in limma). Filtering significant genes by their estimated fold change does not test the threshold; TREAT does, and McCarthy & Smyth (2009) found that it improves on the false discovery rate of existing methods when the size of the change is taken into account.

References
  1. Smyth, G. K. (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. Statistical Applications in Genetics and Molecular Biology, 3(1), Article 3. 10.2202/1544-6115.1027
  2. Phipson, B., Lee, S., Majewski, I. J., Alexander, W. S., & Smyth, G. K. (2016). Robust hyperparameter estimation protects against hypervariable genes and improves power to detect differential expression. The Annals of Applied Statistics, 10(2), 946–963. 10.1214/16-AOAS920
  3. Chen, Y., Chen, L., Lun, A. T. L., Baldoni, P. L., & Smyth, G. K. (2025). edgeR v4: powerful differential analysis of sequencing data with expanded functionality and improved support for small counts and larger datasets. Nucleic Acids Research, 53(2), gkaf018. 10.1093/nar/gkaf018
  4. Lönnstedt, I., & Speed, T. P. (2002). Replicated microarray data. Statistica Sinica, 12(1), 31–46.
  5. McCarthy, D. J., & Smyth, G. K. (2009). Testing significance relative to a fold-change threshold is a TREAT. Bioinformatics, 25(6), 765–771. 10.1093/bioinformatics/btp053