Here we perform analysis of PBMCs from 8 individuals stimulated with
interferon-β Kang, et
al, 2018, Nature Biotech. We perform standard processing with dreamlet
to compute pseudobulk before applying crumblr.
Here, single cell RNA-seq data is downloaded from ExperimentHub.
library(dreamlet)
library(muscat)
library(ExperimentHub)
library(scater)
# Download data, specifying EH2259 for the Kang, et al. study
eh <- ExperimentHub()sce$ind <- as.character(sce$ind)
# only keep singlet cells with sufficient reads
sce <- sce[rowSums(counts(sce) > 0) > 0, ]
sce <- sce[, colData(sce)$multiplets == "singlet"]
# compute QC metrics
qc <- perCellQCMetrics(sce)
# remove cells with few or many detected genes
ol <- isOutlier(metric = qc$detected, nmads = 2, log = TRUE)
sce <- sce[, !ol]
# set variable indicating stimulated (stim) or control (ctrl)
sce$StimStatus <- sce$stimDreamlet creates the pseudobulk dataset:
# Since 'ind' is the individual and 'StimStatus' is the stimulus status,
# create unique identifier for each sample
sce$id <- paste0(sce$StimStatus, sce$ind)
# Create pseudobulk data by specifying cluster_id and sample_id for aggregating cells
pb <- aggregateToPseudoBulk(sce,
assay = "counts",
cluster_id = "cell",
sample_id = "id",
verbose = FALSE
)Here we evaluate whether the observed cell proportions change in response to interferon-β.
## B cells CD14+ Monocytes CD4 T cells
## ctrl101 101 136 288
## ctrl1015 424 644 819
## ctrl1016 119 315 413
Now continue on with the downstream analysis
library(variancePartition)
fit <- dream(cobj, ~ StimStatus + ind, colData(pb))
fit <- eBayes(fit)
topTable(fit, coef = "StimStatusstim", number = Inf)## logFC AveExpr t P.Value adj.P.Val B
## CD8 T cells -0.25085170 0.0857175 -4.0787416 0.002436375 0.01949100 -1.279815
## Dendritic cells 0.37386979 -2.1849234 3.1619195 0.010692544 0.02738587 -2.638507
## CD14+ Monocytes -0.10525402 1.2698117 -3.1226341 0.011413912 0.02738587 -2.709377
## B cells -0.10478652 0.5516882 -3.0134349 0.013692935 0.02738587 -2.940542
## CD4 T cells -0.07840101 2.0201947 -2.2318104 0.050869691 0.08139151 -4.128069
## FCGR3A+ Monocytes 0.07425165 -0.2567492 1.6647681 0.128337022 0.17111603 -4.935304
## NK cells 0.10270672 0.3797777 1.5181860 0.161321761 0.18436773 -5.247806
## Megakaryocytes 0.01377768 -1.8655172 0.1555131 0.879651456 0.87965146 -6.198336
Given the results here, we see that CD8 T cells at others change relative abundance following treatment with interferon-β.
ere we construct a hierarchical clustering between cell types based
on gene expression from pseudobulk, and perform a multivariate test for
each internal node of the tree based on its leaf nodes. The results for
the leaves are the same as from topTable() above.
# hierarchical cluster based on pseudobulked gene expression
hcl <- buildClusterTreeFromPB(pb)
# Perform multivariate test across the hierarchy
res <- treeTest(fit, cobj, hcl, coef = "StimStatusstim")
# Plot hierarchy and testing results
plotTreeTest(res)## R version 4.6.1 (2026-06-24)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
## [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
## [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats4 parallel stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] scater_1.41.2 scuttle_1.23.2 ExperimentHub_3.3.2
## [4] AnnotationHub_4.3.2 BiocFileCache_3.3.0 dbplyr_2.6.0
## [7] muscat_1.27.4 dreamlet_1.11.0 SingleCellExperiment_1.35.2
## [10] SummarizedExperiment_1.43.0 Biobase_2.73.2 GenomicRanges_1.65.4
## [13] Seqinfo_1.3.2 IRanges_2.47.5 S4Vectors_0.51.10
## [16] BiocGenerics_0.59.12 generics_0.1.4 MatrixGenerics_1.25.0
## [19] matrixStats_1.5.0 variancePartition_1.43.1 BiocParallel_1.47.0
## [22] limma_3.99.0 lubridate_1.9.5 forcats_1.0.1
## [25] stringr_1.6.0 dplyr_1.2.1 purrr_1.2.2
## [28] readr_2.2.0 tidyr_1.3.2 tibble_3.3.1
## [31] tidyverse_2.0.0 glue_1.8.1 crumblr_1.5.3
## [34] ggplot2_4.0.3 BiocStyle_2.41.0
##
## loaded via a namespace (and not attached):
## [1] fs_2.1.0 bitops_1.1-0 httr_1.4.9
## [4] RColorBrewer_1.1-3 doParallel_1.0.17 Rgraphviz_2.57.2
## [7] numDeriv_2016.8-1.1 tools_4.6.1 backports_1.5.1
## [10] R6_2.6.1 metafor_5.2-1 mgcv_1.9-4
## [13] lazyeval_0.2.3 GetoptLong_1.1.1 withr_3.0.3
## [16] prettyunits_1.2.0 gridExtra_2.3.1 cli_3.6.6
## [19] sandwich_3.1-3 labeling_0.4.3 sass_0.4.10
## [22] KEGGgraph_1.73.0 SQUAREM_2026.1 mvtnorm_1.4-2
## [25] S7_0.2.2 blme_1.0-8 mixsqp_0.3-54
## [28] systemfonts_1.3.2 yulab.utils_0.2.5 zenith_1.15.0
## [31] invgamma_1.2 RSQLite_3.53.3 shape_1.4.6.1
## [34] gridGraphics_0.5-1 gtools_3.9.5 scrapper_1.7.9
## [37] Matrix_1.7-6 metadat_1.6-0 ggbeeswarm_0.7.3
## [40] abind_1.4-8 lifecycle_1.0.5 yaml_2.3.12
## [43] edgeR_4.99.6 mathjaxr_2.0-0 gplots_3.3.0
## [46] SparseArray_1.13.4 grid_4.6.1 blob_1.3.0
## [49] crayon_1.5.3 lattice_0.23-1 beachmat_2.29.3
## [52] msigdbr_26.1.1 annotate_1.91.0 KEGGREST_1.53.6
## [55] sys_3.4.3 maketools_1.3.2 pillar_1.11.1
## [58] knitr_1.52 ComplexHeatmap_2.29.0 rjson_0.2.23
## [61] boot_1.3-32 corpcor_1.6.10 codetools_0.2-20
## [64] ggiraph_0.9.6 ggfun_0.2.2 fontLiberation_0.1.0
## [67] data.table_1.18.6.1 vctrs_0.7.3 png_0.1-9
## [70] treeio_1.37.1 Rdpack_2.6.6 gtable_0.3.6
## [73] assertthat_0.2.1 cachem_1.1.0 zigg_0.0.2
## [76] xfun_0.61 rbibutils_2.4.1 S4Arrays_1.13.2
## [79] Rfast_2.1.5.2 reformulas_0.4.4 iterators_1.0.14
## [82] statmod_1.5.2 dirmult_0.1.3-5 nlme_3.1-171
## [85] pbkrtest_0.5.5 ggtree_4.3.0 bit64_4.8.6
## [88] fontquiver_0.2.1 filelock_1.0.3 progress_1.2.3
## [91] EnvStats_3.1.0 TMB_1.9.25 bslib_0.12.0
## [94] irlba_2.4.1 vipor_0.4.7 KernSmooth_2.23-27
## [97] otel_0.2.0 colorspace_2.1-4 rmeta_3.0
## [100] DBI_1.3.0 tidyselect_1.2.1 curl_8.0.0
## [103] bit_4.6.0 compiler_4.6.1 httr2_1.3.0
## [106] graph_1.91.0 BiocNeighbors_2.7.3 fontBitstreamVera_0.1.1
## [109] DelayedArray_0.39.8 scales_1.4.0 caTools_1.18.4
## [112] remaCor_0.0.20 rappdirs_0.3.4 digest_0.6.39
## [115] minqa_1.2.8 rmarkdown_2.32 aod_1.3.3
## [118] XVector_0.53.0 RhpcBLASctl_0.23-42 htmltools_0.5.9
## [121] pkgconfig_2.0.3 lme4_2.0-6 sparseMatrixStats_1.25.0
## [124] mashr_0.2.79 fastmap_1.2.0 rlang_1.3.0
## [127] GlobalOptions_0.1.4 htmlwidgets_1.6.4 DelayedMatrixStats_1.35.0
## [130] farver_2.1.2 jquerylib_0.1.4 zoo_1.9-1
## [133] jsonlite_2.0.0 BiocSingular_1.29.2 RCurl_1.98-1.20
## [136] magrittr_2.0.5 ggplotify_0.1.3 patchwork_1.3.2
## [139] Rcpp_1.1.2 ape_5.8-1 viridis_0.6.5
## [142] gdtools_0.5.1 EnrichmentBrowser_2.43.0 stringi_1.8.9
## [145] MASS_7.3-66 plyr_1.8.9 ggrepel_0.9.8
## [148] Biostrings_2.81.9 splines_4.6.1 circlize_0.4.18
## [151] hms_1.1.4 locfit_1.5-9.12 RTMB_2.0
## [154] buildtools_1.0.0 ScaledMatrix_1.21.0 reshape2_1.4.5
## [157] BiocVersion_3.24.0 XML_3.99-0.25 evaluate_1.0.5
## [160] RcppParallel_6.2.1 BiocManager_1.30.27 nloptr_2.2.1
## [163] tzdb_0.5.0 foreach_1.5.2 clue_0.3-68
## [166] scattermore_1.2 ashr_2.2-63 BiocBaseUtils_1.15.1
## [169] rsvd_1.0.5 broom_1.0.13 xtable_1.8-8
## [172] fANCOVA_0.6-1 tidytree_0.4.8 viridisLite_0.4.3
## [175] truncnorm_1.0-9 glmmTMB_1.1.15.2 lmerTest_3.2-1
## [178] aplot_0.3.2 memoise_2.0.1 beeswarm_0.4.0
## [181] AnnotationDbi_1.75.2 cluster_2.1.8.3 timechange_0.4.0
## [184] GSEABase_1.75.0