Move comparison editor to results page

This commit is contained in:
Elias Projahn 2022-06-22 13:48:37 +02:00
parent 9960379645
commit e7cbb4ea33
3 changed files with 12 additions and 28 deletions

View file

@ -21,8 +21,7 @@ input_page_ui <- function(id, options) {
style = "margin-top: 16px; margin-bottom: 16px" style = "margin-top: 16px; margin-bottom: 16px"
) )
) )
), )
comparison_editor_ui(NS(id, "comparison_editor"), options)
), ),
mainPanel( mainPanel(
width = 9, width = 9,
@ -40,8 +39,7 @@ input_page_ui <- function(id, options) {
#' @param id ID for namespacing the inputs and outputs. #' @param id ID for namespacing the inputs and outputs.
#' @param options Global options for the application. #' @param options Global options for the application.
#' #'
#' @return A list containing two reactives: the `preset` for the analysis and #' @return A reactive containing the `preset` for the analysis.
#' the `comparison_gene_ids`.
#' #'
#' @noRd #' @noRd
input_page_server <- function(id, options) { input_page_server <- function(id, options) {
@ -49,31 +47,15 @@ input_page_server <- function(id, options) {
current_preset <- reactiveVal(geposan::preset(options$gene_sets[[1]])) current_preset <- reactiveVal(geposan::preset(options$gene_sets[[1]]))
potential_preset <- preset_editor_server("preset_editor", options) potential_preset <- preset_editor_server("preset_editor", options)
comparison_gene_ids <- comparison_editor_server(
"comparison_editor",
current_preset,
options
)
output$positions_plot <- plotly::renderPlotly({ output$positions_plot <- plotly::renderPlotly({
preset <- potential_preset() preset <- potential_preset()
if (is.null(preset)) { if (is.null(preset)) {
NULL NULL
} else { } else {
gene_sets <- list("Reference genes" = preset$reference_gene_ids)
comparison_gene_ids <- comparison_gene_ids()
if (length(comparison_gene_ids) >= 1) {
gene_sets <- c(
gene_sets,
list("Comparison genes" = comparison_gene_ids)
)
}
geposan::plot_positions( geposan::plot_positions(
preset$species_ids, preset$species_ids,
gene_sets, list("Reference genes" = preset$reference_gene_ids),
reference_gene_ids = preset$reference_gene_ids reference_gene_ids = preset$reference_gene_ids
) )
} }
@ -101,9 +83,6 @@ input_page_server <- function(id, options) {
current_preset(potential_preset()) current_preset(potential_preset())
}) |> bindEvent(input$apply_button) }) |> bindEvent(input$apply_button)
list( current_preset
preset = current_preset,
comparison_gene_ids = comparison_gene_ids
)
}) })
} }

View file

@ -13,9 +13,13 @@ js_link <- DT::JS("function(row, data) {
#' @noRd #' @noRd
server <- function(options) { server <- function(options) {
function(input, output, session) { function(input, output, session) {
input_reactives <- input_page_server("input_page", options) preset <- input_page_server("input_page", options)
preset <- input_reactives$preset
comparison_gene_ids <- input_reactives$comparison_gene_ids comparison_gene_ids <- comparison_editor_server(
"comparison_editor",
preset,
options
)
observe({ observe({
updateNavbarPage( updateNavbarPage(

1
R/ui.R
View file

@ -25,6 +25,7 @@ ui <- function(options) {
sidebarLayout( sidebarLayout(
sidebarPanel( sidebarPanel(
width = 3, width = 3,
comparison_editor_ui("comparison_editor", options),
methods_ui("methods"), methods_ui("methods"),
filters_ui("filters") filters_ui("filters")
), ),