Commit a8a1caf3 authored by Midoux Cedric's avatar Midoux Cedric

panel/histo

parent b4992de1
output$histUI <- renderUI({
validate(need(data16S(), ""))
box(
title = "Setting : ",
width = NULL,
status = "primary",
radioButtons(
"barFill",
label = "Taxonomic rank : ",
choices = rank_names(data16S()),
inline = TRUE
),
textInput("barTitle",
label = "Title : ",
value = "OTU abundance barplot"),
selectInput(
"barGrid",
label = "Subplot : ",
choices = c("..." = 0, sample_variables(data16S()))
),
selectInput(
"barX",
label = "X : ",
choices = c("..." = 0, sample_variables(data16S()))
),
collapsedBox(verbatimTextOutput("histScript"), title = "RCode")
)
})
output$histScript <- renderText({
scriptArgs <- c("physeq = data",
glue("fill = \"{input$barFill}\""))
if (!is.null(checkNull(input$barX))) {
scriptArgs <- c(scriptArgs, glue("x = \"{input$barX}\""))
}
if (!is.null(checkNull(input$barTitle))) {
scriptArgs <- c(scriptArgs, glue("title = \"{input$barTitle}\""))
}
script <- c(
scriptHead,
"# Plot barplot",
glue("p <- plot_bar({glue_collapse(scriptArgs, sep=', ')})")
)
if (!is.null(checkNull(input$barGrid))) {
script <- c(script,
glue(
"p <- p + facet_grid(\". ~ {input$barGrid}\", scales = \"free_x\")"
))
}
script <- c(script, "", "plot(p)")
return(glue_collapse(script, sep = "\n"))
})
output$histo <- renderPlot({
validate(need(data16S(),
"Requires an abundance dataset"))
p <- plot_bar(
physeq = data16S(),
fill = input$barFill,
x = ifelse(is.null(checkNull(input$barX)), "Sample", input$barX),
title = checkNull(input$barTitle)
)
if (!is.null(checkNull(input$barGrid))) {
p <-
p + facet_grid(paste(".", "~", input$barGrid), scales = "free_x")
}
return(p)
})
histo <- fluidPage(withLoader(plotOutput("histo", height = 700)),uiOutput("histUI"))
......@@ -8,6 +8,8 @@ library(factoextra)
shinyServer
(function(input, output, session)
{
source("panels/histo-server.R", local = TRUE)
checkNull <- function(x) {
if (!exists(as.character(substitute(x)))) {
return(NULL)
......@@ -239,76 +241,6 @@ shinyServer
beautifulTable(joinGlom)
})
output$histUI <- renderUI({
validate(need(data16S(), ""))
box(
title = "Setting : ",
width = NULL,
status = "primary",
radioButtons(
"barFill",
label = "Taxonomic rank : ",
choices = rank_names(data16S()),
inline = TRUE
),
textInput("barTitle",
label = "Title : ",
value = "OTU abundance barplot"),
selectInput(
"barGrid",
label = "Subplot : ",
choices = c("..." = 0, sample_variables(data16S()))
),
selectInput(
"barX",
label = "X : ",
choices = c("..." = 0, sample_variables(data16S()))
),
collapsedBox(verbatimTextOutput("histScript"), title = "RCode")
)
})
output$histScript <- renderText({
scriptArgs <- c("physeq = data",
glue("fill = \"{input$barFill}\""))
if (!is.null(checkNull(input$barX))) {
scriptArgs <- c(scriptArgs, glue("x = \"{input$barX}\""))
}
if (!is.null(checkNull(input$barTitle))) {
scriptArgs <- c(scriptArgs, glue("title = \"{input$barTitle}\""))
}
script <- c(
scriptHead,
"# Plot barplot",
glue("p <- plot_bar({glue_collapse(scriptArgs, sep=', ')})")
)
if (!is.null(checkNull(input$barGrid))) {
script <- c(script,
glue(
"p <- p + facet_grid(\". ~ {input$barGrid}\", scales = \"free_x\")"
))
}
script <- c(script, "", "plot(p)")
return(glue_collapse(script, sep = "\n"))
})
output$histo <- renderPlot({
validate(need(data16S(),
"Requires an abundance dataset"))
p <- plot_bar(
physeq = data16S(),
fill = input$barFill,
x = ifelse(is.null(checkNull(input$barX)), "Sample", input$barX),
title = checkNull(input$barTitle)
)
if (!is.null(checkNull(input$barGrid))) {
p <-
p + facet_grid(paste(".", "~", input$barGrid), scales = "free_x")
}
return(p)
})
output$histFocusUIfocusRank <- renderUI({
validate(need(data16S(), ""))
radioButtons(
......
library(shinydashboard)
library(shinycustomloader)
source("panels/histo-ui.R", local = TRUE)
shinyUI(dashboardPage(
dashboardHeader(title = "Easy16S"),
......@@ -101,8 +102,7 @@ shinyUI(dashboardPage(
)
),
tabPanel("Global barplot",
withLoader(plotOutput("histo", height = 700)),
uiOutput("histUI")),
histo),
tabPanel(
"Filtered barplot",
withLoader(plotOutput("histFocus", height = 700)),
......
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