--- title: "DAssemble: Ensemble Differential Analysis" author: - name: Ziyu Liu - name: Nalin Arora - name: Chuxuan Gao - name: Himel Mallick package: DAssemble output: BiocStyle::html_document: toc: true toc_float: true vignette: > %\VignetteIndexEntry{DAssemble: Ensemble Differential Analysis} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE ) ``` # Introduction DAssemble is an R package for ensemble-based differential association analysis of high-throughput omics data. It provides a flexible framework for combining a user-specified **core method** with one or more complementary **enhancer** methods, allowing users to integrate statistical evidence across different modeling assumptions rather than relying on a single differential analysis approach. DAssemble aggregates model-specific p-values using the **Cauchy Combination Tests (CCT)** and reports both ensemble-level and method-specific results. The package was developed to support robust and interpretable differential analysis across multiple omics domains, including bulk RNA-seq, single-cell RNA-seq, and microbiome data. We submitted DAssemble to Bioconductor to make the method easier to install, document, test, and integrate with established Bioconductor workflows and data structures, thereby supporting reproducible and extensible analysis of high-throughput biological data. # Overview `DAssemble` implements an ensemble framework for differential-abundance and differential-expression analysis. Users can choose a single core model and optionally combine it with enhancer tests using the Cauchy Combination Test. The package accepts a `MultiAssayExperiment` object directly. When multiple experiments are present, use `assay_name` to select the experiment to analyze. For lower-level workflows, `features` can also be a data frame with samples in rows and features in columns, paired with a `metadata` data frame with matching sample row names. The exposure variable supplied through `expVar` must be binary. The main `DAssemble()` function also supports: - multiple adjustment covariates through `coVars` - repeated-measures / longitudinal designs through `random_effects` - open-ended method-specific controls through `method_args` These arguments are available only for methods whose wrappers can express the corresponding model directly. For unsupported methods, DAssemble stops with a clear error rather than fitting a mis-specified model. # Main API The primary entry point is: ```{r main-signature, eval=FALSE} DAssemble( features, metadata = NULL, core_method = NULL, enhancers = NULL, expVar = "group", coVars = NULL, random_effects = NULL, method_args = NULL, assay_name = NULL, p_adj = "BY", enhancer_norm = "TSS", return_components = TRUE, return_subensembles = FALSE ) ``` `method_args` is a named control list used to forward additional arguments to underlying methods. When an argument overlaps with a DAssemble wrapper default, the value in `method_args` takes precedence. The usual pattern is: - `method_args$core` for arguments shared by the selected core method - `method_args$enhancer` for arguments shared by the selected enhancers - `method_args$` for method-specific overrides For the `LR` enhancer, the wrapper additionally recognizes `method_args$LR$separation_method`. The default is `"augment"`, which follows the MaAsLin3-style augmented logistic fit. For cross-sectional presence/absence logistic analyses, users can instead request `"firth"` to use bias-reduced logistic regression through `brglm2`. For the `Maaslin2` core, the wrapper also recognizes `method_args$Maaslin2$median_comparison = TRUE`. When requested, DAssemble uses raw `fit$results`, applies the internal `median_comparison_tweedie()` adjustment there, and only then reduces the output back to the standardized exposure-specific result table. Wrappers with multi-stage internals can also accept subcall-specific entries. For example, `method_args$DESeq2` may contain items such as `DESeq`, `results`, or `estimateSizeFactors`, while `method_args$edgeR` may contain items such as `glmFit` or `glmLRT`. ```{r method-args-example, eval=FALSE} res <- DAssemble( features = features, metadata = metadata, enhancers = "LR", expVar = "group", method_args = list( LR = list(separation_method = "firth") ) ) ``` For example, MaAsLin3's prevalence median comparison can be enabled with: ```{r maaslin3-method-args, eval=FALSE} res <- DAssemble( features = features, metadata = metadata, core_method = "Maaslin3", expVar = "group", method_args = list( Maaslin3 = list(median_comparison_prevalence = TRUE) ) ) ``` # Supported methods Core methods currently available in `DAssemble()` include: - `DESeq2` - `edgeR` - `limmaVOOM` - `metagenomeSeq` - `MAST` - `dearseq` - `ALDEx2` - `LinDA` - `LOCOM` - `Maaslin2` - `Maaslin3` - `Tweedieverse` - `Robseq` - `ANCOMBC2` Enhancers currently available are: - `WLX` - `LR` - `KS` # Covariate and longitudinal support The current implementation supports multiple covariates (`coVars`) for the following methods: | Method | Multiple covariates | |:--|:--| | DESeq2 | Yes | | edgeR | Yes | | limmaVOOM | Yes | | metagenomeSeq | Yes | | MAST | Yes | | dearseq | Yes | | ALDEx2 | Yes | | LinDA | Yes | | Maaslin2 | Yes | | Maaslin3 | Yes | | Tweedieverse | Yes | | Robseq | Yes | | ANCOMBC2 | Yes | | LR | Yes | | WLX | No | | KS | No | | LOCOM | No | When `random_effects` is supplied, the following methods are currently treated as longitudinal-compatible: | Method | Longitudinal support | |:--|:--| | Maaslin2 | Yes | | Maaslin3 | Yes | | Tweedieverse | Yes | | LR | Yes | All other methods should be treated as cross-sectional only in the current package implementation. For the `LR` enhancer, the default fitting path uses MaAsLin3-style augmentation in both cross-sectional and longitudinal settings. The alternative `method_args$LR$separation_method = "firth"` is available only for the non-longitudinal model. `Maaslin3` is used through its standard package pathway in `DAssemble()` and is not forced into a prevalence-only mode. # Installation Install `DAssemble` from Bioconductor with `BiocManager`: ```{r installation, eval=FALSE} if (!requireNamespace("BiocManager", quietly = TRUE)) { install.packages("BiocManager") } BiocManager::install("DAssemble") ``` # Bulk RNA-seq Example The `airway` dataset from Bioconductor contains RNA-seq counts from airway smooth muscle cells treated with dexamethasone. The example below runs `DAssemble` with `DESeq2` as the core method and two enhancers. ```{r airway-example} data("airway", package = "airway") counts <- SummarizedExperiment::assay(airway, "counts") keep_genes <- order(rowSums(counts), decreasing = TRUE)[seq_len(500L)] counts <- counts[keep_genes, , drop = FALSE] metadata <- as.data.frame(SummarizedExperiment::colData(airway)) metadata <- metadata[colnames(counts), , drop = FALSE] se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = counts) ) mae <- MultiAssayExperiment::MultiAssayExperiment( experiments = list(rnaseq = se), colData = S4Vectors::DataFrame(metadata) ) res <- DAssemble::DAssemble( features = mae, assay_name = "rnaseq", core_method = "DESeq2", enhancers = c("WLX", "LR"), expVar = "dex", coVars = "cell", p_adj = "BH", enhancer_norm = "tmm", method_args = list( DESeq2 = list( DESeq = list(fitType = "local") ), LR = list( control = glm.control(maxit = 100) ) ), return_components = TRUE, return_subensembles = TRUE ) head(res$res) names(res$components) ``` This analysis adjusts for `cell`, combines DESeq2 p-values with Wilcoxon and logistic-regression enhancer p-values, and forwards example control arguments through `method_args`. The combined results are returned in `res$res`, and the per-method outputs are available in `res$components`. # Longitudinal HMP2 Example The Human Microbiome Project 2 adult example included with the package shows a longitudinal microbiome analysis with multiple covariates. The feature table and metadata are stored in `inst/extdata` and can be accessed after installation with `system.file()`. To keep the vignette build lightweight, the evaluated example below uses the most abundant taxa and runs the Dysbiosis_UC scenario. ```{r hmp2-longitudinal-example} hmp2_file <- system.file( "extdata", "hmp2_adult.RData", package = "DAssemble", mustWork = TRUE ) load(hmp2_file) stopifnot( exists("adult_taxa"), exists("adult_meta"), identical(rownames(adult_taxa), rownames(adult_meta)) ) binary_factor <- function(x) { factor(as.integer(x), levels = c(0, 1)) } adult_meta$diagnosis_CD <- binary_factor(adult_meta$diagnosis == "CD") adult_meta$diagnosis_UC <- binary_factor(adult_meta$diagnosis == "UC") adult_meta$dysbiosis_CD <- binary_factor( adult_meta$dysbiosis_state == "dysbiosis_CD" ) adult_meta$dysbiosis_UC <- binary_factor( adult_meta$dysbiosis_state == "dysbiosis_UC" ) adult_meta$dysbiosis_nonIBD <- binary_factor( adult_meta$dysbiosis_state == "dysbiosis_nonIBD" ) adult_meta$abx_used <- binary_factor(adult_meta$Antibiotics == "Yes") adult_meta$participant_id <- factor(adult_meta$`Participant ID`) disease <- "UC" other_disease <- "CD" hmp2_taxa <- adult_taxa[ , order(colSums(adult_taxa), decreasing = TRUE)[seq_len(20L)], drop = FALSE ] res <- DAssemble::DAssemble( features = hmp2_taxa, metadata = adult_meta, expVar = paste0("dysbiosis_", disease), coVars = c( "diagnosis_CD", "diagnosis_UC", paste0("dysbiosis_", other_disease), "dysbiosis_nonIBD", "abx_used", "reads_filtered" ), random_effects = "participant_id", core_method = "Maaslin2", enhancers = "LR", method_args = list( Maaslin2 = list(median_comparison = TRUE) ), enhancer_norm = "TSS", p_adj = "BH", return_components = TRUE ) head(res$res) head(res$components$Maaslin2) head(res$components$LR) ``` The same example is also available as an executable script: ```{r hmp2-example-script, eval=FALSE} source(system.file( "extdata", "hmp2_adult_example.R", package = "DAssemble", mustWork = TRUE )) ``` # Microbiome Example The `GlobalPatterns` dataset from `phyloseq` contains 16S rRNA profiles from environmental and host-associated microbiome samples. The example below compares fecal and soil samples using enhancer-only DAssemble with CLR normalization. ```{r microbiome-example} data("GlobalPatterns", package = "phyloseq") gp <- GlobalPatterns otu <- as(phyloseq::otu_table(gp), "matrix") metadata <- as.data.frame(phyloseq::sample_data(gp)) keep <- metadata$SampleType %in% c("Feces", "Soil") otu <- otu[, keep, drop = FALSE] keep_taxa <- order(rowSums(otu), decreasing = TRUE)[seq_len(250L)] features <- as.data.frame(t(otu[keep_taxa, , drop = FALSE])) metadata <- metadata[keep, , drop = FALSE] metadata$group <- droplevels(factor(metadata$SampleType)) stopifnot(nlevels(metadata$group) == 2L) se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = t(as.matrix(features))) ) mae <- MultiAssayExperiment::MultiAssayExperiment( experiments = list(microbiome = se), colData = S4Vectors::DataFrame(metadata) ) res <- DAssemble::DAssemble( features = mae, assay_name = "microbiome", core_method = NULL, enhancers = c("WLX", "LR", "KS"), expVar = "group", enhancer_norm = "clr", return_components = TRUE, return_subensembles = TRUE ) head(res$res) names(res$components) head(res$ensembles) ``` Because the core method is `NULL`, this example combines only enhancer tests. The `$ensembles` element reports the CCT results for the enhancer combinations when `return_subensembles = TRUE`. # Single-Cell Example The single-cell example uses a small `SingleCellExperiment` object with two cell groups. The object is wrapped in a `MultiAssayExperiment` before being passed to `DAssemble`, matching the same input architecture used above. ```{r single-cell-example} set.seed(1) n_genes <- 120L n_cells <- 20L cell_type <- factor(rep(c("control", "treated"), each = n_cells / 2L)) counts <- matrix( stats::rnbinom(n_genes * n_cells, mu = 20, size = 5), nrow = n_genes, dimnames = list( paste0("gene", seq_len(n_genes)), paste0("cell", seq_len(n_cells)) ) ) counts[seq_len(12L), cell_type == "treated"] <- counts[seq_len(12L), cell_type == "treated"] + 15L metadata <- data.frame( CellType = cell_type, row.names = colnames(counts) ) sce <- SingleCellExperiment::SingleCellExperiment( assays = list(counts = counts), colData = S4Vectors::DataFrame(metadata) ) mae <- MultiAssayExperiment::MultiAssayExperiment( experiments = list(single_cell = sce), colData = S4Vectors::DataFrame(metadata) ) res <- DAssemble::DAssemble( features = mae, assay_name = "single_cell", core_method = "edgeR", enhancers = c("WLX", "LR", "KS"), enhancer_norm = "TSS", expVar = "CellType", p_adj = "BH", return_components = TRUE, return_subensembles = TRUE ) head(res$res) names(res$components) ``` # Session information ```{r session-info} sessionInfo() ```