Using the tabular output generated by evp_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()
Usage
evp_output(
process_output,
output_level = "patient",
filter_variable = NULL,
large_n = FALSE,
large_n_sites = NULL
)Arguments
- process_output
tabular input || required
The tabular output produced by
evp_process- output_level
string || defaults to
patientA string indicating the analysis level that should be reflected in the plot. All checks utilize this parameter EXCEPT
Single Site, Anomaly Detection, Cross-Sectional, which executes a Jaccard index using only patient counts- filter_variable
string or vector || defaults to
NULLA string or vector with variable names that should be the focus of the analysis. Only a single value is accepted for the following checks:
Multi Site, Exploratory, Longitudinal(non-year time period)Multi Site, Anomaly Detection, LongitudinalSingle Site, Anomaly Detection, Longitudinal
Multiple values (up to 3) are accepted for:
Multi Site, Exploratory, Longitudinal(year time period)
- 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 evp_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 = 'expectedvariablespresent'))
#' 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 = 'evp_process_test',
working_directory = my_directory,
db_conn = conn,
is_json = FALSE,
file_subdirectory = my_file_folder,
cdm_schema = NA)
#> Connected to: :memory:@NA
#' Build mock study cohort
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'))
#' Execute `evp_process` function
#' This example will use the single site, exploratory, cross sectional
#' configuration
evp_process_example <- evp_process(cohort = cohort,
multi_or_single_site = 'single',
anomaly_or_exploratory = 'exploratory',
time = FALSE,
omop_or_pcornet = 'omop',
evp_variable_file = evp_variable_file_omop) %>%
suppressMessages()
#> ┌ Output Function Details ──────────────────────────────────────┐
#> │ You can optionally use this dataframe in the accompanying │
#> │ `evp_output` function. Here are the parameters you will need: │
#> │ │
#> │ Always Required: process_output │
#> │ Required for Check: output_level │
#> │ │
#> │ See ?evp_output for more details. │
#> └───────────────────────────────────────────────────────────────┘
evp_process_example
#> # A tibble: 1 × 9
#> site total_pt_ct total_row_ct variable_pt_ct variable_row_ct prop_pt_variable
#> <chr> <int> <int> <int> <int> <dbl>
#> 1 comb… 7 70 5 5 0.714
#> # ℹ 3 more variables: prop_row_variable <dbl>, variable <chr>,
#> # output_function <chr>
#' Execute `evp_output` function
evp_output_example <- evp_output(process_output = evp_process_example,
output_level = 'patient')
evp_output_example
#' Easily convert the graph into an interactive ggiraph or plotly object with
#' `make_interactive_squba()`
make_interactive_squba(evp_output_example)