When a study has several samples per donor (two conditions, several tissues, a time course), the samples of a donor are correlated. A fixed effect per donor removes that correlation, but it also absorbs every variable that is constant within a donor, such as disease status or sex, which then cannot be tested. A random intercept per donor models the correlation instead and keeps donor-level variables testable. dream applies this to gene expression Hoffman & Roussos, 2021, and dreamlet to the pseudobulk profiles of every cell type Hoffman et al., 2026.
The model¶
Every gene is fitted with the same model (lme4’s notation (1 | donor); Bates et al. (2015)):
where holds the fixed effects, assigns each sample to a level of the -th
grouping factor (one random intercept per level), and holds the gene’s precision
weights. Grouping factors may be crossed, (1 | donor) + (1 | batch), or nested,
(1 | donor/sample). Random slopes are not implemented yet.
REML¶
fit_mixed_model estimates the variance components by restricted maximum
likelihood Patterson & Thompson, 1971, as lme4’s lmer does, into a MixedModelFit. With
and , the fixed
effects and are profiled out, and the criterion minimized is lme4’s profiled
REML deviance
with . Newton’s method minimizes it
with exact derivatives Harville, 1977; a variance component whose estimate is zero is
held exactly at zero, the boundary that lme4 reports as a singular fit. Random effects
are predicted by their best linear unbiased predictors Henderson, 1975. method="ml"
maximizes the likelihood instead.
Satterthwaite’s degrees of freedom¶
The t-statistic of a contrast of the fixed effects is , with the covariance matrix of the estimates. Its distribution is approximated by a t distribution with Satterthwaite’s degrees of freedom Satterthwaite, 1946Giesbrecht & Burns, 1985,
where holds the derivatives of with respect to the variance parameters and
is their asymptotic covariance matrix. fixed_effect_tests gives them in
FixedEffectTests, computed as lmerTest does Kuznetsova et al., 2017, with exact
derivatives where lmerTest takes numerical ones. With every component at zero,
, the degrees of freedom of the fixed-effects model.
dream¶
dream is limma-voom with the mixed model in place of the linear model:
voom_with_dream_weights: voom’s precision weights, from the mean-variance trend of the mixed model of every gene, fitted by maximum likelihood, read at the fitted values with the predicted random effects.fit_mixed_modelby REML with those weights, andfixed_effect_tests.moderated_fixed_effect_tests: empirical Bayes moderation of each gene’s residual variance on the approximate residual degrees of freedom of the mixed model, for its hat matrix ; the moderated t-statistic has Satterthwaite’s degrees of freedom plus the prior’s, and the result (ModeratedFixedEffectTests) adds a z-statistic with the same p-value, so that tests on different degrees of freedom compare.
dream_voom runs these steps on every cell type of a cube. As variancePartition
does, it moderates the residual variance of an observation of each gene’s average
weight, which keeps the mean-variance trend that voom’s weights remove; trend=True
lets the prior follow it.
Not yet implemented¶
Kenward-Roger’s degrees of freedom (dream’s default for 20 samples or fewer), F-tests of several contrasts at once, random slopes and variance partitioning Hoffman & Schadt, 2016 are planned. A gene that the fixed and random effects reproduce exactly has no REML estimate; it is left unfitted rather than given a variance of zero.
- Hoffman, G. E., & Roussos, P. (2021). Dream: powerful differential expression analysis for repeated measures designs. Bioinformatics, 37(2), 192–201. 10.1093/bioinformatics/btaa687
- Hoffman, G. E., Lee, D., Bendl, J., Prashant, N. M., Hong, A., Casey, C., Alvia, M., Shao, Z., Argyriou, S., Therrien, K., Venkatesh, S., Voloudakis, G., Haroutunian, V., Fullard, J. F., & Roussos, P. (2026). Efficient differential expression analysis of large-scale single-cell transcriptomics data using Dreamlet. Nature Communications, 17(1), 9597. 10.1038/s41467-026-75680-8
- Bates, D., Mächler, M., Bolker, B., & Walker, S. (2015). Fitting linear mixed-effects models using lme4. Journal of Statistical Software, 67(1), 1–48. 10.18637/jss.v067.i01
- Patterson, H. D., & Thompson, R. (1971). Recovery of inter-block information when block sizes are unequal. Biometrika, 58(3), 545–554. 10.1093/biomet/58.3.545
- Harville, D. A. (1977). Maximum likelihood approaches to variance component estimation and to related problems. Journal of the American Statistical Association, 72(358), 320–338. 10.1080/01621459.1977.10480998
- Henderson, C. R. (1975). Best linear unbiased estimation and prediction under a selection model. Biometrics, 31(2), 423–447. 10.2307/2529430
- Satterthwaite, F. E. (1946). An approximate distribution of estimates of variance components. Biometrics Bulletin, 2(6), 110–114. 10.2307/3002019
- Giesbrecht, F. G., & Burns, J. C. (1985). Two-stage analysis based on a mixed model: large-sample asymptotic theory and small-sample simulation results. Biometrics, 41(2), 477–486. 10.2307/2530872
- Kuznetsova, A., Brockhoff, P. B., & Christensen, R. H. B. (2017). lmerTest package: tests in linear mixed effects models. Journal of Statistical Software, 82(13), 1–26. 10.18637/jss.v082.i13
- Hoffman, G. E., & Schadt, E. E. (2016). variancePartition: interpreting drivers of variation in complex gene expression studies. BMC Bioinformatics, 17(1), 483. 10.1186/s12859-016-1323-z