
Longitudinal Taxa Abundance Volatility Test
Source:R/generate_taxa_volatility_test_long.R
generate_taxa_volatility_test_long.RdCalculates and tests taxa abundance volatility (variability over time) between groups. Volatility is the mean absolute difference between consecutive time points, normalized by time difference.
Usage
generate_taxa_volatility_test_long(
data.obj,
time.var,
subject.var,
group.var,
adj.vars = NULL,
prev.filter = 0,
abund.filter = 0,
feature.level,
feature.dat.type = c("count", "proportion", "other"),
transform = "CLR",
...
)Arguments
- data.obj
A MicrobiomeStat data object, which is a list containing at minimum the following components:
feature.tab: A matrix of feature abundances (taxa/genes as rows, samples as columns)meta.dat: A data frame of sample metadata (samples as rows)
Optional components include:
feature.ann: A matrix/data frame of feature annotations (e.g., taxonomy)tree: A phylogenetic tree object (class "phylo")feature.agg.list: Pre-aggregated feature tables by taxonomy
Data objects can be created using converters like
mStat_convert_phyloseq_to_data_objor importers likemStat_import_qiime2_as_data_obj.- time.var
Character string specifying the column name in meta.dat containing the time variable. Required for longitudinal and paired analyses. Supports character/factor labels (e.g., "baseline", "week4") and numeric values. Some trend/volatility methods require numeric or coercible-to-numeric time values.
- subject.var
Character string specifying the column name in meta.dat that uniquely identifies each subject or sample unit. Required for longitudinal and paired designs to track repeated measurements.
- group.var
Character string specifying the column name in meta.dat containing the grouping variable (e.g., treatment, condition, phenotype). Used for between-group comparisons.
- adj.vars
Character vector specifying column names in meta.dat to be used as covariates for adjustment in statistical models. These variables will be included as fixed effects.
- prev.filter
Numeric value between 0 and 1. Features with prevalence (proportion of non-zero samples) below this threshold will be excluded from analysis. Default is usually 0 (no filtering).
- abund.filter
Numeric value. Features with mean abundance below this threshold will be excluded from analysis. Default is usually 0 (no filtering).
- feature.level
Character vector specifying the taxonomic or annotation level(s) for analysis. Should match column names in feature.ann, such as "Phylum", "Family", "Genus", etc. Use "original" to analyze at the original feature level without aggregation.
- feature.dat.type
Character string specifying the data type of feature.tab. One of:
"count": Raw count data (will be normalized)
"proportion": Relative abundance data (should sum to 1 per sample)
"other": Pre-transformed data (no transformation applied)
- transform
Character; transformation method before volatility calculation. "CLR" applies CLR transform (default). Any other value skips CLR and uses filtered abundance values directly.
- ...
Additional arguments passed to other methods.
Value
A nested list structure where:
First level: Named by
feature.level(e.g., "Phylum", "Genus")Second level: Named by tested comparisons between groups (e.g., "Level vs Reference (Reference)")
Each element is a data.frame with the following columns:
Variable: Feature/taxon nameCoefficient: Effect size for volatility differences between groupsSE: Standard error of the coefficient from the linear modelP.Value: Raw p-value from standard linear model (lm)Adjusted.P.Value: FDR-adjusted p-value (Benjamini-Hochberg)Mean.Abundance: Mean abundance across all samplesPrevalence: Proportion of samples where feature is present (non-zero)
This function analyzes VOLATILITY (variability over time) using standard linear models, NOT LinDA. Volatility is calculated as mean absolute differences between consecutive time points.
Examples
if (FALSE) { # \dontrun{
data("subset_T2D.obj")
test.list <- generate_taxa_volatility_test_long(
data.obj = subset_T2D.obj,
time.var = "visit_number",
subject.var = "subject_id",
group.var = "subject_race",
adj.vars = "sample_body_site",
prev.filter = 0.1,
abund.filter = 0.0001,
feature.level = c("Genus"),
feature.dat.type = "count",
transform = "CLR"
)
plot.list <- generate_taxa_volatility_volcano_long(data.obj = subset_T2D.obj,
group.var = "subject_race",
test.list = test.list,
feature.sig.level = 0.1,
feature.mt.method = "none")
data("ecam.obj")
test.list <- generate_taxa_volatility_test_long(
data.obj = ecam.obj,
time.var = "month_num",
subject.var = "subject.id",
group.var = "antiexposedall",
adj.vars = "delivery",
prev.filter = 0.1,
abund.filter = 0.0001,
feature.level = c("Order", "Family", "Genus"),
feature.dat.type = "proportion",
transform = "CLR"
)
plot.list <- generate_taxa_volatility_volcano_long(
data.obj = ecam.obj,
group.var = "antiexposedall",
test.list = test.list,
feature.sig.level = 0.2,
feature.mt.method = "none"
)
} # }