From 99af85584fc761d7fef974c06f7de8a285d9b0d4 Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Fri, 5 Jul 2024 16:02:56 +0200 Subject: [PATCH] fix --- R/1.0_module_data_summary.R | 22 ++++++++-------------- R/module_nested_tabs.R | 5 +++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/R/1.0_module_data_summary.R b/R/1.0_module_data_summary.R index bf34ffddc6..a6989ffbae 100644 --- a/R/1.0_module_data_summary.R +++ b/R/1.0_module_data_summary.R @@ -1,4 +1,4 @@ -ui_data_summary = function(id) { +ui_data_summary <- function(id) { ns <- NS(id) tags$div( id = id, # not used, can be used to customize CSS behavior @@ -37,14 +37,12 @@ ui_data_summary = function(id) { #' `shiny` module instance id. #' @param filtered_teal_data (`reactive`) (`teal_data`) an output of `.make_teal_data()` #' @return `NULL`. -srv_data_summary = function(id, filtered_teal_data) { +srv_data_summary <- function(id, filtered_teal_data) { checkmate::check_class(filtered_teal_data, "reactive") - checkmate::check_class(filtered_teal_data(), "teal_data") - moduleServer( id = id, function(input, output, session) { - #shinyjs::hide(id = "teal-main_ui-filter_panel-overview") # this doesnt hide filter-panel-overiw from teal.slice YET + # shinyjs::hide(id = "teal-main_ui-filter_panel-overview") # this doesnt hide filter-panel-overiw from teal.slice YET logger::log_trace("srv_data_summary initializing") observeEvent(input$minimise_filter_overview, { @@ -54,6 +52,7 @@ srv_data_summary = function(id, filtered_teal_data) { }) output$table <- renderUI({ + req(inherits(filtered_teal_data(), "teal_data")) logger::log_trace("srv_data_summary updating counts") if (length(datanames(filtered_teal_data())) == 0) { @@ -142,8 +141,7 @@ srv_data_summary = function(id, filtered_teal_data) { ) } -get_filter_overview <- function(filtered_teal_data){ - +get_filter_overview <- function(filtered_teal_data) { rows <- lapply( datanames(filtered_teal_data()), get_object_filter_overview, @@ -154,7 +152,6 @@ get_filter_overview <- function(filtered_teal_data){ } get_object_filter_overview <- function(filtered_teal_data, dataname, experiment_name = NULL) { - object <- extract_data(filtered_teal_data, dataname, experiment_name)$raw # not a regular S3 method, so we do not need to have dispatch for df/array/Matrix separately @@ -173,13 +170,13 @@ get_object_filter_overview <- function(filtered_teal_data, dataname, experiment_ } } -get_object_filter_overview_array = function(filtered_teal_data, dataname, experiment_name) { +get_object_filter_overview_array <- function(filtered_teal_data, dataname, experiment_name) { logger::log_trace("srv_data_overiew-get_filter_overview initialized") subject_keys <- if (!is.null(experiment_name)) { join_keys() } else { - ##if (length(parent(filtered_teal_data(), dataname)) > 0) { + ## if (length(parent(filtered_teal_data(), dataname)) > 0) { # if (dataname %in% names(join_keys(filtered_teal_data()))) { # join_keys(filtered_teal_data())[[dataname]][[dataname]] # } else { @@ -205,12 +202,10 @@ get_object_filter_overview_array = function(filtered_teal_data, dataname, experi subjects_filtered = nrow(unique(data$filtered[subject_keys])) ) } - } extract_data <- function(filtered_teal_data, dataname, experiment_name = NULL) { - - data <- filtered_teal_data()@env[[paste0(dataname, '_raw')]] + data <- filtered_teal_data()@env[[paste0(dataname, "_raw")]] data_filtered <- filtered_teal_data()@env[[dataname]] if (!is.null(experiment_name)) { @@ -231,7 +226,6 @@ get_object_filter_overview_SummarizedExperiment <- function(filtered_teal_data, } get_object_filter_overview_MultiAssayExperiment <- function(filtered_teal_data, dataname, experiment_name) { - data <- extract_data(filtered_teal_data, dataname, experiment_name) experiment_names <- names(data$raw) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index a1afe8fa35..76284183a3 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -100,6 +100,7 @@ ui_teal_module.teal_module <- function(id, modules, depth = 0L) { column( width = 3, ui_filter_panel(ns("module_filter_panel")), + ui_data_summary(ns("data_summary")), class = "teal_secondary_col" ) ) @@ -245,6 +246,7 @@ srv_teal_module.teal_module <- function(id, filtered_teal_data <- eventReactive(trigger_data(), { .make_teal_data(modules, data = data_rv(), datasets = datasets(), datanames = active_datanames()) }) + srv_data_summary("data_summary", filtered_teal_data) # Call modules. module_out <- if (!inherits(modules, "teal_module_previewer")) { @@ -288,7 +290,6 @@ srv_teal_module.teal_module <- function(id, if (is_arg_used(modules$server, "data")) { args <- c(args, data = list(filtered_teal_data)) - srv_data_summary("data_summary", filtered_teal_data) } @@ -357,4 +358,4 @@ srv_teal_module.teal_module <- function(id, datasets = datasets, USE.NAMES = FALSE ) -} \ No newline at end of file +}