diff --git a/server.R b/server.R index 00dd22dc2035c2e96c9b9bc214c2d010c0e23b54..bcbb75f76a521fd577d3a4f431c554d9cadc1049 100644 --- a/server.R +++ b/server.R @@ -210,16 +210,66 @@ shinyServer "barGrid", label = "Subplot : ", choices = c("..." = 0, sample_variables(data16S())) - ) - , + ), selectInput( "barX", label = "X : ", choices = c("..." = 0, sample_variables(data16S())) + ), + box( + title = "RCode", + width = NULL, + status = "primary", + collapsible = TRUE, + collapsed = TRUE, + verbatimTextOutput("histScript") ) ) }) + output$histScript <- renderText({ + paste0( + "# Loading packages\n", + "source(\"https://raw.githubusercontent.com/mahendra-mariadassou/phyloseq-extended/master/R/load-extra-functions.R\")\n", + "\n", + "# Loading data\n", + paste0( + "load(\"", + paste("Easy16S-data", Sys.Date(), "RData", sep = "."), + "\") # if necessary, adapt the file path\n" + ), + "\n", + "# View data\n", + "data\n", + "\n", + "# Plot barplot\n", + "p <- plot_bar(physeq = data", + ifelse( + is.null(checkNull(input$barFill)), + "", + paste0(",\n fill = \"", input$barFill, "\"") + ), + ifelse(is.null(checkNull(input$barX)), "", paste0(",\n x = ", input$barX)), + ifelse( + is.null(checkNull(input$barTitle)), + "", + paste0(",\n title = \"", input$barTitle, "\"") + ), + ")\n", + ifelse( + is.null(checkNull(input$barGrid)), + "", + paste0( + "p <- p + facet_grid(\". ~ ", + input$barGrid, + "\", scales = \"free_x\")\n" + ) + ), + "\n", + "plot(p)" + ) + }) + output$histo <- renderPlot({ validate(need(data16S(), "Requires an abundance dataset")) @@ -854,7 +904,11 @@ shinyServer axes = as.numeric(input$acpAxes), title = checkNull(input$acpTitle), color = checkNull(input$acpCol), - replicate = if (is.null(checkNull(input$acpRep))) { NULL } else { checkNull(input$acpRep) }, + replicate = if (is.null(checkNull(input$acpRep))) { + NULL + } else { + checkNull(input$acpRep) + }, shape = checkNull(input$acpShape), label = checkNull(input$acpLabel) )