DiPPER

This is an R package implementing DiPPER (Differential Prevalence via Probabilistic Estimation in R).

DiPPER is a Bayesian hierarchical model-based approach designed for differential prevalence analysis, that is, for analyzing associations between the presence/absence status of taxonomic features (e.g. microbial species or genera) and an external variable (e.g. host disease status). This can be done while adjusting for covariates (e.g. age, sex, BMI) and/or for sequencing depth. DiPPER can also be used in longitudinal (repeated measures) designs.

Advantages of DiPPER

Installation

1. Install the CmdStan backend

DiPPER relies on CmdStan for Bayesian inference, so you first need to install the cmdstanr package and configure the C++ toolchain.

# Install cmdstanr from the official stan-dev repository
install.packages("cmdstanr",
                 repos = c("https://stan-dev.r-universe.dev",
                           getOption("repos")))

# Set up the C++ toolchain (Windows users may be prompted to install Rtools)
cmdstanr::check_cmdstan_toolchain(fix = TRUE)

# Install the actual CmdStan backend (only needs to be done once)
cmdstanr::install_cmdstan()

2. Install DiPPER

Once CmdStan is ready, install DiPPER.

# Install BiocManager if it is not already installed
if (!requireNamespace("BiocManager", quietly = TRUE)) {
    install.packages("BiocManager")
}

BiocManager::install("DiPPER")

DiPPER compiles its Stan models during installation, which takes a few minutes and produces verbose output. This is expected, and it is done only once.

Example

Below is a minimal workflow using the built-in tse_hintikka dataset, which compares gut microbiomes of rats on a high-fat versus low-fat diet (N = 20 + 20) while controlling for xylo-oligosaccharide supplementation. The dataset originates from Hintikka et al. (2021).

library(DiPPER)

# Load the dataset (a TreeSummarizedExperiment agglomerated to genus level)
data("tse_hintikka")

# Run DiPPER.
# The first term in the formula (here: Fat) is automatically used as the
# variable of interest. XOS (xylo-oligosaccharide supplementation) is included
# as a covariate. As the data consist of sequenecing counts, it is recommended
# to control for sequancing depth, too, by setting `read.depth = TRUE`.
fit <- dipper(
    tse = tse_hintikka,
    assay.type = "counts", # assay name in the tse object
    data.type = "counts", # type of data in the assay
    formula = ~ Fat + XOS,
    read.depth = TRUE,
    niter = 400 # This needs to be increased in practice!
)

# Print the details of the fit
print(fit)

# Extract summarized results as a data.frame
res <- summary(fit)

# Create a forest plot (showing only 'significant' taxa).
plot(fit)
Forest plot of the Hintikka dataset

Documentation

The package vignette covers the above example in more detail, along with an example using longitudinal data and a description of the summary output. After installing DiPPER, open it with:

vignette("DiPPER")