Skip to contents

This function conducts association tests for multiple alpha diversity indices using linear model analyses. It can be applied to cross-sectional data, a single time point from longitudinal or paired data. It takes a data object as input and returns a list of association tests for each specified alpha diversity index.

Usage

generate_alpha_test_single(
  data.obj,
  alpha.obj = NULL,
  alpha.name = NULL,
  depth = NULL,
  time.var = NULL,
  t.level = NULL,
  group.var,
  adj.vars
)

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

character vector containing the names of alpha diversity indices to calculate. Possible values are: "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 time variable. Used to subset to a single time point if provided. Default NULL does not subset data.

t.level

Character string specifying the time level/value to subset data to, if a time variable is provided. Default NULL does not subset data.

group.var

Character string specifying the column name in metadata containing the grouping variable. Used as a predictor in the linear models.

adj.vars

Character vector specifying column names in metadata containing variables to adjust for in the linear models.

Value

A list containing the association tests for each alpha diversity index. Each element in the list corresponds to a different alpha diversity index, and contains a dataframe with the linear model's coefficients, standard errors, t values, and p values.

Examples

if (FALSE) { # \dontrun{
data("subset_T2D.obj")
# Example where alpha diversity indices are calculated beforehand
alpha.obj <- mStat_calculate_alpha_diversity(subset_T2D.obj$feature.tab,
                                             c("shannon", "observed_species"))
generate_alpha_test_single(data.obj = subset_T2D.obj,
                           alpha.obj = alpha.obj,
                           alpha.name = c("shannon", "observed_species", "ace"),
                           time.var = "visit_number",
                           t.level = NULL,
                           group.var = "subject_race",
                           adj.vars = "subject_gender")

# Example where alpha diversity indices are calculated within the function
generate_alpha_test_single(data.obj = subset_T2D.obj,
                           time.var = "visit_number",
                           t.level = "4",
                           alpha.name = c("shannon", "observed_species"),
                           group.var = "subject_race",
                           adj.vars = "subject_gender")

data("peerj32.obj")
generate_alpha_test_single(data.obj = peerj32.obj,
                           time.var = "time",
                           t.level = "1",
                           alpha.name = c("shannon", "observed_species"),
                           group.var = "group",
                           adj.vars = "sex")
generate_alpha_test_single(data.obj = peerj32.obj,
                           time.var = "time",
                           t.level = "1",
                           alpha.name = c("shannon", "observed_species"),
                           group.var = "group",
                           adj.vars = NULL)
} # }