diff --git a/server.R b/server.R index b144d0fd770f1fbb80a648ab54ff85f0086af8d3..1b68bbd0fbb72b64a62b1577934dff992bd9592f 100644 --- a/server.R +++ b/server.R @@ -762,7 +762,6 @@ shinyServer color = "gray60") } return(p + ggtitle(input$rarefactionTitle)) - }) output$rarefactionCurveUI <- renderUI({ @@ -796,8 +795,47 @@ shinyServer "rarefactionGrid", label = "Subplot : ", choices = c("..." = 0, sample_variables(data16S())) - ) + ), + collapsedBox(verbatimTextOutput("rarefactionCurveScript"), title = "RCode") + ) + }) + + output$rarefactionCurveScript <- renderText({ + scriptArgs <- c("physeq = data", + "step = 100", + "se = FALSE") + if (!is.null(checkNull(input$rarefactionColor))) { + scriptArgs <- + c(scriptArgs, + glue("color = \"{input$rarefactionColor}\"")) + } + if (!is.null(checkNull(input$rarefactionLabel))) { + scriptArgs <- + c(scriptArgs, + glue("label = \"{input$rarefactionLabel}\"")) + } + script <- c( + scriptHead, + "# Plot filtered barplot", + glue("p <- ggrare({glue_collapse(scriptArgs, sep=', ')})") ) + if (!is.null(checkNull(input$rarefactionGrid))) { + script <- c(script, + glue("p <- p + facet_grid(\". ~ {input$rarefactionGrid}\")")) + } + if (input$rarefactionMin) { + script = c( + script, + "p <- p + geom_vline(xintercept = min(sample_sums(data)), color = \"gray60\")" + ) + } + if (!is.null(checkNull(input$rarefactionTitle))) { + script <- c(script, + glue("p <- p + ggtitle({input$rarefactionTitle})")) + } + script <- c(script, "", "plot(p)") + + return(glue_collapse(script, sep = "\n")) }) output$HeatmapUI <- renderUI({