Learn R Programming

tidyMicro (version 1.47)

micro_chisq: Run Chi-Squared tests for each taxa

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

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

Value

A data from containing the taxa, the chi-squared statistic, and the p-value of the 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

References

help(chisq.test)

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab