mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 19:27:24 +01:00
results: Add download button
This commit is contained in:
parent
7834360e2a
commit
c8e1e311dc
1 changed files with 57 additions and 41 deletions
98
R/results.R
98
R/results.R
|
|
@ -4,7 +4,11 @@ results_ui <- function(id) {
|
||||||
verticalLayout(
|
verticalLayout(
|
||||||
div(
|
div(
|
||||||
style = "margin-top: 16px",
|
style = "margin-top: 16px",
|
||||||
uiOutput(NS(id, "copy")),
|
splitLayout(
|
||||||
|
cellWidths = "auto",
|
||||||
|
uiOutput(NS(id, "copy")),
|
||||||
|
downloadButton(NS(id, "download"), "Download CSV")
|
||||||
|
)
|
||||||
),
|
),
|
||||||
div(
|
div(
|
||||||
style = "margin-top: 16px",
|
style = "margin-top: 16px",
|
||||||
|
|
@ -21,46 +25,6 @@ results_ui <- function(id) {
|
||||||
#' @noRd
|
#' @noRd
|
||||||
results_server <- function(id, filtered_results) {
|
results_server <- function(id, filtered_results) {
|
||||||
moduleServer(id, function(input, output, session) {
|
moduleServer(id, function(input, output, session) {
|
||||||
output$genes <- DT::renderDT({
|
|
||||||
columns <- c(
|
|
||||||
"rank",
|
|
||||||
"gene",
|
|
||||||
"name",
|
|
||||||
"chromosome",
|
|
||||||
method_ids,
|
|
||||||
"score",
|
|
||||||
"percentile"
|
|
||||||
)
|
|
||||||
|
|
||||||
column_names <- c(
|
|
||||||
"",
|
|
||||||
"Gene",
|
|
||||||
"",
|
|
||||||
"Chromosome",
|
|
||||||
method_names,
|
|
||||||
"Score",
|
|
||||||
"Percentile"
|
|
||||||
)
|
|
||||||
|
|
||||||
dt <- DT::datatable(
|
|
||||||
filtered_results()[, ..columns],
|
|
||||||
rownames = FALSE,
|
|
||||||
colnames = column_names,
|
|
||||||
style = "bootstrap",
|
|
||||||
options = list(
|
|
||||||
rowCallback = js_link,
|
|
||||||
columnDefs = list(list(visible = FALSE, targets = 2)),
|
|
||||||
pageLength = 25
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
DT::formatPercentage(
|
|
||||||
dt,
|
|
||||||
c(method_ids, "score", "percentile"),
|
|
||||||
digits = 2
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
output$copy <- renderUI({
|
output$copy <- renderUI({
|
||||||
results <- filtered_results()
|
results <- filtered_results()
|
||||||
|
|
||||||
|
|
@ -86,5 +50,57 @@ results_server <- function(id, filtered_results) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
columns <- c(
|
||||||
|
"rank",
|
||||||
|
"gene",
|
||||||
|
"name",
|
||||||
|
"chromosome",
|
||||||
|
method_ids,
|
||||||
|
"score",
|
||||||
|
"percentile"
|
||||||
|
)
|
||||||
|
|
||||||
|
column_names <- c(
|
||||||
|
"",
|
||||||
|
"Gene",
|
||||||
|
"",
|
||||||
|
"Chromosome",
|
||||||
|
method_names,
|
||||||
|
"Score",
|
||||||
|
"Percentile"
|
||||||
|
)
|
||||||
|
|
||||||
|
output_data <- reactive({
|
||||||
|
filtered_results()[, ..columns]
|
||||||
|
})
|
||||||
|
|
||||||
|
output$download <- downloadHandler(
|
||||||
|
filename = "geposan_filtered_results.csv",
|
||||||
|
content = function(file) {
|
||||||
|
fwrite(output_data(), file = file)
|
||||||
|
},
|
||||||
|
contentType = "text/csv"
|
||||||
|
)
|
||||||
|
|
||||||
|
output$genes <- DT::renderDT({
|
||||||
|
dt <- DT::datatable(
|
||||||
|
output_data(),
|
||||||
|
rownames = FALSE,
|
||||||
|
colnames = column_names,
|
||||||
|
style = "bootstrap",
|
||||||
|
options = list(
|
||||||
|
rowCallback = js_link,
|
||||||
|
columnDefs = list(list(visible = FALSE, targets = 2)),
|
||||||
|
pageLength = 25
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
DT::formatPercentage(
|
||||||
|
dt,
|
||||||
|
c(method_ids, "score", "percentile"),
|
||||||
|
digits = 2
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue