pathway_daa: Differential Abundance Analysis for Predicted Functional...

View source: R/pathway_daa.R

pathway_daaR Documentation

Differential Abundance Analysis for Predicted Functional Pathways

Description

Performs differential abundance analysis on predicted functional pathway data using various statistical methods. This function supports multiple methods for analyzing differences in pathway abundance between groups, including popular approaches like ALDEx2, DESeq2, edgeR, and others.

Usage

calculate_abundance_stats(abundance, metadata, group, features, group1, group2)

pathway_daa(
  abundance,
  metadata,
  group,
  daa_method = "ALDEx2",
  select = NULL,
  p.adjust = "BH",
  reference = NULL,
  include_abundance_stats = FALSE,
  ...
)

Arguments

abundance

A matrix or data frame with features as rows and samples as columns

metadata

A data frame containing sample information

group

Character string specifying the group column name in metadata

features

Character vector of feature names to calculate statistics for

group1

Character string specifying the first group name

group2

Character string specifying the second group name

daa_method

Character string specifying the method for differential abundance analysis. Available choices are:

  • "ALDEx2": ANOVA-Like Differential Expression tool

  • "DESeq2": Differential expression analysis based on negative binomial distribution

  • "edgeR": Exact test for differences between groups using negative binomial model

  • "limma voom": Limma-voom framework for RNA-seq analysis

  • "metagenomeSeq": Zero-inflated Gaussian mixture model

  • "LinDA": Linear models for differential abundance analysis

  • "Maaslin2": Multivariate Association with Linear Models

  • "Lefser": Linear discriminant analysis effect size

Default is "ALDEx2".

select

Vector of sample names to include in the analysis. If NULL (default), all samples are included.

p.adjust

Character string specifying the method for p-value adjustment. Choices are:

  • "BH": Benjamini-Hochberg procedure (default)

  • "holm": Holm's step-down method

  • "bonferroni": Bonferroni correction

  • "hochberg": Hochberg's step-up method

  • "fdr": False Discovery Rate

  • "none": No adjustment

reference

Character string specifying the reference level for the group comparison. If NULL (default), the first level is used as reference.

include_abundance_stats

Logical value indicating whether to include abundance statistics (mean relative abundance, standard deviation, and log2 fold change) in the output. Default is FALSE for backward compatibility.

...

Additional arguments passed to the specific DAA method

Details

Differential Abundance Analysis for Predicted Functional Pathways

Value

A data frame containing the differential abundance analysis results. The structure of the results depends on the chosen DAA method. For methods that support multi-group comparisons (like LinDA), when there are more than two groups, the results will contain separate rows for each feature in each pairwise comparison between the reference group and each non-reference group. The data frame includes the following columns:

  • feature: Feature/pathway identifier

  • method: The DAA method used

  • group1: Reference group

  • group2: Comparison group

  • p_values: P-values for the comparison

  • p_adjust: Adjusted p-values

  • adj_method: Method used for p-value adjustment

When include_abundance_stats = TRUE, the following additional columns are included:

  • mean_rel_abundance_group1: Mean relative abundance for group1

  • sd_rel_abundance_group1: Standard deviation of relative abundance for group1

  • mean_rel_abundance_group2: Mean relative abundance for group2

  • sd_rel_abundance_group2: Standard deviation of relative abundance for group2

  • log2_fold_change: Log2 fold change (group2/group1)

Some methods may provide additional columns, such as log2FoldChange for effect size information.

A data frame with columns:

feature

Feature identifier

mean_rel_abundance_group1

Mean relative abundance for group1

sd_rel_abundance_group1

Standard deviation of relative abundance for group1

mean_rel_abundance_group2

Mean relative abundance for group2

sd_rel_abundance_group2

Standard deviation of relative abundance for group2

log2_fold_change

Log2 fold change (group2/group1)

References

  • ALDEx2: Fernandes et al. (2014) Unifying the analysis of high-throughput sequencing datasets: characterizing RNA-seq, 16S rRNA gene sequencing and selective growth experiments by compositional data analysis. Microbiome.

  • DESeq2: Love et al. (2014) Moderated estimation of fold change and dispersion for RNA-seq data with DESeq2. Genome Biology.

  • edgeR: Robinson et al. (2010) edgeR: a Bioconductor package for differential expression analysis of digital gene expression data. Bioinformatics.

  • limma-voom: Law et al. (2014) voom: precision weights unlock linear model analysis tools for RNA-seq read counts. Genome Biology.

  • metagenomeSeq: Paulson et al. (2013) Differential abundance analysis for microbial marker-gene surveys. Nature Methods.

  • Maaslin2: Mallick et al. (2021) Multivariable Association Discovery in Population-scale Meta-omics Studies.

Helper function to calculate abundance statistics for differential analysis

This function calculates mean relative abundance, standard deviation, and log2 fold change for each feature between two groups.

Examples


# Load example data
data(ko_abundance)
data(metadata)

# Prepare abundance data
abundance_data <- as.data.frame(ko_abundance)
rownames(abundance_data) <- abundance_data[, "#NAME"]
abundance_data <- abundance_data[, -1]

# Run differential abundance analysis using ALDEx2
results <- pathway_daa(
  abundance = abundance_data,
  metadata = metadata,
  group = "Environment"
)

# Using a different method (DESeq2)
deseq_results <- pathway_daa(
  abundance = abundance_data,
  metadata = metadata,
  group = "Environment",
  daa_method = "DESeq2"
)

# Create example data with more samples
abundance <- data.frame(
  sample1 = c(10, 20, 30),
  sample2 = c(20, 30, 40),
  sample3 = c(30, 40, 50),
  sample4 = c(40, 50, 60),
  sample5 = c(50, 60, 70),
  row.names = c("pathway1", "pathway2", "pathway3")
)

metadata <- data.frame(
  sample = c("sample1", "sample2", "sample3", "sample4", "sample5"),
  group = c("control", "control", "treatment", "treatment", "treatment")
)

# Run differential abundance analysis using ALDEx2
results <- pathway_daa(abundance, metadata, "group")

# Using a different method (limma voom instead of DESeq2 for this small example)
limma_results <- pathway_daa(abundance, metadata, "group",
                            daa_method = "limma voom")

# Analyze specific samples only
subset_results <- pathway_daa(abundance, metadata, "group",
                             select = c("sample1", "sample2", "sample3", "sample4"))



ggpicrust2 documentation built on Aug. 26, 2025, 1:07 a.m.