micro_chisq: Run Chi-Squared tests for each taxa

Description Usage Arguments Details Value References Examples

View source: R/micro_chisq.R

Description

Run Chi-Squared tests for presence / absence of each taxa in you data set, or each taxa that didn't converge in negative binomial models

Usage

1
micro_chisq(micro_set, table, grp_var, y = bin, mod = NULL, ...)

Arguments

micro_set

A tidy_micro data set

table

The OTU table you'd like to test

grp_var

Grouping variable for chi-squared test

y

Response variable for chi-squared test. Default is presence / absence (bin)

mod

The output from mods if you'd like to only run on taxa that did not converge

...

Options to be passed to chisq.test

Details

If the taxa are present or absent in every subject the chi-sqared test will not but run. The returned chi-sqared stat will either be "All Absent" or "All Present." This will be clear in the output

Value

A data from containing the taxa, the chi-squared statistic, and the p-value of the test.

References

help(chisq.test)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(bpd_cla); data(bpd_clin)

set <- tidy_micro(otu_tabs = bpd_cla, tab_names = "Class", clinical = bpd_clin,
prev_cutoff = 5, ra_cutoff = 0.1, exclude_taxa = c("Unclassified", "Bacteria")) %>%
filter(day == 7) ## Only including the first week

## Chi-squared test on every taxa's presence/absence
set %>% micro_chisq(table = "Class", grp_var = bpd1,
simulate.p.value = TRUE)

## Chi-squared test on every taxa whose model didn't converge
nb_cla <- set %>% nb_mods(table = "Class", bpd1)

micro_chisq(micro_set = set, table = "Class", grp_var = bpd1,
mod = nb_cla, simulate.p.value = TRUE)

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