Commit 9ad33f01 authored by mahendra-mariadassou's avatar mahendra-mariadassou
Browse files

Add pairwise compairison in alpha-diversity ANOVA

parent 540cdc77
......@@ -136,7 +136,7 @@ output$alphaAnovaUI <- renderUI({
)
})
output$alphaAnova <- renderPrint({
model <- reactive({
validate(
need(physeq(), "Requires an abundance dataset"),
need(input$anovaRichnessMeasure, ""),
......@@ -145,8 +145,28 @@ output$alphaAnova <- renderPrint({
anova_data <- cbind(estimate_richness(physeq(), measures = input$anovaRichnessMeasure),
as(sample_data(physeq()), "data.frame"))
formula <- paste0(input$anovaRichnessMeasure, " ~ ", input$anovaCovariate)
model <- do.call("lm", list(formula = as.formula(formula), data = as.name("anova_data")))
print(model)
anova(model)
do.call("lm", list(formula = as.formula(formula), data = as.name("anova_data")))
})
output$alphaAnova <- renderPrint({
validate(need(model(), ""))
print(model())
anova(model())
})
output$anovaHSD <- DT::renderDT({
validate(
need(model(), ""),
need(physeq(), "Requires an abundance dataset"),
need(input$anovaRichnessMeasure, ""),
need(input$anovaCovariate, "Select a covariate")
)
var <- get_variable(physeq(), input$anovaCovariate)
if (! (is.factor(var) || is.character(var))) {
tibble::tibble(.rows = 0)
} else {
TukeyHSD(aov(model()))[[1]] %>% as_tibble(rownames = "Pair") %>%
beautifulTable() %>%
DT::formatSignif(columns = c("diff", "lwr", "upr", "p adj"), digits = 4)
}
})
......@@ -2,5 +2,12 @@ alphaPlot <- fluidPage(outputCodeButton(withLoader(plotOutput("alphaPlot", heigh
uiOutput("alphaPlotUI"))
alphaTable <- fluidPage(uiOutput("alphaTable"))
alphaAnova <- fluidPage(uiOutput("alphaAnovaUI"),
verbatimTextOutput("alphaAnova")
verbatimTextOutput("alphaAnova"),
box(
title = "Table of pairwise comparisons",
width = NULL,
status = "primary",
collapsible = TRUE,
collapsed = TRUE,
DT::DTOutput("anovaHSD"))
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment