Generate Beta Diversity Volatility Test for Longitudinal Data
Source:R/generate_beta_volatility_test_long.R
generate_beta_volatility_test_long.Rd
This function computes a volatility test for longitudinal data on beta diversity. It tests the association between beta diversity volatility and the specified group variable.
Usage
generate_beta_volatility_test_long(
data.obj,
dist.obj = NULL,
subject.var,
time.var,
group.var = NULL,
adj.vars = NULL,
dist.name = c("BC"),
...
)
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.
- dist.obj
Distance matrix between samples, usually calculated using
mStat_calculate_beta_diversity
function. If NULL, beta diversity will be automatically computed fromdata.obj
usingmStat_calculate_beta_diversity
.- subject.var
A string indicating the column name in the metadata table that represents the subject.
- time.var
A string indicating the column name in the metadata table that represents the time. Ensure that it is coded as numeric.
- group.var
(Optional) A string indicating the column name in the metadata table that represents the grouping factor.
- adj.vars
(Optional) A character vector specifying the column names in the metadata table used for adjustment.
- dist.name
A character vector specifying which beta diversity indices to calculate. Default is "BC" (Bray-Curtis).
- ...
(Optional) Additional arguments to pass to internal functions.
Value
A list containing the result of the volatility test for each specified beta diversity index. Each element in the list is a tibble with the coefficients extracted from the linear model fitted for each distance, and an ANOVA table if the group variable is multi-categorical.
Details
The function starts by validating the input data, processing the time variable, and calculating the beta diversity if necessary. Adjustments are made based on the provided adjusting variables. The volatility of the beta diversity is computed for each subject, and linear models are fitted to test the association between volatility and the specified group variable. The coefficients and ANOVA results are extracted and returned for each beta diversity index specified.
Note
A warning message will be displayed to ensure that the time variable is coded as numeric. Non-numeric coding may lead to issues in the volatility test computation.
Examples
if (FALSE) { # \dontrun{
data(ecam.obj)
generate_beta_volatility_test_long(
data.obj = ecam.obj,
dist.obj = NULL,
subject.var = "studyid",
time.var = "month_num",
t0.level = NULL,
ts.levels = NULL,
group.var = "diet",
adj.vars = NULL,
dist.name = c("BC", "Jaccard")
)
data(subset_T2D.obj)
generate_beta_volatility_test_long(
data.obj = subset_T2D.obj,
dist.obj = NULL,
subject.var = "subject_id",
time.var = "visit_number_num",
t0.level = NULL,
ts.levels = NULL,
group.var = "subject_race",
adj.vars = NULL,
dist.name = c("BC", "Jaccard")
)
} # }