2022-01-23 19:46:17 +01:00
|
|
|
#' Create the UI for the input page.
|
2022-05-19 16:24:23 +02:00
|
|
|
#'
|
|
|
|
|
#' @param options Global options for the application.
|
|
|
|
|
#'
|
2022-01-23 19:46:17 +01:00
|
|
|
#' @noRd
|
2022-05-19 16:24:23 +02:00
|
|
|
input_page_ui <- function(id, options) {
|
2022-05-26 12:44:09 +02:00
|
|
|
sidebarLayout(
|
|
|
|
|
sidebarPanel(
|
|
|
|
|
width = 3,
|
|
|
|
|
preset_editor_ui(NS(id, "preset_editor"), options),
|
|
|
|
|
tabsetPanel(
|
|
|
|
|
id = NS(id, "apply_panel"),
|
|
|
|
|
type = "hidden",
|
|
|
|
|
tabPanelBody(value = "hide"),
|
|
|
|
|
tabPanelBody(
|
|
|
|
|
value = "show",
|
|
|
|
|
actionButton(
|
|
|
|
|
NS(id, "apply_button"),
|
|
|
|
|
"Perform analysis",
|
|
|
|
|
class = "btn-primary",
|
|
|
|
|
style = "margin-top: 16px; margin-bottom: 16px"
|
|
|
|
|
)
|
2022-01-23 19:46:17 +01:00
|
|
|
)
|
2022-06-22 13:48:37 +02:00
|
|
|
)
|
2022-05-26 12:44:09 +02:00
|
|
|
),
|
|
|
|
|
mainPanel(
|
|
|
|
|
width = 9,
|
|
|
|
|
plotly::plotlyOutput(
|
|
|
|
|
NS(id, "positions_plot"),
|
|
|
|
|
width = "100%",
|
2022-05-28 17:12:44 +02:00
|
|
|
height = "1200px"
|
2022-05-26 12:44:09 +02:00
|
|
|
)
|
2022-01-23 19:46:17 +01:00
|
|
|
)
|
2022-05-26 12:44:09 +02:00
|
|
|
)
|
2022-01-23 19:46:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#' Application logic for the input page.
|
|
|
|
|
#'
|
|
|
|
|
#' @param id ID for namespacing the inputs and outputs.
|
2022-05-19 16:24:23 +02:00
|
|
|
#' @param options Global options for the application.
|
|
|
|
|
#'
|
2022-06-22 13:48:37 +02:00
|
|
|
#' @return A reactive containing the `preset` for the analysis.
|
2022-01-23 19:46:17 +01:00
|
|
|
#'
|
|
|
|
|
#' @noRd
|
2022-05-19 16:24:23 +02:00
|
|
|
input_page_server <- function(id, options) {
|
2022-05-26 12:44:09 +02:00
|
|
|
moduleServer(id, function(input, output, session) {
|
2022-08-18 09:21:48 +02:00
|
|
|
current_preset <- reactiveVal(geposan::preset(
|
|
|
|
|
options$reference_gene_sets[[1]],
|
|
|
|
|
methods = options$methods
|
|
|
|
|
))
|
2022-08-18 09:02:53 +02:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
potential_preset <- preset_editor_server("preset_editor", options)
|
2022-01-23 19:46:17 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
output$positions_plot <- plotly::renderPlotly({
|
|
|
|
|
preset <- potential_preset()
|
2022-01-23 19:46:17 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
if (is.null(preset)) {
|
|
|
|
|
NULL
|
|
|
|
|
} else {
|
2022-05-28 17:12:44 +02:00
|
|
|
geposan::plot_positions(
|
|
|
|
|
preset$species_ids,
|
2022-06-22 13:48:37 +02:00
|
|
|
list("Reference genes" = preset$reference_gene_ids),
|
2022-05-28 17:12:44 +02:00
|
|
|
reference_gene_ids = preset$reference_gene_ids
|
|
|
|
|
)
|
2022-05-26 12:44:09 +02:00
|
|
|
}
|
|
|
|
|
})
|
2022-01-23 19:46:17 +01:00
|
|
|
|
2022-05-26 12:44:09 +02:00
|
|
|
observe({
|
|
|
|
|
if (is.null(potential_preset()) |
|
|
|
|
|
rlang::hash(potential_preset()) ==
|
|
|
|
|
rlang::hash(current_preset())) {
|
|
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"apply_panel",
|
|
|
|
|
selected = "hide"
|
2022-01-23 19:46:17 +01:00
|
|
|
)
|
2022-05-26 12:44:09 +02:00
|
|
|
} else {
|
|
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"apply_panel",
|
|
|
|
|
selected = "show"
|
|
|
|
|
)
|
|
|
|
|
}
|
2022-01-23 19:46:17 +01:00
|
|
|
})
|
2022-05-26 12:44:09 +02:00
|
|
|
|
|
|
|
|
observe({
|
|
|
|
|
current_preset(potential_preset())
|
|
|
|
|
}) |> bindEvent(input$apply_button)
|
|
|
|
|
|
2022-06-22 13:48:37 +02:00
|
|
|
current_preset
|
2022-05-26 12:44:09 +02:00
|
|
|
})
|
2022-01-23 19:46:17 +01:00
|
|
|
}
|