Skip to content

Commit

Permalink
Changed some overlapping button ids, fixed a bug, where use full data…
Browse files Browse the repository at this point in the history
… set was not working if we did not create seleted data before
  • Loading branch information
PaulJonasJost committed Nov 11, 2024
1 parent 78ec773 commit 157e983
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion program/shinyApp/R/help_tab/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
3 changes: 3 additions & 0 deletions program/shinyApp/R/util.R
Original file line number Diff line number Diff line change
@@ -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)){
Expand Down
27 changes: 15 additions & 12 deletions program/shinyApp/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ server <- function(input,output,session){
}
})

observeEvent(input$NextPanel,{
observeEvent(input$NextPanel_tutorial,{
showTab(inputId = "tabsetPanel1",target = "Data selection",select = T)
})

Expand Down Expand Up @@ -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
Expand All @@ -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
)]
)
}
Expand Down

0 comments on commit 157e983

Please sign in to comment.