Learn R Programming

tidyMicro (version 1.47)

bb_mods: Fit beta binomial models to each taxa within an OTU table

Description

Fit beta binomial models to each taxa within an OTU table through vglm in the VGAM package. Summaries for models or confidence intervals that fail to converge will not be returned, but taxa summaries will be provided in the output. Rank-Sum tests or presence/absence tests can be run on these taxa using tidi_rank_sum or tidi_chisq, respectively

Usage

bb_mods(
  micro_set,
  table,
  ...,
  CI_method = c("wald", "profile"),
  SS_type = c(2, 3, "II", "III"),
  trace = FALSE
)

Arguments

micro_set

A tidy_micro data set

table

OTU table of interest

...

Covariates of interest. Can be interactions such as Group*Age

CI_method

Character indicating the type of method used for confidence interval estimation. Wald intervals are the current default. Abbreviations allowed. See confintvglm for more details

SS_type

Type of sums of squares calculated in anova.vglm. Either type II (2) or type III (3) sums of squares. Type II is the default

trace

Print messages of model fitting proceedure

Value

A list containing several different model components and summaries

Convergend_Summary

A data.frame of model summaries from convergent models. Includes the Taxa name, the model coefficient, the estimated beta, the beta's 95 percent confidence interval, Z score, p_value, false discovery rate p-value, and p-value from likelihood ratio test

Estimate_Summary

A data.frame of model estimates from convergent models intended to be ready for export for publications. Includes the Taxa name, the model coefficient, the estimated Rate Ratio, the Wald 95 percent confidence interval, the Z-score, and false discovery rate p-value

RA_Summary

A data.frame of taxa summaries. Includes the Taxa name, grouping variables (each factor variable in your models), sample size (n), percent of 0 counts, basic summaries of relative abundance, percentiles of relative abundance, and a logical indicator of whether or not the model converged

formula

The formula used in the model

Model_Coef

Model coefficients (used in plotting funcitons)

Model_Covs

Model covariates (used in plotting functions)

Details

Models containing only fixed effects are fit using vglm in the VGAM package. ANOVA / ANCOVA tests are conducted using a Likelihood Ratio test

References

anova.vglm, vglm, betabinomial

Examples

Run this code
# NOT RUN {
data(bpd_phy); data(bpd_cla); data(bpd_ord); data(bpd_fam); data(bpd_clin)

otu_tabs <- list(Phylum = bpd_phy, Class = bpd_cla,
Order = bpd_ord, Family = bpd_fam)
set <- tidy_micro(otu_tabs = otu_tabs, clinical = bpd_clin) %>%
  filter(day == 7) ## Only including first week

# }
# NOT RUN {
bb_phy <- set %>%

## Filtering out low abundance and unclassified taxa
## These models will either break or we don't care about them
otu_filter(prev_cutoff = 5, ra_cutoff = 0.1,
           exclude_taxa = c("Unclassified", "Bacteria")) %>%

## Beta binomial models for each Family of taxa with bpd1 as a covariate
bb_mods(table = "Phylum", bpd1, CI_method = "wald")

names(bb_phy)
bb_phy$Estimate_Summary
# }

Run the code above in your browser using DataLab