david-barnett / microViz

R package for microbiome data visualization and statistics. Uses phyloseq, vegan and the tidyverse. Docker image available.
https://david-barnett.github.io/microViz/
GNU General Public License v3.0
101 stars 11 forks source link

Output from taxatree_models not matching corncob::differentialTest() #104

Closed wilhelmsjoland closed 1 year ago

wilhelmsjoland commented 1 year ago

Hello, thank you for creating this great package.

I really like the heat-tree plots from taxatree_plots() so I used type = corncob::bbdml with the taxatree_models() function. Although, when comparing the results from microViz and running it straight into corncob::differentialTest() I get slightly different results.

E.g.

model <- test %>%
    taxatree_models(
        type = corncob::bbdml,
        rank = "Genus",
        formula = ~ Knockout + Female,
    )  %>% 
    taxatree_models2stats(param = "mu") %>%
    # with or without p-adjustment it doesn't match corncob::differential test
    taxatree_stats_p_adjust(method = "fdr", grouping = "taxon", new_var = "p.adj.signif") 

# compared to

model2 <- corncob::differentialTest(formula = ~ Knockout + Female,
                          phi.formula = ~ 1,
                          formula_null = ~ 1,
                          phi.formula_null = ~ 1,
                          data = otu_table(test),
                          sample_data = sample_data(test),
                          test = "Wald",
                          boot = FALSE,
                          fdr = "fdr",
                          fdr_cutoff = 0.05,
                          rownames = "Genus")

Shouldn’t they essentially be the same? How is microViz calling bbdml?

EDIT: I read up on the difference between bbdml and differentialTest so I got my answer there.

Thank you!