Using the tabular output generated by ssc_process, this function will build a graph to
visualize the results. Each function configuration will output a bespoke ggplot. Theming can
be adjusted by the user after the graph has been output using + theme(). Most graphs can
also be made interactive using make_interactive_squba()
Arguments
- process_output
tabular input || required
The tabular output produced by
ssc_process- alt_cohort_filter
string or vector || defaults to
NULLA vector with the names of alternate cohorts to display in the output. This should be limited to 2 or less to maintain good visibility on the graph. This parameter is required for the following check types:
Single Site, Exploratory, Cross-SectionalMulti-Site, Exploratory, Cross-Sectional
- large_n
boolean || defaults to
FALSEFor Multi-Site analyses, a boolean indicating whether the large N visualization, intended for a high volume of sites, should be used. This visualization will produce high level summaries across all sites, with an option to add specific site comparators via the
large_n_sitesparameter.- large_n_sites
vector || defaults to
NULLWhen
large_n = TRUE, a vector of site names that can add site-level information to the plot for comparison across the high level summary information.
Value
This function will produce a graph to visualize the results
from ssc_process based on the parameters provided. The default
output is typically a static ggplot or gt object, but interactive
elements can be activated by passing the plot through make_interactive_squba.
For a more detailed description of output specific to each check type,
see the PEDSpace metadata repository
Examples
#' Source setup file
source(system.file('setup.R', package = 'sensitivityselectioncriteria'))
#' Create in-memory RSQLite database using data in extdata directory
conn <- mk_testdb_omop()
#' Establish connection to database and generate internal configurations
initialize_dq_session(session_name = 'ssc_process_test',
working_directory = my_directory,
db_conn = conn,
is_json = FALSE,
file_subdirectory = my_file_folder,
cdm_schema = NA)
#> Connected to: :memory:@NA
## silence SQL trace for this example
config('db_trace', FALSE)
#' Build mock base study cohort
base_cohort <- cdm_tbl('person') %>% dplyr::distinct(person_id) %>%
dplyr::mutate(start_date = as.Date(-5000),
#RSQLite does not store date objects,
#hence the numerics
end_date = as.Date(15000),
site = ifelse(person_id %in% c(1:6), 'synth1', 'synth2'))
#' Build mock alternate study cohort
alt_cohort <- cdm_tbl('person') %>% dplyr::distinct(person_id) %>%
head(100) %>%
dplyr::mutate(start_date = as.Date(-5000),
#RSQLite does not store date objects,
#hence the numerics
end_date = as.Date(15000),
site = ifelse(person_id %in% c(1:6), 'synth1', 'synth2'))
#' Prepare input tables
ssc_domain_tbl <- dplyr::tibble(domain = c('all conditions', 'outpatient visits'),
domain_tbl = c('condition_occurrence', 'visit_occurrence'),
concept_field = c('condition_concept_id', 'visit_concept_id'),
date_field = c('condition_start_date', 'visit_start_date'),
vocabulary_field = c(NA, NA),
filter_logic = c(NA, 'visit_concept_id == 9202'))
ssc_outcome_tbl <- read_codeset('dx_hypertension') %>%
dplyr::mutate(variable = 'hypertension', domain = 'all conditions')
#' Execute `ssc_process` function
#' This example will use the single site, exploratory, cross sectional
#' configuration
ssc_process_example <- ssc_process(base_cohort = base_cohort,
alt_cohorts = list('Sample Alternate' = alt_cohort),
omop_or_pcornet = 'omop',
multi_or_single_site = 'single',
anomaly_or_exploratory = 'exploratory',
domain_tbl = ssc_domain_tbl,
domain_select = c('all conditions', 'outpatient visits'),
outcome_concepts = ssc_outcome_tbl) %>%
suppressMessages()
#> Warning: Missing values are always removed in SQL aggregation functions.
#> Use `na.rm = TRUE` to silence this warning
#> This warning is displayed once every 8 hours.
#> ┌ Output Function Details ──────────────────────────────────────┐
#> │ You can optionally use this dataframe in the accompanying │
#> │ `ssc_output` function. Here are the parameters you will need: │
#> │ │
#> │ Always Required: process_output │
#> │ Required for Check: alt_cohort_filter │
#> │ │
#> │ See ?ssc_output for more details. │
#> └───────────────────────────────────────────────────────────────┘
ssc_process_example
#> $summary_values
#> # A tibble: 28 × 7
#> site cohort_id cohort_characteristic fact_group fact_summary cohort_total_pt
#> <chr> <chr> <chr> <chr> <dbl> <int>
#> 1 comb… Sample A… median_age_cohort_en… Cohort De… -12.0 12
#> 2 comb… Sample A… median_age_first_vis… Cohort De… 1.46 12
#> 3 comb… Sample A… median_all condition… Clinical … 0 12
#> 4 comb… Sample A… median_fu Cohort De… 0 12
#> 5 comb… Sample A… median_outpatient vi… Utilizati… 0 12
#> 6 comb… base_coh… median_age_cohort_en… Cohort De… -12.0 12
#> 7 comb… base_coh… median_age_first_vis… Cohort De… 1.46 12
#> 8 comb… base_coh… median_all condition… Clinical … 0 12
#> 9 comb… base_coh… median_fu Cohort De… 0 12
#> 10 comb… base_coh… median_outpatient vi… Utilizati… 0 12
#> # ℹ 18 more rows
#> # ℹ 1 more variable: output_function <chr>
#>
#> $cohort_overlap
#> # A tibble: 1 × 3
#> site cohort_group group_ct
#> <chr> <chr> <int>
#> 1 combined base_cohort&Sample Alternate 12
#>
#' Execute `ssc_output` function
ssc_output_example <- ssc_output(process_output = ssc_process_example,
alt_cohort_filter = 'Sample Alternate') %>%
suppressMessages()
#> Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
#> ℹ Please use tidy evaluation idioms with `aes()`.
#> ℹ See also `vignette("ggplot2-in-packages")` for more information.
#> ℹ The deprecated feature was likely used in the UpSetR package.
#> Please report the issue to the authors.
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` instead.
#> ℹ The deprecated feature was likely used in the UpSetR package.
#> Please report the issue to the authors.
#> Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
#> ℹ Please use the `linewidth` argument instead.
#> ℹ The deprecated feature was likely used in the UpSetR package.
#> Please report the issue to the authors.
ssc_output_example[[1]]
ssc_output_example[[2]]
#' Easily convert the graph into an interactive ggiraph or plotly object with
#' `make_interactive_squba()`
make_interactive_squba(ssc_output_example[[2]])
#> Warning: geom_GeomLabel() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues
#> Warning: geom_GeomLabel() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues