Skip to contents

This function `generate_alpha_trend_test_long`, part of the MicrobiomeStat package, performs a trend test on longitudinal alpha diversity data using a linear mixed-effects model. The model is used to test the association between alpha diversity and a numeric time variable, while adjusting for potential confounding variables. It accepts alpha diversity data and other related parameters to conduct the test.

Usage

generate_alpha_trend_test_long(
  data.obj,
  alpha.obj = NULL,
  alpha.name = c("shannon", "observed_species"),
  depth = NULL,
  time.var,
  subject.var,
  group.var = NULL,
  adj.vars = NULL
)

Arguments

data.obj

A list object in a format specific to MicrobiomeStat, which can include components such as feature.tab (matrix), feature.ann (matrix), meta.dat (data.frame), tree, and feature.agg.list (list). The data.obj can be converted from other formats using several functions from the MicrobiomeStat package, including: 'mStat_convert_DGEList_to_data_obj', 'mStat_convert_DESeqDataSet_to_data_obj', 'mStat_convert_phyloseq_to_data_obj', 'mStat_convert_SummarizedExperiment_to_data_obj', 'mStat_import_qiime2_as_data_obj', 'mStat_import_mothur_as_data_obj', 'mStat_import_dada2_as_data_obj', and 'mStat_import_biom_as_data_obj'. Alternatively, users can construct their own data.obj. Note that not all components of data.obj may be required for all functions in the MicrobiomeStat package.

alpha.obj

An optional list containing pre-calculated alpha diversity indices. If NULL (default), alpha diversity indices will be calculated using mStat_calculate_alpha_diversity function from MicrobiomeStat package.

alpha.name

A string with the name of the alpha diversity index to compute. Options could include: "shannon", "simpson", "observed_species", "chao1", "ace", and "pielou".

depth

An integer specifying the sequencing depth for the "Rarefy" and "Rarefy-TSS" methods. If NULL, no rarefaction is performed.

time.var

Character string specifying the column name in metadata containing the numeric time variable.

subject.var

Character string specifying the column name in metadata containing unique subject IDs.

group.var

Character string specifying the column name in metadata containing grouping categories.

adj.vars

Character vector specifying column names in metadata containing covariates to adjust for.

Value

A list object containing the results of the trend test for each alpha diversity index specified in `alpha.name`. Each element of the list contains a summary table of the trend test results for a specific alpha diversity index.

Examples

if (FALSE) { # \dontrun{
# Load example data
data("subset_T2D.obj")

# Example 1: Test trend for multiple alpha indices with group and no adjustment
result1 <- generate_alpha_trend_test_long(
  data.obj = subset_T2D.obj,
  alpha.name = c("shannon", "observed_species"),
  time.var = "visit_number_num",
  subject.var = "subject_id",
  group.var = "subject_race"
)

# Example 2: Test trend for multiple alpha indices with group and adjustment for one covariate
result2 <- generate_alpha_trend_test_long(
  data.obj = subset_T2D.obj,
  alpha.name = c("shannon", "observed_species"),
  time.var = "visit_number_num",
  subject.var = "subject_id",
  group.var = "subject_race",
  adj.vars = "subject_gender"
)

# Example 3: Test trend for multiple alpha indices with group and adjustment for multiple covariates
result3 <- generate_alpha_trend_test_long(
  data.obj = subset_T2D.obj,
  alpha.name = c("shannon", "observed_species"),
  time.var = "visit_number_num",
  subject.var = "subject_id",
  group.var = "subject_race",
  adj.vars = c("subject_gender", "sample_body_site")
)

# Example 4: Test trend for multiple alpha indices without group
result4 <- generate_alpha_trend_test_long(
  data.obj = subset_T2D.obj,
  alpha.name = c("shannon", "observed_species"),
  time.var = "visit_number_num",
  subject.var = "subject_id"
)

# Example 5: Test trend for a single alpha index with group
result5 <- generate_alpha_trend_test_long(
  data.obj = subset_T2D.obj,
  alpha.name = "chao1",
  time.var = "visit_number_num",
  subject.var = "subject_id",
  group.var = "subject_race"
)

# Example 6: Test trend using pre-calculated alpha diversity
alpha.obj <- mStat_calculate_alpha_diversity(subset_T2D.obj$feature.tab,
c("shannon", "observed_species"))
result6 <- generate_alpha_trend_test_long(
  data.obj = subset_T2D.obj,
  alpha.obj = alpha.obj,
  time.var = "visit_number_num",
  subject.var = "subject_id",
  group.var = "subject_race"
)
} # }