diff --git a/CharacterisationCode/renv.lock b/CharacterisationCode/renv.lock index 11e8cd9..eeac4cb 100644 --- a/CharacterisationCode/renv.lock +++ b/CharacterisationCode/renv.lock @@ -102,7 +102,7 @@ }, "OmopSketch": { "Package": "OmopSketch", - "Version": "0.2.0", + "Version": "0.2.1", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -122,7 +122,7 @@ "tibble", "tidyr" ], - "Hash": "0c37ddc951ee1dafd9ef3ef7998db507" + "Hash": "1267f40708ddba6cd56b623d5c386ad3" }, "PatientProfiles": { "Package": "PatientProfiles", @@ -441,9 +441,9 @@ }, "pillar": { "Package": "pillar", - "Version": "1.10.0", + "Version": "1.10.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "cli", "glue", @@ -453,7 +453,7 @@ "utils", "vctrs" ], - "Hash": "101ca350beea21261a15ba169d7a8513" + "Hash": "8b16b6097daef84cd3c40a6a7c5c9d86" }, "pkgconfig": { "Package": "pkgconfig", @@ -695,22 +695,21 @@ }, "visOmopResults": { "Package": "visOmopResults", - "Version": "0.5.1", + "Version": "1.0.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "cli", "dplyr", "generics", "glue", - "lifecycle", "omopgenerics", "purrr", "rlang", "stringr", "tidyr" ], - "Hash": "62111b2c7b941ffe31fc68fbe1cae436" + "Hash": "4a6d832d0cf4775f7a3f865982b92231" }, "vroom": { "Package": "vroom", diff --git a/shiny/data/preprocess.R b/shiny/data/preprocess.R index 9bbe218..2f8129e 100644 --- a/shiny/data/preprocess.R +++ b/shiny/data/preprocess.R @@ -3,7 +3,7 @@ resultList <- list( "summarise_omop_snapshot" = c(1L), "summarise_characteristics" = c(2L), "summarise_missing_data" = c(3L), - "summarise_all_concept_counts" = c(4L), + "summarise_concept_id_counts" = c(4L), "summarise_clinical_records" = c(5L), "summarise_record_count" = c(6L), "summarise_in_observation" = c(7L), @@ -12,7 +12,19 @@ resultList <- list( source(file.path(getwd(), "functions.R")) -result <- omopgenerics::importSummarisedResult(file.path(getwd(), "data")) +data_path <- file.path(getwd(), "data") +csv_files <- list.files(data_path, pattern = "\\.csv$", full.names = TRUE) + +result <- purrr::map(csv_files, \(x){ + d <- omopgenerics::importSummarisedResult(x) + attr(d, "settings") <- attr(d, "settings")|>dplyr::mutate(result_type = dplyr::if_else(.data$result_type == "summarise_all_concept_counts", "summarise_concept_id_counts", .data$result_type)) + d +}) |> + dplyr::bind_rows() |> + omopgenerics::newSummarisedResult() + +# result <- omopgenerics::importSummarisedResult(file.path(getwd(), "data")) + data <- prepareResult(result, resultList) filterValues <- defaultFilterValues(result, resultList) diff --git a/shiny/server.R b/shiny/server.R index 3968374..5d1fcc5 100644 --- a/shiny/server.R +++ b/shiny/server.R @@ -259,24 +259,24 @@ server <- function(input, output, session) { ) - # summarise_all_concept_counts ----- - ## tidy summarise_all_concept_counts ----- + # summarise_concept_id_counts ----- + ## tidy summarise_concept_id_counts ----- getTidyDataSummariseAllConceptCounts <- shiny::reactive({ res <- data |> - filterData("summarise_all_concept_counts", input) |> + filterData("summarise_concept_id_counts", input) |> omopgenerics::addSettings() |> omopgenerics::splitAll() |> dplyr::select(!"result_id") - + # columns to eliminate colsEliminate <- colnames(res) colsEliminate <- colsEliminate[!colsEliminate %in% c( - input$summarise_all_concept_counts_tidy_columns, "variable_name", "variable_level", + input$summarise_concept_id_counts_tidy_columns, "variable_name", "variable_level", "estimate_name", "estimate_type", "estimate_value" )] # pivot - pivot <- input$summarise_all_concept_counts_tidy_pivot + pivot <- input$summarise_concept_id_counts_tidy_pivot if (pivot != "none") { vars <- switch(pivot, "estimates" = "estimate_name", @@ -289,28 +289,28 @@ server <- function(input, output, session) { res |> dplyr::select(!dplyr::all_of(colsEliminate)) }) - output$summarise_all_concept_counts_tidy <- DT::renderDT({ + output$summarise_concept_id_counts_tidy <- DT::renderDT({ DT::datatable( getTidyDataSummariseAllConceptCounts(), options = list(scrollX = TRUE), rownames = FALSE ) }) - output$summarise_all_concept_counts_tidy_download <- shiny::downloadHandler( - filename = "tidy_summarise_all_concept_counts.csv", + output$summarise_concept_id_counts_tidy_download <- shiny::downloadHandler( + filename = "tidy_summarise_concept_id_counts.csv", content = function(file) { getTidyDataSummariseAllConceptCounts() |> readr::write_csv(file = file) } ) - ## output summarise_all_concept_counts ----- + ## output summarise_concept_id_counts ----- ## output 0 ----- createOutput27 <- shiny::reactive({ result <- data |> - filterData("summarise_all_concept_counts", input) - header <- input$summarise_all_concept_counts_gt_0_header - group <- input$summarise_all_concept_counts_gt_0_group - hide <- input$summarise_all_concept_counts_gt_0_hide + filterData("summarise_concept_id_counts", input) + header <- input$summarise_concept_id_counts_gt_0_header + group <- input$summarise_concept_id_counts_gt_0_group + hide <- input$summarise_concept_id_counts_gt_0_hide if (is.null(header) || length(header) == 0) header <- c("cdm_name") if (is.null(group) || length(group) == 0) group <- c("omop_table","year") @@ -322,11 +322,11 @@ server <- function(input, output, session) { hide = hide ) }) - output$summarise_all_concept_counts_gt_0 <- gt::render_gt({ + output$summarise_concept_id_counts_gt_0 <- gt::render_gt({ createOutput27() }) - output$summarise_all_concept_counts_gt_0_download <- shiny::downloadHandler( - filename = paste0("output_gt_summarise_all_concept_counts.", input$summarise_all_concept_counts_gt_0_download_type), + output$summarise_concept_id_counts_gt_0_download <- shiny::downloadHandler( + filename = paste0("output_gt_summarise_concept_id_counts.", input$summarise_concept_id_counts_gt_0_download_type), content = function(file) { obj <- createOutput27() gt::gtsave(data = obj, filename = file) diff --git a/shiny/ui.R b/shiny/ui.R index 03b55c9..4638bb6 100644 --- a/shiny/ui.R +++ b/shiny/ui.R @@ -554,18 +554,18 @@ ui <- bslib::page_navbar( bslib::accordion_panel( title = "Settings", shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_settings_study_period_end", + inputId = "summarise_concept_id_counts_settings_study_period_end", label = "Study period end", - choices = filterValues$summarise_all_concept_counts_settings_study_period_end, - selected = filterValues$summarise_all_concept_counts_settings_study_period_end, + choices = filterValues$summarise_concept_id_counts_settings_study_period_end, + selected = filterValues$summarise_concept_id_counts_settings_study_period_end, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ), shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_settings_study_period_start", + inputId = "summarise_concept_id_counts_settings_study_period_start", label = "Study period start", - choices = filterValues$summarise_all_concept_counts_settings_study_period_start, - selected = filterValues$summarise_all_concept_counts_settings_study_period_start, + choices = filterValues$summarise_concept_id_counts_settings_study_period_start, + selected = filterValues$summarise_concept_id_counts_settings_study_period_start, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ) @@ -573,42 +573,42 @@ ui <- bslib::page_navbar( bslib::accordion_panel( title = "Grouping", shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_grouping_cdm_name", + inputId = "summarise_concept_id_counts_grouping_cdm_name", label = "Cdm name", - choices = filterValues$summarise_all_concept_counts_grouping_cdm_name, - selected = filterValues$summarise_all_concept_counts_grouping_cdm_name, + choices = filterValues$summarise_concept_id_counts_grouping_cdm_name, + selected = filterValues$summarise_concept_id_counts_grouping_cdm_name, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ), shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_grouping_omop_table", + inputId = "summarise_concept_id_counts_grouping_omop_table", label = "Omop table", - choices = filterValues$summarise_all_concept_counts_grouping_omop_table, - selected = filterValues$summarise_all_concept_counts_grouping_omop_table, + choices = filterValues$summarise_concept_id_counts_grouping_omop_table, + selected = filterValues$summarise_concept_id_counts_grouping_omop_table, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ), shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_grouping_age_group", + inputId = "summarise_concept_id_counts_grouping_age_group", label = "Age group", - choices = filterValues$summarise_all_concept_counts_grouping_age_group, - selected = filterValues$summarise_all_concept_counts_grouping_age_group, + choices = filterValues$summarise_concept_id_counts_grouping_age_group, + selected = filterValues$summarise_concept_id_counts_grouping_age_group, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ), shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_grouping_sex", + inputId = "summarise_concept_id_counts_grouping_sex", label = "Sex", - choices = filterValues$summarise_all_concept_counts_grouping_sex, - selected = filterValues$summarise_all_concept_counts_grouping_sex, + choices = filterValues$summarise_concept_id_counts_grouping_sex, + selected = filterValues$summarise_concept_id_counts_grouping_sex, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ), shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_grouping_year", + inputId = "summarise_concept_id_counts_grouping_year", label = "Year", - choices = filterValues$summarise_all_concept_counts_grouping_year, - selected = filterValues$summarise_all_concept_counts_grouping_year, + choices = filterValues$summarise_concept_id_counts_grouping_year, + selected = filterValues$summarise_concept_id_counts_grouping_year, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ) @@ -616,10 +616,10 @@ ui <- bslib::page_navbar( bslib::accordion_panel( title = "Variables", shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_variable_name", + inputId = "summarise_concept_id_counts_variable_name", label = "Variable name", - choices = filterValues$summarise_all_concept_counts_variable_name, - selected = filterValues$summarise_all_concept_counts_variable_name, + choices = filterValues$summarise_concept_id_counts_variable_name, + selected = filterValues$summarise_concept_id_counts_variable_name, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ) @@ -627,10 +627,10 @@ ui <- bslib::page_navbar( bslib::accordion_panel( title = "Estimates", shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_estimate_name", + inputId = "summarise_concept_id_counts_estimate_name", label = "Estimate name", - choices = filterValues$summarise_all_concept_counts_estimate_name, - selected = filterValues$summarise_all_concept_counts_estimate_name, + choices = filterValues$summarise_concept_id_counts_estimate_name, + selected = filterValues$summarise_concept_id_counts_estimate_name, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ) @@ -645,29 +645,29 @@ ui <- bslib::page_navbar( bslib::card_header( bslib::popover( shiny::icon("download"), - shiny::downloadButton(outputId = "summarise_all_concept_counts_tidy_download", label = "Download csv") + shiny::downloadButton(outputId = "summarise_concept_id_counts_tidy_download", label = "Download csv") ), class = "text-end" ), bslib::layout_sidebar( sidebar = bslib::sidebar( shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_tidy_columns", + inputId = "summarise_concept_id_counts_tidy_columns", label = "Columns", - choices = filterValues$summarise_all_concept_counts_tidy_columns, - selected = filterValues$summarise_all_concept_counts_tidy_columns, + choices = filterValues$summarise_concept_id_counts_tidy_columns, + selected = filterValues$summarise_concept_id_counts_tidy_columns, multiple = TRUE, options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = "count > 3") ), shiny::radioButtons( - inputId = "summarise_all_concept_counts_tidy_pivot", + inputId = "summarise_concept_id_counts_tidy_pivot", label = "Pivot estimates/variables", choices = c("none", "estimates", "estimates and variables"), selected = "none" ), position = "right" ), - DT::dataTableOutput("summarise_all_concept_counts_tidy") + DT::dataTableOutput("summarise_concept_id_counts_tidy") ) ) ), @@ -679,13 +679,13 @@ ui <- bslib::page_navbar( bslib::popover( shiny::icon("download"), shinyWidgets::pickerInput( - inputId = "summarise_all_concept_counts_gt_0_download_type", + inputId = "summarise_concept_id_counts_gt_0_download_type", label = "File type", selected = "docx", choices = c("docx", "png", "pdf", "html"), multiple = FALSE ), - shiny::downloadButton(outputId = "summarise_all_concept_counts_gt_0_download", label = "Download") + shiny::downloadButton(outputId = "summarise_concept_id_counts_gt_0_download", label = "Download") ), class = "text-end" ), @@ -696,27 +696,27 @@ ui <- bslib::page_navbar( sortable::add_rank_list( text = "none", labels = c("variable_name", "estimate_name", "estimate_level", "sex", "age-group"), - input_id = "summarise_all_concept_counts_gt_0_none" + input_id = "summarise_concept_id_counts_gt_0_none" ), sortable::add_rank_list( text = "header", labels = "cdm_name", - input_id = "summarise_all_concept_counts_gt_0_header" + input_id = "summarise_concept_id_counts_gt_0_header" ), sortable::add_rank_list( text = "group", labels = c("omop_table","year"), - input_id = "summarise_all_concept_counts_gt_0_group" + input_id = "summarise_concept_id_counts_gt_0_group" ), sortable::add_rank_list( text = "hide", labels = c("study_period_end", "study_period_start"), - input_id = "summarise_all_concept_counts_gt_0_hide" + input_id = "summarise_concept_id_counts_gt_0_hide" ) ), position = "right" ), - gt::gt_output("summarise_all_concept_counts_gt_0") + gt::gt_output("summarise_concept_id_counts_gt_0") ) ) )