Commit 8e7823c5 authored by mahendra-mariadassou's avatar mahendra-mariadassou
Browse files

Add anova module for alpha diversity

parent cdd02021
......@@ -62,15 +62,15 @@ output$alphaPlotUI <- renderUI({
output$alphaPlot <- metaRender2(renderPlot, {
validate(need(physeq(), "Requires an abundance dataset"))
data <- physeq()
alphaPlot_boxplot <- if (input$richnessBoxplot >= 2) {
metaExpr({geom_boxplot()})
}
alphaPlot_point <- if (input$richnessBoxplot <= 2) {
metaExpr({geom_point()})
}
metaExpr({
p <- plot_richness(
physeq = data,
......@@ -106,3 +106,47 @@ output$alphaTable <- renderUI({
beautifulTable(tibble::rownames_to_column(round(estimate_richness(physeq()), digits = 2), var = "SAMPLE"))
)
})
output$alphaAnovaUI <- renderUI({
validate(need(physeq(), "Requires an abundance dataset"))
box(
title = "Alpha diversity Anova analysis",
width = NULL,
status = "primary",
selectInput(
inputId = "anovaRichnessMeasure",
label = "Richness measure : ",
choices = c(
"Observed",
"Chao1",
"ACE",
"Shannon",
"Simpson",
"InvSimpson",
"Fisher"
),
selected = "Observed",
multiple = FALSE
),
selectInput(
inputId = "anovaCovariate",
label = "Covariate : ",
choices = c(sample_variables(physeq()))
)
)
})
output$alphaAnova <- renderPrint({
validate(
need(physeq(), "Requires an abundance dataset"),
need(input$anovaRichnessMeasure, ""),
need(input$anovaCovariate, "Select a covariate")
)
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)
})
alphaPlot <- fluidPage(outputCodeButton(withLoader(plotOutput("alphaPlot", height = 700))),
uiOutput("alphaPlotUI"))
alphaTable <- fluidPage(uiOutput("alphaTable"))
alphaAnova <- fluidPage(uiOutput("alphaAnovaUI"),
verbatimTextOutput("alphaAnova")
)
......@@ -17,18 +17,18 @@ source("panels/Help-ui.R", local = TRUE)
shinyUI(dashboardPage(
dashboardHeader(title = "Easy16S"),
dashboardSidebar(
actionButton("dataButton",
"Select your data",
actionButton("dataButton",
"Select your data",
icon = icon("upload"),
width = 200
),
actionButton("filterButton",
actionButton("filterButton",
"Select some samples",
icon = icon("filter"),
width = 200
),
actionButton("transformButton",
"Transform abundance",
actionButton("transformButton",
"Transform abundance",
icon = icon("square-root-alt"),
width = 200
),
......@@ -39,13 +39,13 @@ dashboardHeader(title = "Easy16S"),
size = "mini",
width = 200
),
actionButton("downloadButton",
"Download data",
actionButton("downloadButton",
"Download data",
icon = icon("download"),
width = 200
),
actionButton("plotButton",
"Download last plot",
actionButton("plotButton",
"Download last plot",
icon = icon("file-image"),
width = 200
),
......@@ -62,7 +62,8 @@ dashboardHeader(title = "Easy16S"),
menuItem("Rarefaction curves", tabName = "rarefactionCurve", icon = icon("chart-line")),
menuItem(HTML("&alpha;-diversity"), icon = icon("th"),
menuSubItem("Plots", tabName = "alphaPlot"),
menuSubItem("Table", tabName = "alphaTable")
menuSubItem("Table", tabName = "alphaTable"),
menuSubItem("ANOVA", tabName = "alphaAnova")
),
menuItem(HTML("&beta;-diversity"), icon = icon("th"),
selectInput("betaDistance",
......@@ -92,6 +93,7 @@ dashboardHeader(title = "Easy16S"),
tabItem(tabName = "rarefactionCurve", rarefactionCurve),
tabItem(tabName = "alphaPlot", alphaPlot),
tabItem(tabName = "alphaTable", alphaTable),
tabItem(tabName = "alphaAnova", alphaAnova),
tabItem(tabName = "betaMds", betaMds),
tabItem(tabName = "betaCluster", betaCluster),
tabItem(tabName = "betaManova", betaManova),
......
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