#

How to use DeeDeeExperiment with single-cell data

Najla Abassi1*, Lea Schwarz1** and Federico Marini1,2***

1Institute of Medical Biostatistics, Epidemiology and Informatics (IMBEI), Mainz
2Research Center for Immunotherapy (FZI), Mainz

*abassina@uni-mainz.de
**lea.schwarz@uni-mainz.de
***marinif@uni-mainz.de

#### 20 March 2026

#### Package

DeeDeeExperiment 1.1.4

# 1 Differential State (DS) analysis with `muscat` & `DeeDeeExperiment`

## 1.1 `DeeDeeExperiment` on the `Kang` dataset

In this vignette, we illustrate how to integrate Differential Expression Analysis (DEA) results generated with the muscat framework into a DeeDeeExperiment object. As an example, we use a publicly available dataset from Kang, et al. “Multiplexed droplet single-cell RNA-sequencing using natural genetic variation”, published in Nature Biotechnology, December 2017 Kang et al. (2017)

The data is made available via the ExperimentHub Bioconductor package as a SingleCellExperiment object containing scRNA-seq data from PBMCs obtained from 8 lupus patients before and after IFNβ stimulation.

For demonstration purposes we adapt parts of the code from the original muscat vignette)

    library("DeeDeeExperiment")
    library("ExperimentHub")
    library("scater")
    library("muscat")
    library("limma")

We begin by creating an `ExperimentHub` instance, which provides access to curated datasets stored in the Bioconductor cloud. Using `query()`, we filter available records for entries matching the keyword “Kang”, and then load the dataset of interest using its accession ID “EH2259”.

    # retrieve the data
    eh <- ExperimentHub()
    query(eh, "Kang")
    #> ExperimentHub with 3 records
    #> # snapshotDate(): 2026-03-06
    #> # $dataprovider: NCI_GDC, GEO
    #> # $species: Homo sapiens
    #> # $rdataclass: character, SingleCellExperiment, BSseq
    #> # additional mcols(): taxonomyid, genome, description,
    #> #   coordinate_1_based, maintainer, rdatadateadded, preparerclass, tags,
    #> #   rdatapath, sourceurl, sourcetype
    #> # retrieve records with, e.g., 'object[["EH1661"]]'
    #>
    #>            title
    #>   EH1661 | Whole Genome Bisulfit Sequencing Data for 47 samples
    #>   EH1662 | Whole Genome Bisulfit Sequencing Data for 47 samples
    #>   EH2259 | Kang18_8vs8
    sce <- eh[["EH2259"]]

Before running muscat, we perform standard single-cell preprocessing steps: removing undetected genes, filtering low-quality cells using scater, and removing lowly expressed genes.

    # remove undetected genes
    sce <- sce[rowSums(counts(sce) > 0) > 0, ]

    # calculate per-cell quality control (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]
    dim(sce)
    #> [1] 18890 26820

    # remove lowly expressed genes
    sce <- sce[rowSums(counts(sce) > 1) >= 10, ]
    dim(sce)
    #> [1]  7118 26820

    # compute sum-factors & normalize
    sce <- computeLibraryFactors(sce)
    sce <- logNormCounts(sce)

We then prepare the data for `muscat`. The package expects a certain format of the input SCE. Specifically, the following cell metadata (colData) columns have to be provided:

- `sample_id` : unique sample identifiers
- `cluster_id` : subpopulation (cluster) assignments
- `group_id` : experimental group/condition

    # data preparation
    sce$id <- paste0(sce$stim, sce$ind)
    (sce <- prepSCE(sce,
                    kid = "cell", # subpopulation assignments
                    gid = "stim",  # group IDs (ctrl/stim)
                    sid = "id",   # sample IDs (ctrl/stim.1234)
                    drop = TRUE))  # drop all other colData columns
    #> class: SingleCellExperiment
    #> dim: 7118 26820
    #> metadata(1): experiment_info
    #> assays(2): counts logcounts
    #> rownames(7118): NOC2L HES4 ... S100B PRMT2
    #> rowData names(2): ENSEMBL SYMBOL
    #> colnames(26820): AAACATACAATGCC-1 AAACATACATTTCC-1 ... TTTGCATGGTTTGG-1
    #>   TTTGCATGTCTTAC-1
    #> colData names(3): cluster_id sample_id group_id
    #> reducedDimNames(1): TSNE
    #> mainExpName: NULL
    #> altExpNames(0):

We compute UMAP for visualization. The dataset already includes precomputed TSNE coordinates, so we only run UMAP here.

    # compute UMAP using 1st 20 PCs
    sce <- runUMAP(sce, pca = 20)

Then we aggregate measurements for each sample (in each cluster) to obtain pseudobulk data

    # aggregate by cell type
    pb <- aggregateData(
      sce,
      assay = "counts",
      fun = "sum",
      by = c("cluster_id", "sample_id")
    )

    assayNames(pb)
    #> [1] "B cells"           "CD14+ Monocytes"   "CD4 T cells"
    #> [4] "CD8 T cells"       "Dendritic cells"   "FCGR3A+ Monocytes"
    #> [7] "Megakaryocytes"    "NK cells"

And construct the contrast matrix

    # construct design & contrast matrix
    ei <- metadata(sce)$experiment_info
    mm <- model.matrix(~ 0 + ei$group_id)
    dimnames(mm) <- list(ei$sample_id, levels(ei$group_id))
    contrast <- makeContrasts("stim-ctrl", levels = mm)

With the pseudobulk data assembled, we can now test for differential state (DS) using `pbDS`

    # run DS analysis
    muscat_res <- pbDS(pb, design = mm, contrast = contrast)
    #>
      |
      |                                                                      |   0%
    #>
      |
      |=========                                                             |  12%
    #>
      |
      |==================                                                    |  25%
    #>
      |
      |==========================                                            |  38%
    #>
      |
      |===================================                                   |  50%
    #>
      |
      |============================================                          |  62%
    #>
      |
      |====================================================                  |  75%
    #>
      |
      |=============================================================         |  88%
    #>
      |
      |======================================================================| 100%

    names(muscat_res$table[["stim-ctrl"]])
    #> [1] "B cells"           "CD14+ Monocytes"   "CD4 T cells"
    #> [4] "CD8 T cells"       "Dendritic cells"   "FCGR3A+ Monocytes"
    #> [7] "Megakaryocytes"    "NK cells"

Now we integrate the output of muscat in `muscat_list_for_dde()` to transform it into a format accepted by `DeeDeeExperiment`

    # preparing the results as muscat list
    muscat_list <- muscat_list_for_dde(res = list(`stim-ctrl` = muscat_res),
                                       padj_col = "p_adj.loc")

Finally the results can be directly added to a new `dde` object, or to an existing one.

    # create dde
    dde <- DeeDeeExperiment(sce = sce,
                            de_results = muscat_list)
    dde
    #> class: DeeDeeExperiment
    #> dim: 7118 26820
    #> metadata(3): experiment_info singlecontrast version
    #> assays(2): counts logcounts
    #> rownames(7118): NOC2L HES4 ... S100B PRMT2
    #> rowData names(26): ENSEMBL SYMBOL ... stim-ctrl_NK cells_pvalue
    #>   stim-ctrl_NK cells_padj
    #> colnames(26820): AAACATACAATGCC-1 AAACATACATTTCC-1 ... TTTGCATGGTTTGG-1
    #>   TTTGCATGTCTTAC-1
    #> colData names(3): cluster_id sample_id group_id
    #> reducedDimNames(2): TSNE UMAP
    #> mainExpName: NULL
    #> altExpNames(0):
    #> dea(8): stim-ctrl_B cells, stim-ctrl_CD14+ Monocytes, stim-ctrl_CD4 T cells, stim-ctrl_CD8 T cells, stim-ctrl_Dendritic cells, stim-ctrl_FCGR3A+ Monocytes, stim-ctrl_Megakaryocytes, stim-ctrl_NK cells
    #> fea(0):

As for the other `DeeDeeExperiment` objects, we can call some specific methods to extract/retrieve/integrate some information.
We can extract the names of the DEA included:

    # check DEAs
    getDEANames(dde)
    #> [1] "stim-ctrl_B cells"           "stim-ctrl_CD14+ Monocytes"
    #> [3] "stim-ctrl_CD4 T cells"       "stim-ctrl_CD8 T cells"
    #> [5] "stim-ctrl_Dendritic cells"   "stim-ctrl_FCGR3A+ Monocytes"
    #> [7] "stim-ctrl_Megakaryocytes"    "stim-ctrl_NK cells"

Also, we can directly retrieve the content itself of each DEA by typing

    # retrieve results
    getDEA(dde,
           dea_name = "stim-ctrl_NK cells")|> head()
    #> DataFrame with 6 rows and 3 columns
    #>          stim-ctrl_NK cells_log2FoldChange stim-ctrl_NK cells_pvalue
    #>                                  <numeric>                 <numeric>
    #> NOC2L                                   NA                        NA
    #> HES4                                    NA                        NA
    #> ISG15                             4.715080               6.94235e-20
    #> TNFRSF18                         -0.583846               6.49706e-02
    #> TNFRSF4                          -0.219549               5.00289e-01
    #> SDF4                             -0.523241               1.80659e-02
    #>          stim-ctrl_NK cells_padj
    #>                        <numeric>
    #> NOC2L                         NA
    #> HES4                          NA
    #> ISG15                3.00604e-17
    #> TNFRSF18             1.63560e-01
    #> TNFRSF4              6.67095e-01
    #> SDF4                 6.37857e-02

    getDEA(dde,
           dea_name = "stim-ctrl_CD14+ Monocytes",
           format = "original") |> head()
    #>              gene      cluster_id log2FoldChange    logCPM          F
    #> HES4         HES4 CD14+ Monocytes      6.5041181  7.975074 282.968142
    #> ISG15       ISG15 CD14+ Monocytes      7.0258237 14.751515 229.037506
    #> SDF4         SDF4 CD14+ Monocytes     -0.7256656  5.446124  15.236040
    #> UBE2J2     UBE2J2 CD14+ Monocytes     -0.8083617  5.351035  22.886511
    #> CPSF3L     CPSF3L CD14+ Monocytes     -0.6600343  4.337862   7.343274
    #> AURKAIP1 AURKAIP1 CD14+ Monocytes     -0.5728129  7.389181  34.211958
    #>                pvalue         padj    p_adj.glb  contrast
    #> HES4     6.912599e-14 2.959294e-12 3.687094e-12 stim-ctrl
    #> ISG15    8.146888e-13 2.139849e-11 3.052753e-11 stim-ctrl
    #> SDF4     8.128918e-04 1.921981e-03 3.528924e-03 stim-ctrl
    #> UBE2J2   9.898603e-05 2.898329e-04 5.545317e-04 stim-ctrl
    #> CPSF3L   1.314382e-02 2.297739e-02 3.751614e-02 stim-ctrl
    #> AURKAIP1 8.127731e-06 3.167114e-05 6.047946e-05 stim-ctrl

General info on the DEA performed can be shown with `getDEAInfo()`

    # retrieving the DEA information
    dea_name <- "stim-ctrl_B cells"
    getDEAInfo(dde)[[dea_name]][["package"]]
    #> [1] "muscat"
    getDEAInfo(dde)[[dea_name]][["package_version"]]
    #> [1] "1.25.2"

To add some information on the scenario under investigation, we can use `addScenarioInfo()`. This can be e.g. later processed as a contextually relevant bit if a Large Language Model is used to interact with this object.

    # adding info on the scenario under investigation
    dde <- addScenarioInfo(dde,
                           dea_name = "stim-ctrl_Dendritic cells",
                           info = "This result contains the output of pseudobulk DE analysis performed on dendritic cells, comparing untreated samples to those stimulated with IFNβ")

As usual, the `summary()` method can be called to obtain a quick overview on all performed analyses.

    summary(dde, show_scenario_info = TRUE)
    #> DE Results Summary:
    #>                     DEA_name   Up Down  FDR
    #>            stim-ctrl_B cells  344  270 0.05
    #>    stim-ctrl_CD14+ Monocytes 1118 1282 0.05
    #>        stim-ctrl_CD4 T cells  640  511 0.05
    #>        stim-ctrl_CD8 T cells  178  115 0.05
    #>    stim-ctrl_Dendritic cells  113   70 0.05
    #>  stim-ctrl_FCGR3A+ Monocytes  497  411 0.05
    #>     stim-ctrl_Megakaryocytes   29    2 0.05
    #>           stim-ctrl_NK cells  254  200 0.05
    #>
    #> No FEA results stored.
    #>
    #> Scenario Info:
    #>  - stim-ctrl_Dendritic cells :
    #>  This result contains the output of pseudobulk DE analysis performed on
    #>   dendritic cells, comparing untreated samples to those stimulated with IFNβ
    #>
    #>
    #> No scenario info for: stim-ctrl_B cells, stim-ctrl_CD14+ Monocytes, stim-ctrl_CD4 T cells, stim-ctrl_CD8 T cells, stim-ctrl_FCGR3A+ Monocytes, stim-ctrl_Megakaryocytes, stim-ctrl_NK cells

# Session info

    sessionInfo()
    #> R Under development (unstable) (2026-03-20 r89666)
    #> Platform: aarch64-apple-darwin23
    #> Running under: macOS Tahoe 26.3.1
    #>
    #> Matrix products: default
    #> BLAS:   /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib
    #> LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
    #>
    #> locale:
    #> [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    #>
    #> time zone: America/New_York
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats4    stats     graphics  grDevices utils     datasets  methods
    #> [8] base
    #>
    #> other attached packages:
    #>  [1] muscData_1.25.0             muscat_1.25.2
    #>  [3] scater_1.39.3               ggplot2_4.0.2
    #>  [5] scuttle_1.21.0              ExperimentHub_3.1.0
    #>  [7] AnnotationHub_4.1.0         BiocFileCache_3.1.0
    #>  [9] dbplyr_2.5.2                DEFormats_1.39.0
    #> [11] edgeR_4.9.4                 limma_3.67.0
    #> [13] DESeq2_1.51.7               macrophage_1.27.0
    #> [15] DeeDeeExperiment_1.1.4      SingleCellExperiment_1.33.1
    #> [17] SummarizedExperiment_1.41.1 Biobase_2.71.0
    #> [19] GenomicRanges_1.63.1        Seqinfo_1.1.0
    #> [21] IRanges_2.45.0              S4Vectors_0.49.0
    #> [23] BiocGenerics_0.57.0         generics_0.1.4
    #> [25] MatrixGenerics_1.23.0       matrixStats_1.5.0
    #> [27] BiocStyle_2.39.0
    #>
    #> loaded via a namespace (and not attached):
    #>   [1] fs_1.6.7                 bitops_1.0-9             httr_1.4.8
    #>   [4] RColorBrewer_1.1-3       doParallel_1.0.17        numDeriv_2016.8-1.1
    #>   [7] tools_4.6.0              sctransform_0.4.3        backports_1.5.0
    #>  [10] R6_2.6.1                 uwot_0.2.4               mgcv_1.9-4
    #>  [13] apeglm_1.33.0            GetoptLong_1.1.0         withr_3.0.2
    #>  [16] prettyunits_1.2.0        gridExtra_2.3            fdrtool_1.2.18
    #>  [19] cli_3.6.5                sandwich_3.1-1           slam_0.1-55
    #>  [22] sass_0.4.10              mvtnorm_1.3-6            S7_0.2.1
    #>  [25] blme_1.0-7               yulab.utils_0.2.4        DOSE_4.5.1
    #>  [28] dichromat_2.0-0.1        parallelly_1.46.1        bbmle_1.0.25.1
    #>  [31] RSQLite_2.4.6            shape_1.4.6.1            gtools_3.9.5
    #>  [34] dplyr_1.2.0              GO.db_3.22.0             Matrix_1.7-4
    #>  [37] ggbeeswarm_0.7.3         abind_1.4-8              lifecycle_1.0.5
    #>  [40] multcomp_1.4-30          yaml_2.3.12              gplots_3.3.0
    #>  [43] SparseArray_1.11.11      grid_4.6.0               blob_1.3.0
    #>  [46] crayon_1.5.3             bdsmatrix_1.3-7          lattice_0.22-9
    #>  [49] beachmat_2.27.3          KEGGREST_1.51.1          pillar_1.11.1
    #>  [52] knitr_1.51               ComplexHeatmap_2.27.1    rjson_0.2.23
    #>  [55] boot_1.3-32              estimability_1.5.1       corpcor_1.6.10
    #>  [58] future.apply_1.20.2      codetools_0.2-20         glue_1.8.0
    #>  [61] data.table_1.18.2.1      vctrs_0.7.1              png_0.1-9
    #>  [64] Rdpack_2.6.6             gtable_0.3.6             emdbook_1.3.14
    #>  [67] cachem_1.1.0             xfun_0.57                rbibutils_2.4.1
    #>  [70] S4Arrays_1.11.1          coda_0.19-4.1            reformulas_0.4.4
    #>  [73] survival_3.8-6           iterators_1.0.14         statmod_1.5.1
    #>  [76] TH.data_1.1-5            nlme_3.1-168             pbkrtest_0.5.5
    #>  [79] bit64_4.6.0-1            RcppAnnoy_0.0.23         progress_1.2.3
    #>  [82] EnvStats_3.1.0           filelock_1.0.3           bslib_0.10.0
    #>  [85] TMB_1.9.20               irlba_2.3.7              vipor_0.4.7
    #>  [88] KernSmooth_2.23-26       otel_0.2.0               colorspace_2.1-2
    #>  [91] DBI_1.3.0                tidyselect_1.2.1         emmeans_2.0.2
    #>  [94] bit_4.6.0                compiler_4.6.0           curl_7.0.0
    #>  [97] httr2_1.2.2              BiocNeighbors_2.5.4      DelayedArray_0.37.0
    #> [100] bookdown_0.46            checkmate_2.3.4          scales_1.4.0
    #> [103] caTools_1.18.3           remaCor_0.0.20           rappdirs_0.3.4
    #> [106] stringr_1.6.0            digest_0.6.39            minqa_1.2.8
    #> [109] variancePartition_1.41.5 rmarkdown_2.30           aod_1.3.3
    #> [112] XVector_0.51.0           RhpcBLASctl_0.23-42      htmltools_0.5.9
    #> [115] pkgconfig_2.0.3          lme4_2.0-1               lpsymphony_1.39.0
    #> [118] fastmap_1.2.0            rlang_1.1.7              GlobalOptions_0.1.3
    #> [121] farver_2.1.2             jquerylib_0.1.4          IHW_1.39.0
    #> [124] zoo_1.8-15               jsonlite_2.0.0           BiocParallel_1.45.0
    #> [127] GOSemSim_2.37.2          BiocSingular_1.27.1      magrittr_2.0.4
    #> [130] Rcpp_1.1.1               viridis_0.6.5            stringi_1.8.7
    #> [133] MASS_7.3-65              plyr_1.8.9               parallel_4.6.0
    #> [136] listenv_0.10.1           ggrepel_0.9.8            Biostrings_2.79.5
    #> [139] splines_4.6.0            hms_1.1.4                circlize_0.4.17
    #> [142] locfit_1.5-9.12          enrichit_0.1.3           reshape2_1.4.5
    #> [145] ScaledMatrix_1.19.0      BiocVersion_3.23.1       evaluate_1.0.5
    #> [148] BiocManager_1.30.27      nloptr_2.2.1             foreach_1.5.2
    #> [151] tidyr_1.3.2              purrr_1.2.1              future_1.70.0
    #> [154] clue_0.3-67              rsvd_1.0.5               broom_1.0.12
    #> [157] xtable_1.8-8             RSpectra_0.16-2          fANCOVA_0.6-1
    #> [160] viridisLite_0.4.3        tibble_3.3.1             lmerTest_3.2-1
    #> [163] glmmTMB_1.1.14           memoise_2.0.1            beeswarm_0.4.0
    #> [166] AnnotationDbi_1.73.0     writexl_1.5.4            cluster_2.1.8.2
    #> [169] globals_0.19.1

# References

Kang, Hyun Min, Meena Subramaniam, Sasha Targ, Michelle Nguyen, Lenka Maliskova, Elizabeth McCarthy, Eunice Wan, et al. 2017. “Multiplexed Droplet Single-Cell RNA-Sequencing Using Natural Genetic Variation.” Nature Biotechnology 36 (1): 89–94. https://doi.org/10.1038/nbt.4042.