Commit cd0425d5 authored by Midoux Cedric's avatar Midoux Cedric
Browse files

first test on ACP_plot

No related merge requests found
Showing with 93 additions and 23 deletions
+93 -23
...@@ -1246,10 +1246,101 @@ shinyServer ...@@ -1246,10 +1246,101 @@ shinyServer
label = "Barycenters : ", label = "Barycenters : ",
choices = c("..." = 0, sample_variables(data16S())) choices = c("..." = 0, sample_variables(data16S()))
), ),
collapsedBox(verbatimTextOutput("acpScript"), title = "RCode") collapsedBox(verbatimTextOutput("acpScript"), title = "RCode"),
actionButton("downloadSetting", label = "Download plot")
) )
}) })
observeEvent(input$downloadSetting, {
showModal(
modalDialog(
title = "Setting of downloading plot",
textInput(
"plotName",
label = "Plot name : ",
value = "Easy16S-plot"
),
numericInput(
"plotWidth",
label = "Plot width (cm) : ",
value = 20,
min = 1,
max = 100
),
numericInput(
"plotHeight",
label = "Plot height (cm) : ",
value = 20,
min = 1,
max = 100
),
numericInput(
"plotDPI",
label = "Plot resolution : ",
value = 300,
min = 70,
max = 500,
step = 10
),
selectInput(
"plotDevice",
label = "Plot device : ",
choices = list("eps", "ps", "tex", "pdf", "jpeg", "tiff", "png", "bmp", "svg"),
selected = "png"
),
size = "s",
easyClose = TRUE,
footer = downloadButton(outputId = "downloadPlot", label = "Download the plot")
)
)
})
output$downloadPlot <- {
downloadHandler(
filename = function() {
paste(input$plotName, input$plotDevice, sep = ".")
},
content = function(file) {
ggsave(
file,
plot = plotInputACP(),
device = input$plotDevice,
units = "cm",
width = input$plotWidth,
height = input$plotHeight,
dpi = input$plotDPI,
limitsize = FALSE
)
}
)
}
plotInputACP <- function()
{
p <- plot_samples(
data16S(),
ordination = ordinate(
data16S(),
method = input$acpMethod,
distance = input$acpDist
),
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)
},
shape = checkNull(input$acpShape),
label = checkNull(input$acpLabel)
)
if (!is.null(checkNull(input$acpEllipse))) {
p <- p + stat_ellipse(aes_string(group = input$acpEllipse))
}
return(p + theme_bw())
}
output$acpScript <- renderText({ output$acpScript <- renderText({
scriptArgs <- c( scriptArgs <- c(
"physeq = data", "physeq = data",
...@@ -1298,27 +1389,6 @@ shinyServer ...@@ -1298,27 +1389,6 @@ shinyServer
need(data16S(), "Requires an abundance dataset"), need(data16S(), "Requires an abundance dataset"),
need(length(input$acpAxes) == 2, "Requires two projections axes") need(length(input$acpAxes) == 2, "Requires two projections axes")
) )
p <- plot_samples( plotInputACP()
data16S(),
ordination = ordinate(
data16S(),
method = input$acpMethod,
distance = input$acpDist
),
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)
},
shape = checkNull(input$acpShape),
label = checkNull(input$acpLabel)
)
if (!is.null(checkNull(input$acpEllipse))) {
p <- p + stat_ellipse(aes_string(group = input$acpEllipse))
}
return(p + theme_bw())
}) })
}) })
Supports Markdown
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