From d462227a85025774ade5e8f67b1edff72d7f8e4a Mon Sep 17 00:00:00 2001
From: Cedric Midoux <cedric.midoux@inra.fr>
Date: Tue, 11 Sep 2018 11:16:59 +0200
Subject: [PATCH] histFocusScript
---
server.R | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
ui.R | 13 ++----------
2 files changed, 60 insertions(+), 16 deletions(-)
diff --git a/server.R b/server.R
index cf4a028..21f8e84 100644
--- a/server.R
+++ b/server.R
@@ -28,7 +28,7 @@ shinyServer
options = list(
dom = "lBtip",
pageLength = 10,
- lengthMenu = list(c(10, 25, 50, 100, -1), list('10', '25', '50', '100', 'All')),
+ lengthMenu = list(c(10, 25, 50, 100,-1), list('10', '25', '50', '100', 'All')),
buttons = list(
'colvis',
list(
@@ -293,7 +293,8 @@ shinyServer
})
output$histFocusUIfocusTaxa <- renderUI({
- validate(need(data16S(), ""))
+ validate(need(data16S(), ""),
+ need(input$focusRank, ""))
selectInput(
"focusTaxa",
label = "Selected taxa : ",
@@ -330,9 +331,61 @@ shinyServer
choices = c("..." = 0, sample_variables(data16S())))
})
- output$histoFocus <- renderPlot({
- validate(need(data16S(),
- "Requires an abundance dataset"))
+ output$histFocusUI <- renderUI({
+ validate(need(data16S(), ""))
+ box(
+ title = "Setting : ",
+ width = NULL,
+ status = "primary",
+ uiOutput("histFocusUIfocusRank"),
+ uiOutput("histFocusUIfocusTaxa"),
+ uiOutput("histFocusUIfocusNbTaxa"),
+ uiOutput("histFocusUIfocusGrid"),
+ uiOutput("histFocusUIfocusX"),
+ collapsedBox(verbatimTextOutput("histFocusScript"), title = "RCode")
+ )
+ })
+
+ output$histFocusScript <- renderText({
+ paste0(
+ scriptHead,
+ "# Plot filtered barplot\n",
+ "p <- plot_composition(physeq = data",
+ glue(", taxaRank1 = \"{input$focusRank}\""),
+ glue(", taxaSet1 = \"{input$focusTaxa}\""),
+ glue(
+ ", taxaRank2 = \"{rank_names(data16S())[which(rank_names(data16S()) == input$focusRank) + 1]}\""
+ ),
+ glue(", numberOfTaxa = {input$focusNbTaxa}"),
+ glue(
+ ", fill = \"{rank_names(data16S())[which(rank_names(data16S()) == input$focusRank) + 1]}\""
+ ),
+ ifelse(is.null(checkNull(input$focusX)),
+ "",
+ glue(", x = \"{input$focusX}\"")),
+ ")\n",
+ ifelse(
+ is.null(checkNull(input$focusGrid)),
+ "",
+ glue(
+ "p <- p + facet_grid(\". ~ {input$focusGrid}\", scales = \"free_x\")"
+ )
+ ),
+ ###
+ # x = ifelse(is.null(checkNull(input$focusX)), "Sample", input$focusX)
+ ###
+ "\n",
+ "plot(p)"
+ )
+ })
+
+ output$histFocus <- renderPlot({
+ validate(
+ need(data16S(),
+ "Requires an abundance dataset"),
+ need(input$focusRank, ""),
+ need(input$focusTaxa, "")
+ )
p <- plot_composition(
physeq = data16S(),
taxaRank1 = input$focusRank,
diff --git a/ui.R b/ui.R
index cd24170..94de056 100644
--- a/ui.R
+++ b/ui.R
@@ -104,17 +104,8 @@ shinyUI(dashboardPage(
uiOutput("histUI")),
tabPanel(
"Filtered barplot",
- withLoader(plotOutput("histoFocus", height = 700)),
- box(
- title = "Paramètres",
- width = NULL,
- status = "primary",
- uiOutput("histFocusUIfocusRank"),
- uiOutput("histFocusUIfocusTaxa"),
- uiOutput("histFocusUIfocusNbTaxa"),
- uiOutput("histFocusUIfocusGrid"),
- uiOutput("histFocusUIfocusX")
- )
+ withLoader(plotOutput("histFocus", height = 700)),
+ uiOutput("histFocusUI")
),
tabPanel("Heatmap",
withLoader(plotOutput("Heatmap", height = 700)),
--
GitLab