mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 11:17:24 +01:00
results: Move to separate module
This commit is contained in:
parent
b6e9179f13
commit
7834360e2a
3 changed files with 94 additions and 74 deletions
90
R/results.R
Normal file
90
R/results.R
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#' Construct UI for the detailed results panel.
|
||||
#' @noRd
|
||||
results_ui <- function(id) {
|
||||
verticalLayout(
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
uiOutput(NS(id, "copy")),
|
||||
),
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
DT::DTOutput(NS(id, "genes"))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' 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) {
|
||||
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({
|
||||
results <- filtered_results()
|
||||
|
||||
gene_ids <- results[, gene]
|
||||
names <- results[name != "", name]
|
||||
|
||||
genes_text <- paste(gene_ids, collapse = "\n")
|
||||
names_text <- paste(names, collapse = "\n")
|
||||
|
||||
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")
|
||||
)
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
69
R/server.R
69
R/server.R
|
|
@ -45,74 +45,11 @@ server <- function(input, output, session) {
|
|||
# Apply the filters.
|
||||
results_filtered <- filters_server("filters", results)
|
||||
|
||||
# Server for the detailed results panel.
|
||||
results_server("results", results_filtered)
|
||||
|
||||
comparison_gene_ids <- comparison_editor_server("comparison_editor", preset)
|
||||
|
||||
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(
|
||||
results_filtered()[, ..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({
|
||||
results <- results_filtered()
|
||||
|
||||
gene_ids <- results[, gene]
|
||||
names <- results[name != "", name]
|
||||
|
||||
genes_text <- paste(gene_ids, collapse = "\n")
|
||||
names_text <- paste(names, collapse = "\n")
|
||||
|
||||
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")
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
output$scatter <- plotly::renderPlotly({
|
||||
preset <- preset()
|
||||
gene_sets <- list("Reference genes" = preset$reference_gene_ids)
|
||||
|
|
|
|||
9
R/ui.R
9
R/ui.R
|
|
@ -74,14 +74,7 @@ ui <- div(
|
|||
),
|
||||
tabPanel(
|
||||
title = "Detailed results",
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
uiOutput("copy"),
|
||||
),
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
DT::DTOutput("genes")
|
||||
)
|
||||
results_ui("results")
|
||||
),
|
||||
tabPanel(
|
||||
title = "g:Profiler",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue