From 325bbeca99f8d2470c58c4be73b782009c342ebd Mon Sep 17 00:00:00 2001 From: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:00:44 +0100 Subject: [PATCH] Changed some overlapping button ids, fixed a bug, where use full data set was not working if we did not create seleted data before (#376) --- program/shinyApp/R/help_tab/ui.R | 2 +- program/shinyApp/R/util.R | 3 +++ program/shinyApp/server.R | 27 +++++++++++++++------------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/program/shinyApp/R/help_tab/ui.R b/program/shinyApp/R/help_tab/ui.R index d1d425e1..8b8213b2 100644 --- a/program/shinyApp/R/help_tab/ui.R +++ b/program/shinyApp/R/help_tab/ui.R @@ -57,7 +57,7 @@ help_tab_main_panel <- mainPanel( div( # Action button actionButton( - inputId = "NextPanel", + inputId = "NextPanel_tutorial", label = "Take me to the Analysis Start", width = "100%", icon = icon('rocket'), diff --git a/program/shinyApp/R/util.R b/program/shinyApp/R/util.R index 9f07a55f..cf934594 100644 --- a/program/shinyApp/R/util.R +++ b/program/shinyApp/R/util.R @@ -1,5 +1,8 @@ ### general utility functions will be defined here +# Utility function for is.null checks +`%||%` <- function(a, b) if (!is.null(a)) a else b + # tryCatch modal dialog error_modal <- function(e, additional_text = NULL){ if (is.null(e$message)){ diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index 5d6f7d1d..1f44c9f8 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -184,7 +184,7 @@ server <- function(input,output,session){ } }) - observeEvent(input$NextPanel,{ + observeEvent(input$NextPanel_tutorial,{ showTab(inputId = "tabsetPanel1",target = "Data selection",select = T) }) @@ -924,26 +924,29 @@ server <- function(input,output,session){ ## Do Selection ---- selectedData <- reactive({ - shiny::req(input$row_selection, input$sample_selection) - par_tmp[[session$token]][["row_selection"]] <<- input$row_selection - par_tmp[[session$token]][["sample_selection"]] <<- input$sample_selection - par_tmp[[session$token]][["providedRowAnnotationTypes"]] <<- input$providedRowAnnotationTypes + req(data_input_shiny()) + row_selection <- input$row_selection %||% "all" + sample_selection <- input$sample_selection %||% "all" + providedRowAnnotationTypes <- input$providedRowAnnotationTypes %||% c(colnames(rowData(res_tmp[[session$token]]$data_original)))[1] + par_tmp[[session$token]][["row_selection"]] <<- row_selection + par_tmp[[session$token]][["sample_selection"]] <<- sample_selection + par_tmp[[session$token]][["providedRowAnnotationTypes"]] <<- providedRowAnnotationTypes print("Alright do Row selection") selected <- c() - if(any(input$row_selection == "all")){ + if(any(row_selection == "all")){ selected <- rownames(rowData(res_tmp[[session$token]]$data_original)) - } else if(!(length(input$row_selection) == 1 & any(input$row_selection == "High Values+IQR"))){ + } else if(!(length(row_selection) == 1 & any(row_selection == "High Values+IQR"))){ selected <- unique(c( selected, rownames(rowData(res_tmp[[session$token]]$data_original))[ - which(rowData(res_tmp[[session$token]]$data_original)[,input$providedRowAnnotationTypes]%in%input$row_selection) + which(rowData(res_tmp[[session$token]]$data_original)[,providedRowAnnotationTypes]%in%row_selection) ] )) } - if(any(input$row_selection == "High Values+IQR")){ - if(length(input$row_selection) == 1){ + if(any(row_selection == "High Values+IQR")){ + if(length(row_selection) == 1){ toKeep <- filter_rna( rna = assay(res_tmp[[session$token]]$data_original), prop = input$propensityChoiceUser @@ -964,13 +967,13 @@ server <- function(input,output,session){ # Column Selection samples_selected <- c() - if(any(input$sample_selection == "all")){ + if(any(sample_selection == "all")){ samples_selected <- colnames(assay(res_tmp[[session$token]]$data_original)) }else{ samples_selected <- c( samples_selected, rownames(colData(res_tmp[[session$token]]$data_original))[which( - colData(res_tmp[[session$token]]$data_original)[,input$providedSampleAnnotationTypes] %in% input$sample_selection + colData(res_tmp[[session$token]]$data_original)[,input$providedSampleAnnotationTypes] %in% sample_selection )] ) }