server<-function(){
library(preciseR)
library(readxl)
library(purrr)
library(dplyr)
library(shiny)
library(DT)
GG <- new.env()
shinyServer(function(input, output, session) {
observeEvent(input$clear, {
GG <- new.env()
output$foo <- DT::renderDataTable({
NULL
})
})
observeEvent(list(input$target, input$Analyte), {
if (input$target == "LLOD") {
updateSelectInput(session,
"Plate",
choices = "Split",
selected = "Split")
}
if (input$target == "SSMD-Z'") {
if (input$Analyte == "OCR") {
updateSelectInput(session,
"Plate",
choices = "Split",
selected = "Split")
}
if (input$Analyte == "PER") {
updateSelectInput(session,
"Plate",
choices = "Whole",
selected = "Whole")
}
}
})
observeEvent(input$XL, {
GG$df <- filter(input$XL, grepl("xlsx$", name))
GG$xl <-
purrr::map(GG$df$datapath, readxl::read_xlsx, sheet = "Rate") %>% setNames(., GG$df$name)
assay <-
c(
preciseR::LLOD_output,
preciseR::whole_ssmdzprime_output,
preciseR::split_ssmdzprime_output
)[assay_index(input$target,input$Plate)]
GG$OUT <-
purrr::map_df(GG$xl, assay, rate = input$Analyte, .id = 'file')
print(GG$OUT)
output$foo <- DT::renderDataTable({
cbind(GG$OUT[, c(1, 2)],
round(GG$OUT[,-1 * c(1, 2)]))
})
output$downloadData <- downloadHandler(
filename = function() {
paste0(
input$target,
"_",
input$Analyte,
"_",
input$Plate,
"-plate",
"_",
Sys.Date(),
".csv"
)
},
content = function(file) {
write.csv(GG$OUT, file, row.names = FALSE)
}
)
})
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.