### Load packaged example data with load() Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Loads the example data file 'tweedieverse_data.RData' from the package's extdata directory. This is used to run the vignette during Bioconductor checks without network access. ```r load(system.file( "extdata", "tweedieverse_data.RData", package = "Tweedieverse" )) ``` -------------------------------- ### Install Tweedieverse from Bioconductor Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Installs the release version of Tweedieverse using BiocManager. Requires BiocManager to be installed first. ```r if (!requireNamespace("BiocManager", quietly = TRUE)) { install.packages("BiocManager") } BiocManager::install("Tweedieverse") ``` -------------------------------- ### Install Tweedieverse from GitHub Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Installs the Tweedieverse R package from the GitHub repository using the remotes package. Requires the remotes package to be installed beforehand. ```R remotes::install_github('himelmallick/tweedieverse') ``` -------------------------------- ### Load Tweedieverse and Bioconductor packages Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Loads Tweedieverse and several Bioconductor container and example packages needed for the vignette workflows. ```r library(Tweedieverse) library(SummarizedExperiment) library(SingleCellExperiment) library(TreeSummarizedExperiment) library(MultiAssayExperiment) library(muscat) library(airway) ``` -------------------------------- ### Load Tweedieverse library Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Loads the Tweedieverse package into the R session after installation. ```R library(tweedieverse) ``` -------------------------------- ### Run median_comparison_tweedie on a toy data.frame Source: https://github.com/himelmallick/tweedieverse/blob/master/man/median_comparison_tweedie.Rd Creates a minimal data.frame with the required columns (taxon, metadata, effect_size, pval, stderr, qval) and calls median_comparison_tweedie with n_sims = 100 to demonstrate the function. The example uses two taxa and a single metadata group. ```R toy <- data.frame( taxon = c("tax1", "tax2"), metadata = c("grp", "grp"), effect_size = c(0.4, 0.2), pval = c(0.01, 0.2), stderr = c(0.1, 0.1), qval = c(0.02, 0.25) ) median_comparison_tweedie(toy, n_sims = 100) ``` -------------------------------- ### Fit Tweedieverse on multi-omics data (Franzosa et al.) Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Uses the packaged MultiAssayExperiment example from Franzosa et al. to run Tweedieverse with per-omics parameters for domain, normalization, and tweedie_p. The fit results are stored in multi_fit and inspected with names() and head(). ```r franzosa_example_mae multi_fit <- Tweedieverse( input_features = franzosa_example_mae, output = NULL, assay_name = "abundance", domain = c( taxaAbundanceProfile = "microbiome", harmonizedMetaboliteProfile = "custom" ), normalization = c( taxaAbundanceProfile = "NONE", harmonizedMetaboliteProfile = "MEDIAN" ), fixed_effects = c("diseaseCat_clean", "Age"), tweedie_p = list( taxaAbundanceProfile = NULL, harmonizedMetaboliteProfile = NULL ), median_comparison = FALSE, max_significance = 1 ) names(multi_fit) head(multi_fit$taxaAbundanceProfile) head(multi_fit$harmonizedMetaboliteProfile) ``` -------------------------------- ### Compute entropy of a vector Source: https://github.com/himelmallick/tweedieverse/blob/master/man/entropy.Rd Computes Shannon entropy for a vector of values. The example uses a character vector with repeated values. ```R entropy(c("A", "A", "B", "B", "C")) ``` -------------------------------- ### Tweedieverse R Function Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Documentation for the Tweedieverse R function, covering its arguments, usage examples, and behavior for different Tweedie variance powers. ```APIDOC ## Tweedieverse R Function ### Description Fits a Tweedie generalized linear model (GLM) or generalized linear mixed model (GLMM) to microbiome feature abundance data, with options for MaAsLin2 linear models, median comparison, and presence-absence logistic regression. ### Method R function call ### Endpoint `Tweedieverse(input_features, input_metadata, output, fixed_effects, ...)` ### Parameters #### Function Arguments - **input_features** (data.frame) - Required - Feature table with samples as rows and features as columns. - **input_metadata** (data.frame) - Required - Metadata table with sample information. - **output** (character) - Optional - Output directory path; if `NULL`, results are returned in memory. - **fixed_effects** (character) - Required - Column name(s) in metadata for fixed effects. - **tweedie_p** (numeric) - Optional - Tweedie variance power; `NULL` estimates it, `0` for Gaussian, `1` for Poisson, `2` for Gamma, `3` for inverse Gaussian, or a value in `(1,2)` for compound Poisson. - **p0_transform** (character) - Optional - Transform for `tweedie_p = 0`: `NONE`, `CLR`, `RCLR`, `LOG`, or `ARC_SIGNED_SQRT`. - **p0_transform_pseudocount** (numeric) - Optional - Pseudocount for `CLR` and `LOG` transforms. - **Maaslin2_run** (logical) - Optional - If `TRUE` and `tweedie_p = 0`, use MaAsLin2 linear model; default `TRUE`. - **link** (character) - Optional - Link function for GLM; for `tweedie_p = 0`, use `"identity"`. - **median_comparison** (logical) - Optional - If `TRUE`, compare coefficients against median effect; default `FALSE`. - **median_subtraction** (logical) - Optional - If `TRUE`, subtract median effect; used with `median_comparison`. - **run_presence_absence_model** (logical) - Optional - If `TRUE`, also fit a presence-absence logistic regression model. ### Request Example ```r fit <- Tweedieverse( input_features = features, input_metadata = metadata, output = "demo_output/p0_log", fixed_effects = "diagnosis", tweedie_p = 0, p0_transform = "LOG", p0_transform_pseudocount = 1 ) ``` ### Response #### Success Response Returns a fitted model object with results including coefficients, p-values, and q-values. When `median_comparison = TRUE`, the `coef`, `pval`, and `qval` columns are replaced by median-comparison adjusted values. When `output` is provided and a non-`NONE` transform is used, the transformed feature table is written to `transformed_features.tsv`. #### Response Example ```r # Fitted model object with results fit ``` ``` -------------------------------- ### Fit Tweedieverse on pseudobulk single-cell counts Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Aggregates single-cell counts to pseudobulk sample-level counts using muscat::aggregateData, then fits a Tweedieverse model on the resulting SummarizedExperiment. Uses tweedie_p = 1 and max_significance = 1. The example uses the package-provided example_sce object. ```R data("example_sce", package = "muscat") pseudobulk_input <- example_sce[seq_len(100), ] pseudobulk_sce <- muscat::aggregateData( pseudobulk_input, assay = "counts", fun = "sum", by = c("cluster_id", "sample_id"), verbose = FALSE ) SummarizedExperiment::assayNames(pseudobulk_sce) pseudobulk_assay <- "CD4 T cells" pseudobulk_counts <- SummarizedExperiment::assay( pseudobulk_sce, pseudobulk_assay ) top_pseudobulk_genes <- order( rowSums(pseudobulk_counts), decreasing = TRUE )[seq_len(20)] pseudobulk_metadata <- unique(as.data.frame( SummarizedExperiment::colData(pseudobulk_input)[, c("sample_id", "group_id")] )) rownames(pseudobulk_metadata) <- pseudobulk_metadata$sample_id pseudobulk_metadata <- pseudobulk_metadata[ colnames(pseudobulk_counts), , drop = FALSE ] pseudobulk_metadata$condition <- pseudobulk_metadata$group_id pseudobulk_se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = pseudobulk_counts[top_pseudobulk_genes, , drop = FALSE]), colData = pseudobulk_metadata ) pseudobulk_fit <- Tweedieverse( input_features = pseudobulk_se, output = NULL, assay_name = "counts", domain = "bulk_rnaseq", fixed_effects = c("condition"), tweedie_p = 1, median_comparison = FALSE, max_significance = 1 ) head(pseudobulk_fit) ``` -------------------------------- ### Basic Tweedieverse fit with SummarizedExperiment Source: https://github.com/himelmallick/tweedieverse/blob/master/man/Tweedieverse.Rd Creates a simulated count matrix and metadata, builds a SummarizedExperiment, and runs Tweedieverse with fixed effect 'group' and median_comparison = FALSE. The result is stored in 'fit' and printed with head(). ```R set.seed(123) features <- as.data.frame(matrix(rpois(24, lambda = 5), nrow = 12, ncol = 2)) colnames(features) <- c("feature1", "feature2") rownames(features) <- paste0("sample", seq_len(nrow(features))) metadata <- data.frame( group = rep(c("A", "B"), each = 6), row.names = rownames(features) ) experiment <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = t(as.matrix(features))), colData = metadata ) fit <- Tweedieverse( input_features = experiment, output = NULL, fixed_effects = "group", median_comparison = FALSE ) head(fit) ``` -------------------------------- ### Print R session information with sessionInfo() Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Use this snippet to display the R version, platform, and attached packages. It is typically run at the end of a vignette to document the computing environment. ```r sessionInfo() ``` -------------------------------- ### Run Tweedieverse with MaAsLin2 and presence-absence model (CCT) Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Runs Tweedieverse with `tweedie_p = 0`, enabling the MaAsLin2 abundance path and the presence-absence logistic model via `run_presence_absence_model = TRUE`. The combined output reports `pval_abundance`, `pval_presence`, and a joint `pval`/`qval` with `base.model = ```r fit <- Tweedieverse( input_features = features, input_metadata = metadata, output = NULL, fixed_effects = "diagnosis", tweedie_p = 0, Maaslin2_run = TRUE, run_presence_absence_model = TRUE ) ``` -------------------------------- ### Create a Tweedieverse heatmap with a toy data frame Source: https://github.com/himelmallick/tweedieverse/blob/master/man/Tweedieverse_heatmap.Rd Builds a toy data frame with feature, metadata, value, pval, qval, and coef columns, then calls Tweedieverse_heatmap with first_n = 2 to generate a heatmap. ```r toy <- data.frame( feature = c("tax1", "tax2", "tax1", "tax2"), metadata = c("grp", "grp", "time", "time"), value = c("A", "B", "A", "B"), pval = c(0.01, 0.05, 0.02, 0.03), qval = c(0.02, 0.08, 0.03, 0.04), coef = c(1.2, -0.7, 0.9, -0.4) ) Tweedieverse_heatmap(toy, first_n = 2) ``` -------------------------------- ### Basic Tweedieverse usage Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Runs Tweedieverse on an input file with output written to the specified directory. ```R Tweedieverse(input_file, output_dir) ``` -------------------------------- ### Run Tweedieverse with default CPLM path (tweedie_p = NULL) Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Use when you want the default compound Poisson Tweedie path, where the variance power is estimated (usually 1 < p < 2). The index is resolved after the feature table is oriented, aligned with metadata, and filtered. ```R Tweedieverse(feature_table, metadata, output, tweedie_p = NULL) ``` -------------------------------- ### Tweedieverse_heatmap(output_results, title = NA, cell_value = "qval", data_label = "data", metadata_label = "metadata", border_color = "grey93", color = colorRampPalette(c("darkblue", "grey90", "darkred")), col_rotate = 90, first_n = 50, write_to = NA) Source: https://github.com/himelmallick/tweedieverse/blob/master/man/Tweedieverse_heatmap.Rd Creates a heatmap summarizing association statistics from Tweedieverse results. It accepts a result data frame or a path to a TSV file and returns a pheatmap object or NULL when insufficient data are available. ```APIDOC ## Tweedieverse_heatmap ### Description Create a heatmap summarizing association statistics from Tweedieverse results. ### Usage ```r Tweedieverse_heatmap( output_results, title = NA, cell_value = "qval", data_label = "data", metadata_label = "metadata", border_color = "grey93", color = colorRampPalette(c("darkblue", "grey90", "darkred")), col_rotate = 90, first_n = 50, write_to = NA ) ``` ### Parameters - **output_results** (data.frame or character) - Required - Tweedieverse result data frame or path to a TSV file. - **title** (character) - Optional - Optional plot title. - **cell_value** (character) - Optional - Which value to display (`"qval"`, `"pval"`, or `"coef"`). - **data_label** (character) - Optional - Label for feature axis. - **metadata_label** (character) - Optional - Label for metadata axis. - **border_color** (character) - Optional - Heatmap border color. - **color** (function) - Optional - Color palette function. - **col_rotate** (numeric) - Optional - Rotation angle for column labels. - **first_n** (numeric) - Optional - Number of top features to include. - **write_to** (character) - Optional - Optional output directory for serialized plot objects. ### Return Value A `pheatmap` object or `NULL` when insufficient data are available. ### Example ```r toy <- data.frame( feature = c("tax1", "tax2", "tax1", "tax2"), metadata = c("grp", "grp", "time", "time"), value = c("A", "B", "A", "B"), pval = c(0.01, 0.05, 0.02, 0.03), qval = c(0.02, 0.08, 0.03, 0.04), coef = c(1.2, -0.7, 0.9, -0.4) ) Tweedieverse_heatmap(toy, first_n = 2) ``` ``` -------------------------------- ### Tweedieverse with Maaslin2 median comparison Source: https://github.com/himelmallick/tweedieverse/blob/master/man/Tweedieverse.Rd Runs Tweedieverse with tweedie_p = 0, Maaslin2_run = TRUE, median_comparison = TRUE, and median_subtraction = TRUE on the same experiment. The result is stored in 'maaslin2_median_fit'. ```R maaslin2_median_fit <- Tweedieverse( input_features = experiment, output = NULL, fixed_effects = "group", tweedie_p = 0, Maaslin2_run = TRUE, median_comparison = TRUE, median_subtraction = TRUE ) ``` -------------------------------- ### Tweedieverse with custom parameters Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Runs Tweedieverse with a custom Tweedie variance power, fixed effects, random effects, and normalization method. ```R Tweedieverse(input_file, output_dir, tweedie_power = 1.5, fixed_effects = c("fixed_effect1", "fixed_effect2"), random_effects = c("random_effect1"), normalization = "TMM") ``` -------------------------------- ### Fit Tweedieverse on bulk RNA-seq data (airway dataset) Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Loads the airway dataset, selects the top 20 genes by total count, creates a SummarizedExperiment, and runs Tweedieverse with TMM normalization (default for bulk RNA-seq). The output is set to NULL and the fit is stored in bulk_rnaseq_fit. ```r data("airway", package = "airway") airway_counts <- SummarizedExperiment::assay(airway, "counts") top_airway_genes <- order(rowSums(airway_counts), decreasing = TRUE)[seq_len(20)] bulk_rnaseq_se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = airway_counts[top_airway_genes, , drop = FALSE]), colData = SummarizedExperiment::colData(airway) ) bulk_rnaseq_se bulk_rnaseq_fit <- Tweedieverse( input_features = bulk_rnaseq_se, output = NULL, assay_name = "counts", domain = "bulk_rnaseq", fixed_effects = c("dex"), tweedie_p = 1, median_comparison = FALSE, max_significance = 1 ) head(bulk_rnaseq_fit) ``` -------------------------------- ### Run Tweedieverse with MultiAssayExperiment input Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Use when input_features is a MultiAssayExperiment. Tweedieverse iterates over each omics layer and returns a named list of omics-specific result tables; if output is provided, each layer is written to its own subdirectory. Most arguments can be a single value or a named list keyed by experiment name; use a named list when one layer needs NULL, since atomic vectors cannot reliably store per-layer NULL values. The returned object is a named list, so access results per layer with names(fit), fit$microbiome, and fit$rnaseq. ```r fit <- Tweedieverse( input_features = mae, output = "tweedieverse_multiomics", fixed_effects = "group", domain = c( microbiome = "microbiome", rnaseq = "bulk_rnaseq" ), normalization = c( microbiome = "TSS", rnaseq = "TMM" ), tweedie_p = list( microbiome = NULL, rnaseq = 1.5 ), run_presence_absence_model = c( microbiome = TRUE, rnaseq = FALSE ) ) names(fit) fit$microbiome fit$rnaseq ``` -------------------------------- ### Run Tweedieverse with MaAsLin2 linear model Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Set `Maaslin2_run = FALSE` to use a Tweedie GLM instead of the default MaAsLin2 linear model when `tweedie_p = 0`. ```R Tweedieverse(..., tweedie_p = 0, Maaslin2_run = FALSE) ``` -------------------------------- ### Tweedieverse Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Main function to run Tweedieverse analysis. It fits abundance models (Tweedie or MaAsLin2) and optionally presence-absence models, combining p-values with a Cauchy combination test. ```APIDOC ## Tweedieverse ### Description Main function to run Tweedieverse analysis. It fits abundance models (Tweedie or MaAsLin2) and optionally presence-absence models, combining p-values with a Cauchy combination test. ### Method R function ### Endpoint `Tweedieverse(input_features, input_metadata, output, fixed_effects, random_effects, ...)` ### Parameters #### input_features - **Type**: Bioconductor container (e.g., `TreeSummarizedExperiment`, `SingleCellExperiment`, `SummarizedExperiment`) or `MultiAssayExperiment` - **Required**: Yes - **Description**: Omics features (taxa, genes, etc.) with sample metadata in `colData`. Plain data frames, matrices, lists, and file paths are not accepted. #### input_metadata - **Type**: data.frame (optional) - **Required**: No - **Description**: Sample metadata. If not provided, `colData` from the input container is used. #### output - **Type**: character (optional) - **Required**: No - **Description**: Output directory. If `NULL`, results are returned in memory. #### fixed_effects - **Type**: character - **Required**: Yes - **Description**: Column name(s) in metadata for fixed effects. #### random_effects - **Type**: character (optional) - **Required**: No - **Description**: Column name(s) for random effects. #### tweedie_p - **Type**: numeric - **Required**: No - **Description**: Tweedie power parameter. Default is 1. When `tweedie_p = 0`, MaAsLin2 is used if `Maaslin2_run = TRUE`. #### Maaslin2_run - **Type**: logical - **Required**: No - **Description**: If `TRUE` and `tweedie_p = 0`, runs MaAsLin2 for abundance model. #### run_presence_absence_model - **Type**: logical - **Required**: No - **Description**: If `TRUE`, runs presence-absence logistic model and combines with abundance p-values via CCT. #### method_args - **Type**: list - **Required**: No - **Description**: List of method-specific arguments, e.g., `list(Maaslin2 = list(normalization = "NONE", transform = "NONE"))`. Alias `method.args` is also supported but only one should be supplied. #### BPPARAM - **Type**: BiocParallelParam - **Required**: No - **Description**: Parallel backend for feature-wise fitting. Default is `SerialParam()`. #### assay_name - **Type**: character - **Required**: No - **Description**: Name of assay to use from the input container. #### median_comparison - **Type**: logical - **Required**: No - **Description**: If `TRUE`, uses median comparison for abundance model. #### max_significance - **Type**: numeric - **Required**: No - **Description**: Maximum significance threshold for filtering results. ### Request Example ```r fit <- Tweedieverse( input_features = experiment, output = NULL, fixed_effects = "group", tweedie_p = 1, median_comparison = FALSE, max_significance = 1 ) ``` ### Response #### Success Response - **fit**: data.frame with columns including `pval_abundance`, `qval_abundance`, `pval_presence`, `qval_presence`, `base.model_abundance`, `base.model_presence`, combined `pval`, `qval`, and `base.model = "CCT"` when presence-absence model is run. #### Response Example ```r head(fit) ``` ``` -------------------------------- ### median_comparison_tweedie(df, p_cutoff, subtract_median, n_sims, median_threshold) Source: https://github.com/himelmallick/tweedieverse/blob/master/man/median_comparison_tweedie.Rd Adjusts coefficient estimates and p-values by testing each taxon against the median effect for the same metadata variable. Returns the input data frame with two new columns: coef_median and pval_median. ```APIDOC ## Function: median_comparison_tweedie ### Description Adjust Tweedieverse (or any other differential analysis methods) coefficient estimates and p-values by testing each taxon against the *median* effect for the same metadata variable - a simple post-hoc strategy to curb false discoveries driven by the compositional nature of microbiome count data (after the approach adopted in **MaAsLin 3**). ### Usage ```r median_comparison_tweedie( df, p_cutoff = 0.95, subtract_median = FALSE, n_sims = 10000, median_threshold = 0 ) ``` ### Parameters - **df** (data.frame) - Required - A `data.frame` returned by **Tweedieverse** or any other differential analysis methods containing (at minimum) the columns `taxon`, `metadata`, `effect_size`, `pval`, `stderr`, and `qval`. - **p_cutoff** (numeric) - Optional - Upper bound on the original p-value to include an effect in the median calculation (default `0.95` = all non-missing). - **subtract_median** (logical) - Optional - If `TRUE`, subtracts the group median from every coefficient before returning it in `coef_median`; otherwise the original `effect_size` is copied unchanged (default `FALSE`). - **n_sims** (integer) - Optional - Number of Monte-Carlo simulations used to estimate the covariance between each coefficient and the group median (default `10 000`). - **median_threshold** (numeric) - Optional - Absolute difference below which a coefficient is considered effectively equal to the median and assigned `pval_median = 1` (default `0`). ### Return Value The input `df` with two new columns: - **coef_median** - Median-centred coefficient (or the original `effect_size` if `subtract_median = FALSE`). - **pval_median** - Two-sided p-value from the median-comparison test. ### Details For every distinct value in `metadata` the algorithm: 1. Keeps coefficients with `pval < p_cutoff` and computes their median. 2. Simulates `n_sims` draws of coefficients using a normal approximation (`N(effect_size, stderr^2)`) and records the empirical distribution of the simulated medians. 3. Derives a variance-inflated *offset* that accounts for the covariance between each coefficient and the group median. 4. Performs a two-sided Z-test of `H0 : beta_i = offset_i`, returning the resulting p-value in `pval_median`. ### Warning The procedure is heuristic and relies on normal approximations. Results may be unstable for very small sample sizes or when `stderr` values are zero or missing. ### Example ```r toy <- data.frame( taxon = c("tax1", "tax2"), metadata = c("grp", "grp"), effect_size = c(0.4, 0.2), pval = c(0.01, 0.2), stderr = c(0.1, 0.1), qval = c(0.02, 0.25) ) median_comparison_tweedie(toy, n_sims = 100) ``` ### See Also [MaAsLin 3 GitHub](https://github.com/biobakery/maaslin3) ``` -------------------------------- ### Fit Tweedieverse on single-cell UMI SingleCellExperiment Source: https://github.com/himelmallick/tweedieverse/blob/master/vignettes/Tweedieverse.Rmd Fits a Tweedieverse model on a SingleCellExperiment with UMI counts. Pins variance power to p = 1 (Poisson variance) and uses normalization = "SCRAN" to compute size factors for the model offset without modifying the assay. ```r umi_sce umi_fit <- Tweedieverse( input_features = umi_sce, output = NULL, assay_name = "counts", domain = "single_cell", normalization = "SCRAN", fixed_effects = c("condition", "batch"), tweedie_p = 1, median_comparison = FALSE ) head(umi_fit) ``` -------------------------------- ### Run Tweedieverse with fixed Tweedie variance power Source: https://github.com/himelmallick/tweedieverse/blob/master/README.md Pass a numeric value to `tweedie_p` to fix the variance power instead of estimating it. Values between 0 and 1 are undefined and rejected; negative values are allowed for non-negative data. ```R Tweedieverse(feature_table, metadata, output, tweedie_p = 1.5) ``` -------------------------------- ### Tweedieverse Analysis Function Parameters Source: https://github.com/himelmallick/tweedieverse/blob/master/man/Tweedieverse.Rd Parameters for the main Tweedieverse analysis function, which fits Tweedie GLM or mixed models to feature abundance data with optional transformations, normalization, and presence-absence modeling. ```APIDOC ## Tweedieverse Analysis Function ### Description Performs Tweedie generalized linear model (GLM) or mixed model analysis on feature abundance data, with options for data transformation, normalization, and multiple testing correction. ### Parameters #### p0_transform - **Type**: character - **Required**: No - **Description**: Transformation to apply to a copy of the filtered feature table when the resolved Tweedie index is 0. The original input data are not modified. Must be one of "NONE", "CLR", "RCLR", "LOG", or "ARC_SIGNED_SQRT". The transformed copy is used for the p = 0 abundance model and written to transformed_features.tsv when output is provided. Default is "NONE". #### p0_transform_pseudocount - **Type**: numeric - **Required**: No - **Description**: Numeric pseudocount used for p0_transform = "CLR" and p0_transform = "LOG". Default is 1. #### fixed_effects - **Type**: character (vector) - **Required**: Yes - **Description**: Metadata variable(s) describing the fixed effects coefficients. #### random_effects - **Type**: character (vector) - **Required**: No - **Description**: Metadata variable(s) describing the random effects part of the model. #### domain - **Type**: character - **Required**: No - **Description**: Domain used to choose the default size-factor normalization. Must be one of "microbiome", "single_cell", "bulk_rnaseq", or "custom". The default is "microbiome". #### normalization - **Type**: character - **Required**: No - **Description**: Size-factor strategy used only to compute the model offset. The input feature table is never normalized or transformed. If NULL, the domain default is used: "TSS" for microbiome, "SCRAN" for single-cell, "TMM" for bulk RNA-seq, and "MEDIAN" for custom/other omics. Supported strategies are "TSS", "GMPR", "CSS", "SCRAN", "TMM", "RLE" / "DESEQ2", "CPM", "MEDIAN", and "NONE". #### adjust_offset - **Type**: logical - **Required**: No - **Description**: If TRUE (default), an offset term will be included as the logarithm of the size factor estimated by normalization, or by scale_factor when supplied. #### scale_factor - **Type**: character - **Required**: No - **Description**: Name of a numerical metadata variable containing user-supplied sample size factors. When supplied, this overrides domain and normalization for offset calculation. #### max_significance - **Type**: numeric - **Required**: No - **Description**: The q-value threshold for significance. Default is 0.05. #### correction - **Type**: character - **Required**: No - **Description**: The correction method for computing the q-value (see p.adjust for options, default is 'BH'). #### Maaslin2_run - **Type**: logical - **Required**: No - **Description**: For tweedie_p = 0, run the MaAsLin2 linear-model path instead of the Tweedie GLM path. Set to FALSE to fit tweedie_p = 0 with the Tweedie GLM. Default is TRUE. When the resolved Tweedie index is 0, non-identity links are changed to "identity" and adjust_offset is disabled. #### median_comparison - **Type**: logical - **Required**: No - **Description**: If TRUE, coefficients will be tested against a null value corresponding to the median coefficient for a covariate in the metadata. Default is FALSE. Should only be used for relative abundance data. #### median_subtraction - **Type**: logical - **Required**: No - **Description**: If TRUE, coefficients minus median will be used for compositionality adjustment. #### run_presence_absence_model - **Type**: logical - **Required**: No - **Description**: If TRUE, also fit a DAssemble-style presence-absence logistic regression model alongside the selected abundance model, including the MaAsLin2 path used by default for tweedie_p = 0. Retains individual abundance and presence-absence model results, and ranks features by a Cauchy combination test of the two p-values. Default is FALSE. #### method_args - **Type**: list - **Required**: No - **Description**: Optional named list of method-specific arguments. For tweedie_p = 0, use method_args = list(Maaslin2 = list(...)) to pass arguments to Maaslin2; user-supplied values override Tweedieverse defaults. #### method.args - **Type**: list - **Required**: No - **Description**: Alias for method_args. #### standardize - **Type**: logical - **Required**: No - **Description**: Should continuous metadata be standardized? Default is TRUE. Bypassed for categorical variables. #### BPPARAM - **Type**: BiocParallelParam - **Required**: No - **Description**: BiocParallelParam object controlling Bioconductor-native parallel evaluation. Default is SerialParam. #### optimizer - **Type**: character - **Required**: No - **Description**: The optimization routine to be used for estimating the parameters of the Tweedie model. Possible choices are "nlminb" (the default), "bobyqa", and "L-BFGS-B". Ignored for random effects modeling which uses an alternative Template Model Builder (TMB) approach (glmmTMB). #### na.action - **Type**: function - **Required**: No - **Description**: How to handle missing values? See na.action. Default is na.exclude. #### plot_heatmap - **Type**: logical - **Required**: No - **Description**: Logical. If TRUE (default is FALSE), generate a heatmap of the (top heatmap_first_n) significant associations. #### plot_scatter - **Type**: logical - **Required**: No - **Description**: Logical. If TRUE (default is FALSE), generate scatter/box plots of individual associations. #### heatmap_first_n - **Type**: numeric - **Required**: No - **Description**: In heatmap, plot top N features with significant associations (default is 50). ``` -------------------------------- ### theme_omicsEye() Source: https://github.com/himelmallick/tweedieverse/blob/master/man/theme_omicsEye.Rd Returns a compact ggplot2 theme used by Tweedieverse visualization functions. This function takes no arguments and returns a list of ggplot2 theme elements. ```APIDOC ## theme_omicsEye() ### Description Returns a compact ggplot2 theme used by Tweedieverse visualization functions. ### Usage ```r theme_omicsEye() ``` ### Arguments None. ### Value A list of ggplot2 theme elements. ### Examples ```r theme_omicsEye() ``` ``` -------------------------------- ### Tweedieverse() Source: https://github.com/himelmallick/tweedieverse/blob/master/man/Tweedieverse.Rd Main function for differential analysis of multi-omics data using Tweedie GLMs. It takes an expression/abundance matrix and metadata, fits per-feature models, and returns results. ```APIDOC ## Tweedieverse() ### Description Performs differential analysis of multi-omics data using Tweedie GLMs. It accepts a Bioconductor container (e.g., TreeSummarizedExperiment, SingleCellExperiment, SummarizedExperiment) or a MultiAssayExperiment, and fits per-feature models to identify associations with metadata. ### Usage ```r Tweedieverse( input_features, input_metadata = NULL, output = NULL, assay_name = "counts", abd_threshold = 0, prev_threshold = 0.1, var_threshold = 0, entropy_threshold = 0, base_model = "CPLM", link = "log", tweedie_p = NULL, p0_transform = "NONE", p0_transform_pseudocount = 1, fixed_effects = NULL, random_effects = NULL, domain = "microbiome", normalization = NULL, adjust_offset = TRUE, scale_factor = NULL, max_significance = 0.05, correction = "BH", Maaslin2_run = TRUE, median_comparison = FALSE, median_subtraction = FALSE, run_presence_absence_model = FALSE, method_args = NULL, method.args = NULL, standardize = TRUE, BPPARAM = BiocParallel::SerialParam(), optimizer = "nlminb", na.action = na.exclude, plot_heatmap = FALSE, plot_scatter = FALSE, heatmap_first_n = 50, reference = NULL ) ``` ### Parameters #### input_features - **Type**: Bioconductor container (TreeSummarizedExperiment, SingleCellExperiment, SummarizedExperiment) or MultiAssayExperiment - **Required**: Yes - **Description**: The omics data container. The `assays` slot contains the expression/abundance matrix (default assay name "counts"). For MultiAssayExperiment, iterates over each experiment and returns a named list of results. The `colData` slot should contain sample metadata. #### input_metadata - **Type**: data.frame - **Required**: No (default NULL) - **Description**: Optional metadata data frame. Sample names must match those in `input_features`. If NULL, metadata is taken from the container's `colData`. #### output - **Type**: character (folder path) - **Required**: No - **Description**: Output folder to write results. #### assay_name - **Type**: character - **Required**: No (default "counts") - **Description**: Name of the assay slot containing the omics measurements. For MultiAssayExperiment, can be a single value or named list/vector keyed by experiment name. #### abd_threshold - **Type**: numeric - **Required**: No (default 0) - **Description**: Minimum abundance for prevalence-abundance filtering. Features present in at least `prev_threshold` percent of samples at this abundance are retained. Set to -Inf to disable filtering. #### prev_threshold - **Type**: numeric - **Required**: No (default 0.1) - **Description**: Minimum prevalence (percent of samples) for prevalence-abundance filtering. #### var_threshold - **Type**: numeric - **Required**: No (default 0) - **Description**: Minimum variance for variance filtering. Features with variance greater than this are retained. Default 0 disables variance filtering. #### entropy_threshold - **Type**: numeric - **Required**: No (default 0) - **Description**: Minimum entropy for metadata filtering. Features with entropy greater than this are retained. Default 0 disables entropy filtering. #### base_model - **Type**: character - **Required**: No (default "CPLM") - **Description**: The per-feature base model. Only "CPLM" is supported. #### link - **Type**: character - **Required**: No (default "log") - **Description**: GLM link function. Must be one of "log", "identity", "sqrt", or "inverse". #### tweedie_p - **Type**: numeric - **Required**: No (default NULL) - **Description**: Tweedie variance power. If NULL, estimates the compound-Poisson Tweedie index in the range 1 < p < 2 when all filtered feature values are non-negative. If NULL/NA and negative values exist, resolves to 0 (Gaussian). Values between 0 and 1 are rejected. Negative supplied powers allowed with warning for non-negative data. Random-effect models support fixed p = 0, 1, 1