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

Description Usage Arguments Details Value Note References Examples

View source: R/bb_mods.R

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

1
2
3
4
5
6
7
8
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

Details

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

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)

Note

False Discovery Rate p-values are calculated using p.adjust. Estimated rate ratios and confidence intervals for interactions in the Estimate_Summary table include all main effects. It is not simply the exponentiated interaction beta, it is the interaction of the sum of the intercept, corresponding main effect betas, and interaction betas

References

anova.vglm, vglm, betabinomial

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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


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

tidyMicro documentation built on Jan. 13, 2021, 6:18 a.m.