2021-12-30 12:19:00 +01:00
|
|
|
#' Construct UI for the detailed results panel.
|
|
|
|
|
#' @noRd
|
|
|
|
|
results_ui <- function(id) {
|
2022-05-26 12:44:09 +02:00
|
|
|
verticalLayout(
|
|
|
|
|
div(
|
|
|
|
|
style = "margin-top: 16px",
|
|
|
|
|
splitLayout(
|
|
|
|
|
cellWidths = "auto",
|
|
|
|
|
uiOutput(NS(id, "copy")),
|
|
|
|
|
downloadButton(NS(id, "download"), "Download CSV")
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
div(
|
|
|
|
|
style = "margin-top: 16px",
|
|
|
|
|
DT::DTOutput(NS(id, "genes"))
|
2021-12-30 12:19:00 +01:00
|
|
|
)
|
2022-05-26 12:44:09 +02:00
|
|
|
)
|
2021-12-30 12:19:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#' Server for the detailed results panel.
|
|
|
|
|
#'
|
|
|
|
|
#' @param filtered_results A reactive containing the prefiltered results to be
|
|
|
|
|
#' displayed.
|
|
|
|
|
#'
|
|
|
|
|
#' @noRd
|
|
|
|
|
results_server <- function(id, filtered_results) {
|
2022-05-26 12:44:09 +02:00
|
|
|
moduleServer(id, function(input, output, session) {
|
|
|
|
|
output$copy <- renderUI({
|
|
|
|
|
results <- filtered_results()
|
2021-12-30 12:19:00 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
gene_ids <- results[, gene]
|
|
|
|
|
names <- results[name != "", name]
|
2021-12-30 12:19:00 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
genes_text <- paste(gene_ids, collapse = "\n")
|
|
|
|
|
names_text <- paste(names, collapse = "\n")
|
2021-12-30 12:29:21 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
splitLayout(
|
|
|
|
|
cellWidths = "auto",
|
|
|
|
|
rclipboard::rclipButton(
|
|
|
|
|
"copy_ids_button",
|
|
|
|
|
"Copy gene IDs",
|
|
|
|
|
genes_text,
|
|
|
|
|
icon = icon("clipboard")
|
|
|
|
|
),
|
|
|
|
|
rclipboard::rclipButton(
|
|
|
|
|
"copy_names_button",
|
|
|
|
|
"Copy gene names",
|
|
|
|
|
names_text,
|
|
|
|
|
icon = icon("clipboard")
|
2021-12-30 12:29:21 +01:00
|
|
|
)
|
2022-05-26 12:44:09 +02:00
|
|
|
)
|
|
|
|
|
})
|
2021-12-30 12:29:21 +01:00
|
|
|
|
2022-05-26 17:55:40 +02:00
|
|
|
methods <- geposan::all_methods()
|
|
|
|
|
method_ids <- sapply(methods, function(method) method$id)
|
|
|
|
|
method_names <- sapply(methods, function(method) method$name)
|
|
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
columns <- c(
|
|
|
|
|
"rank",
|
|
|
|
|
"gene",
|
|
|
|
|
"name",
|
|
|
|
|
"chromosome",
|
|
|
|
|
"distance",
|
|
|
|
|
method_ids,
|
|
|
|
|
"score",
|
|
|
|
|
"percentile"
|
|
|
|
|
)
|
2021-12-30 12:29:21 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
column_names <- c(
|
|
|
|
|
"",
|
|
|
|
|
"Gene",
|
|
|
|
|
"",
|
|
|
|
|
"Chromosome",
|
|
|
|
|
"Distance",
|
|
|
|
|
method_names,
|
|
|
|
|
"Score",
|
|
|
|
|
"Percentile"
|
|
|
|
|
)
|
2021-12-30 12:29:21 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
output_data <- reactive({
|
|
|
|
|
filtered_results()[, ..columns][
|
|
|
|
|
,
|
|
|
|
|
distance := paste0(
|
|
|
|
|
format(
|
|
|
|
|
round(distance / 1000000, digits = 2),
|
|
|
|
|
nsmall = 2,
|
|
|
|
|
),
|
|
|
|
|
" Mbp"
|
2021-12-30 12:29:21 +01:00
|
|
|
)
|
2022-05-26 12:44:09 +02:00
|
|
|
]
|
|
|
|
|
})
|
2021-12-30 12:29:21 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
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,
|
|
|
|
|
options = list(
|
|
|
|
|
rowCallback = js_link,
|
|
|
|
|
columnDefs = list(list(visible = FALSE, targets = 2)),
|
|
|
|
|
pageLength = 25
|
|
|
|
|
)
|
|
|
|
|
)
|
2021-12-30 12:29:21 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
DT::formatPercentage(
|
|
|
|
|
dt,
|
|
|
|
|
c(method_ids, "score", "percentile"),
|
|
|
|
|
digits = 2
|
|
|
|
|
)
|
2021-12-30 12:19:00 +01:00
|
|
|
})
|
2022-05-26 12:44:09 +02:00
|
|
|
})
|
2021-12-30 12:19:00 +01:00
|
|
|
}
|