diff --git a/DESCRIPTION b/DESCRIPTION index 51fca77..b1c2cf3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,5 +23,4 @@ Imports: rlang, rclipboard, shiny, - shinyjs, - shinyWidgets + shinyjs diff --git a/R/app.R b/R/app.R index 640957f..7cb3ece 100644 --- a/R/app.R +++ b/R/app.R @@ -8,7 +8,6 @@ run_app <- function(port = 3464) { shinyjs::useShinyjs() rclipboard::rclipboardSetup() - shinyWidgets::pickerInput("none", choices = NULL) # Actually run the app. diff --git a/R/comparison_editor.R b/R/comparison_editor.R index 49eb7e4..d5ddfd6 100644 --- a/R/comparison_editor.R +++ b/R/comparison_editor.R @@ -1,9 +1,5 @@ # Create a comparison editor. comparison_editor_ui <- function(id) { - known_genes <- genes[name != ""] - gene_choices <- known_genes$id - names(gene_choices) <- known_genes$name - verticalLayout( h3("Comparison"), selectInput( @@ -18,21 +14,16 @@ comparison_editor_ui <- function(id) { "Customize" = "custom" ) ), - tabsetPanel( - id = NS(id, "custom_comparison_genes_panel"), - type = "hidden", - tabPanelBody(value = "hide"), - tabPanelBody( - value = "show", - shinyWidgets::pickerInput( - inputId = NS(id, "custom_comparison_genes"), - choices = gene_choices, - options = list( - "actions-box" = TRUE, - "live-search" = TRUE - ), - multiple = TRUE - ) + conditionalPanel( + condition = sprintf( + "input['%s'] == 'custom'", + NS(id, "comparison_genes") + ), + selectizeInput( + inputId = NS(id, "custom_comparison_genes"), + label = "Select comparison genes", + choices = NULL, + multiple = TRUE ) ) ) @@ -46,21 +37,16 @@ comparison_editor_ui <- function(id) { # @return A reactive containing the comparison gene IDs. comparison_editor_server <- function(id, preset) { moduleServer(id, function(input, output, session) { - observeEvent(input$comparison_genes, { - if (input$comparison_genes == "custom") { - updateTabsetPanel( - session, - "custom_comparison_genes_panel", - selected = "show" - ) - } else { - updateTabsetPanel( - session, - "custom_comparison_genes_panel", - selected = "hide" - ) - } - }) + known_genes <- genes[name != ""] + gene_choices <- known_genes$id + names(gene_choices) <- known_genes$name + + updateSelectizeInput( + session, + "custom_comparison_genes", + choices = gene_choices, + server = TRUE + ) reactive({ if (input$comparison_genes == "none") { diff --git a/R/preset_editor.R b/R/preset_editor.R index 1b51971..7f6760b 100644 --- a/R/preset_editor.R +++ b/R/preset_editor.R @@ -1,12 +1,5 @@ # Create a preset editor. preset_editor_ui <- function(id) { - species_choices <- species$id - names(species_choices) <- species$name - - known_genes <- genes[name != ""] - gene_choices <- known_genes$id - names(gene_choices) <- known_genes$name - verticalLayout( h3("Inputs"), selectInput( @@ -18,22 +11,14 @@ preset_editor_ui <- function(id) { "Customize" = "custom" ) ), - tabsetPanel( - id = NS(id, "custom_species_panel"), - type = "hidden", - tabPanelBody(value = "hide"), - tabPanelBody( - value = "show", - shinyWidgets::pickerInput( - inputId = NS(id, "custom_species"), - choices = species_choices, - options = list( - "actions-box" = TRUE, - "live-search" = TRUE - ), - multiple = TRUE - ) - ) + conditionalPanel( + condition = sprintf("input['%s'] == 'custom'", NS(id, "species")), + selectizeInput( + inputId = NS(id, "custom_species"), + label = "Select input species", + choices = NULL, + multiple = TRUE + ), ), selectInput( NS(id, "reference_genes"), @@ -44,21 +29,16 @@ preset_editor_ui <- function(id) { "Customize" = "custom" ) ), - tabsetPanel( - id = NS(id, "custom_reference_genes_panel"), - type = "hidden", - tabPanelBody(value = "hide"), - tabPanelBody( - value = "show", - shinyWidgets::pickerInput( - inputId = NS(id, "custom_reference_genes"), - choices = gene_choices, - options = list( - "actions-box" = TRUE, - "live-search" = TRUE - ), - multiple = TRUE - ) + conditionalPanel( + condition = sprintf( + "input['%s'] == 'custom'", + NS(id, "reference_genes") + ), + selectizeInput( + inputId = NS(id, "custom_reference_genes"), + label = "Select reference genes", + choices = NULL, + multiple = TRUE ) ), selectInput( @@ -95,6 +75,27 @@ preset_editor_ui <- function(id) { # @return A reactive containing the preset. preset_editor_server <- function(id) { moduleServer(id, function(input, output, session) { + species_choices <- species$id + names(species_choices) <- species$name + + known_genes <- genes[name != ""] + gene_choices <- known_genes$id + names(gene_choices) <- known_genes$name + + updateSelectizeInput( + session, + "custom_species", + choices = species_choices, + server = TRUE + ) + + updateSelectizeInput( + session, + "custom_reference_genes", + choices = gene_choices, + server = TRUE + ) + current_preset <- reactiveVal(geposan::preset( methods = method_ids, species_ids = species$id, @@ -103,38 +104,6 @@ preset_editor_server <- function(id) { optimization_target = "mean" )) - observeEvent(input$species, { - if (input$species == "custom") { - updateTabsetPanel( - session, - "custom_species_panel", - selected = "show" - ) - } else { - updateTabsetPanel( - session, - "custom_species_panel", - selected = "hide" - ) - } - }) - - observeEvent(input$reference_genes, { - if (input$reference_genes == "custom") { - updateTabsetPanel( - session, - "custom_reference_genes_panel", - selected = "show" - ) - } else { - updateTabsetPanel( - session, - "custom_reference_genes_panel", - selected = "hide" - ) - } - }) - new_preset <- reactive({ species_ids <- if (input$species == "replicative") { species[replicative == TRUE, id] diff --git a/R/ui.R b/R/ui.R index 2218be0..a5c5b5c 100644 --- a/R/ui.R +++ b/R/ui.R @@ -1,38 +1,42 @@ -ui <- fluidPage( +ui <- div( shinyjs::useShinyjs(), rclipboard::rclipboardSetup(), - titlePanel("TPE-OLD candidates"), - sidebarLayout( - sidebarPanel( - width = 3, - preset_editor_ui("preset_editor"), - comparison_editor_ui("comparison_editor"), - filters_ui("filters"), - methods_ui("methods") + navbarPage( + theme = bslib::bs_theme( + version = 3, + bootswatch = "united", + primary = "#1c71d8" ), - mainPanel( - tabsetPanel( - type = "pills", - header = div(style = "margin-top: 16px"), - tabPanel( - "Results", - uiOutput("copy"), - div( - style = "margin-top: 16px", - DT::DTOutput("genes") - ) + title = "TPE-OLD candidates", + selected = "Ranking", + tabPanel( + "Input data", + sidebarLayout( + sidebarPanel( + width = 3, + preset_editor_ui("preset_editor"), + comparison_editor_ui("comparison_editor") ), - tabPanel( - "Input Data", + mainPanel( + width = 9, plotly::plotlyOutput( "scatter", width = "100%", height = "600px" ) + ) + ), + ), + tabPanel( + "Ranking", + sidebarLayout( + sidebarPanel( + width = 3, + methods_ui("methods"), + filters_ui("filters") ), - tabPanel( - "Assessment", - htmlOutput("assessment_synopsis"), + mainPanel( + width = 9, div( style = "margin-top: 16px", plotly::plotlyOutput( @@ -49,38 +53,50 @@ ui <- fluidPage( height = "600px" ) ), - div( - style = "margin-top: 16px", - plotly::plotlyOutput( - "boxplot", - width = "100%", - height = "600px" - ) - ), - div( - style = "margin-top: 16px", - plotly::plotlyOutput( - "chromosome_plot", - width = "100%", - height = "600px" - ) - ), - ), - tabPanel( - "Analysis", - checkboxInput( - "enable_gost", - "Perform a gene set enrichment analysis on the \ - filtered result genes." - ), - conditionalPanel( - "input.enable_gost == true", - plotly::plotlyOutput( - "gost", - width = "100%", - height = "600px" - ) - ) + ) + ), + ), + tabPanel( + "Detailed results", + uiOutput("copy"), + div( + style = "margin-top: 16px", + DT::DTOutput("genes") + ) + ), + tabPanel( + "Assessment", + htmlOutput("assessment_synopsis"), + div( + style = "margin-top: 16px", + plotly::plotlyOutput( + "boxplot", + width = "100%", + height = "600px" + ) + ), + div( + style = "margin-top: 16px", + plotly::plotlyOutput( + "chromosome_plot", + width = "100%", + height = "600px" + ) + ), + ), + tabPanel( + "Analysis", + checkboxInput( + "enable_gost", + "Perform a gene set enrichment analysis on the \ + filtered result genes." + ), + conditionalPanel( + "input.enable_gost == true", + plotly::plotlyOutput( + "gost", + width = "100%", + height = "600px" ) ) )