Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Jul 5, 2024
1 parent 78653eb commit 99af855
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
22 changes: 8 additions & 14 deletions R/1.0_module_data_summary.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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, {
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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)) {
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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)
}


Expand Down Expand Up @@ -357,4 +358,4 @@ srv_teal_module.teal_module <- function(id,
datasets = datasets,
USE.NAMES = FALSE
)
}
}

0 comments on commit 99af855

Please sign in to comment.