Title: | Charts for Monitoring Clinical Trial Safety |
---|---|
Description: | Contains chart code for monitoring clinical trial safety. Charts can be used as standalone output, but are also designed for use with the 'safetyGraphics' package, which makes it easy to load data and customize the charts using an interactive web-based interface created with Shiny. |
Authors: | Jeremy Wildfire [aut, cre] |
Maintainer: | Jeremy Wildfire <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0 |
Built: | 2025-02-18 06:30:14 UTC |
Source: | https://github.com/safetygraphics/safetycharts |
Convience mapping of render_widget for aeExplorer.
aeExplorer( data = list(dm = safetyData::sdtm_dm, aes = safetyData::sdtm_ae), mapping = NULL, ... )
aeExplorer( data = list(dm = safetyData::sdtm_dm, aes = safetyData::sdtm_ae), mapping = NULL, ... )
data |
|
mapping |
|
... |
additional options to be added to mapping. Will overwrite mapping. |
The data and
mapping should match the specs
described in the aeExplorer
JavaScript library. Items passed in ... are added to mapping, and then the list is converted to
JSON via jsonlite::toJSON(mapping, auto_unbox=TRUE, NULL="NULL")
.
The default mapping shown below is designed to work with data in the CDISC ADaM format (like
safetydata::adam_adlbc
).
mapping <- list( dm = list( id_col = 'USUBJID', treatment_col = 'ARM' ), aes = list( id_col = 'USUBJID', bodsys_col = 'AEBODSYS', term_col = 'AEDECOD' ) )
Parameters that are not included in the default mapping can be accessed via ....
For more options see the full specs in the JavaScript library.
## Not run: # Render widget with defaults. aeExplorer() # Render widget without stratification. aeExplorer( mapping = list( dm = list( id_col = 'USUBJID' ), aes = list( id_col = 'USUBJID', bodsys_col = 'AEBODSYS', term_col = 'AEDECOD' ) ) ) ## End(Not run)
## Not run: # Render widget with defaults. aeExplorer() # Render widget without stratification. aeExplorer( mapping = list( dm = list( id_col = 'USUBJID' ), aes = list( id_col = 'USUBJID', bodsys_col = 'AEBODSYS', term_col = 'AEDECOD' ) ) ) ## End(Not run)
Demographics Table RTF - UI
demogRTF_server(input, output, session, params)
demogRTF_server(input, output, session, params)
input |
module input |
output |
module output |
session |
module session |
params |
parameters object with |
returns shiny module Server function
create demographics RTF table
demogRTF_table(data, settings)
demogRTF_table(data, settings)
data |
demographics data frame with columns specified in settings object |
settings |
list with parameters specifying the column names for:
|
rtf doc object
settings <- list(treatment_col = "ARM", sex_col = "SEX", race_col = "RACE", age_col = "AGE") demogRTF_table(safetyData::sdtm_dm, settings)
settings <- list(treatment_col = "ARM", sex_col = "SEX", race_col = "RACE", age_col = "AGE") demogRTF_table(safetyData::sdtm_dm, settings)
Demographics Table RTF - UI
demogRTF_ui(id)
demogRTF_ui(id)
id |
module id |
returns shiny module UI
Convience mapping of render_widget for hepExplorer.
hepExplorer(data = safetyData::adam_adlbc, mapping = NULL, ...)
hepExplorer(data = safetyData::adam_adlbc, mapping = NULL, ...)
data |
|
mapping |
|
... |
additional options to be added to mapping. Will overwrite mapping. |
The data and mapping should match the specs described in the hepExplorer javascript library. Items passed in ... are added to mapping, and then the list is converted to json via jsonlite::toJSON(mapping, auto_unbox=TRUE, null="null")
.
The default mapping shown below is designed to work with data in the CDISC ADaM format (like safetydata::adam_adlbc
).
mapping <- list( measure_col = "PARAM", measure_values = list( ALT = "Alanine Aminotransferase (U/L)", AST = "Aspartate Aminotransferase (U/L)", TB = "Bilirubin (umol/L)", ALP = "Alkaline Phosphatase (U/L)" ), id_col = "USUBJID", value_col = "AVAL", normal_col_low = "A1LO", normal_col_high = "A1HI", studyday_col = "ADY", visit_col = "VISIT", visitn_col = "VISITNUM" )
Parameters that are not included in the default mapping can be accessed via ...; Key options and defaults for safetyData::adam_adlbc shown below:
filters
: list of columns to be included as data filters (e.g. 'filters=c("SEX","AGEGR1")“)
group_cols
: list of columns used to define grouping and set point color (e.g. 'filters=c("SEX","AGEGR1")“)
x_options
and y_options
- specify which labs can be used for x and y axis dropdowns. By default, all options are included on x-axis, but only Bilirubin is shown on y-axis. To allow an interactive y-axis, use y_options="all"
.
baseline
- flag defining the baseline visit for each participant. baseline
must be provided to enable the mDish view on the hep-explorer chart. Define as a list with value_col
and values
(e.g. baseline=list(value_col="ABLFL",values="Y")
)
title
and warningText
- Strings used to define the header text shown above the filters.
For more options see the full specs in the javascript library.
## Not run: # Render widget with defaults hepExplorer() # Add age group to default hepExplorer(group_cols=c("SEX","AGEGR1")) # Enable interactive y-axis hepExplorer(y_options='all') # Use custom mapping for SDTM data hepExplorer( data=safetyData::sdtm_lb, measure_col = "LBTEST", measure_values = list( ALT = "Alanine Aminotransferase", AST = "Aspartate Aminotransferase", TB = "Bilirubin", ALP = "Alkaline Phosphatase" ), id_col = "USUBJID", value_col = "LBSTRESN", normal_col_low = "LBORNRLO", normal_col_high = "LBORNRHI", studyday_col = "LBDY", visit_col = "VISIT", visitn_col = "VISITNUM" ) ## End(Not run)
## Not run: # Render widget with defaults hepExplorer() # Add age group to default hepExplorer(group_cols=c("SEX","AGEGR1")) # Enable interactive y-axis hepExplorer(y_options='all') # Use custom mapping for SDTM data hepExplorer( data=safetyData::sdtm_lb, measure_col = "LBTEST", measure_values = list( ALT = "Alanine Aminotransferase", AST = "Aspartate Aminotransferase", TB = "Bilirubin", ALP = "Alkaline Phosphatase" ), id_col = "USUBJID", value_col = "LBSTRESN", normal_col_low = "LBORNRLO", normal_col_high = "LBORNRHI", studyday_col = "LBDY", visit_col = "VISIT", visitn_col = "VISITNUM" ) ## End(Not run)
Initialize Settings for Adverse Event Explorer widget
init_aeExplorer(data, settings)
init_aeExplorer(data, settings)
data |
|
settings |
|
returns list with data and settings
Initialize Settings for AE Timeline widget
init_aeTimelines(data, settings)
init_aeTimelines(data, settings)
data |
adverse events data structured as one record per event. See details for column requirements. |
settings |
named list of settings |
returns list with data and settings
Initialize Settings for Conmeds Explorer widget
init_cmExplorer(data, settings)
init_cmExplorer(data, settings)
data |
Con meds and demographics data. See details for column requirements. |
settings |
named list of settings |
returns list with data and settings
Initialize Settings for Medical History Explorer widget
init_mhExplorer(data, settings)
init_mhExplorer(data, settings)
data |
medical history and demographics data. |
settings |
named list of settings |
returns list with data and settings
Initialize Settings for Paneled Outlier Explorer widget
init_paneledOutlierExplorer(data, settings)
init_paneledOutlierExplorer(data, settings)
data |
labs data structured as one record per person per visit per measurement. See details for column requirements. |
settings |
named list of settings |
returns list with data and settings
Initialize Settings for Safety Outlier Explorer widget
init_safetyOutlierExplorer(data, settings)
init_safetyOutlierExplorer(data, settings)
data |
labs data structured as one record per person per visit per measurement. See details for column requirements. |
settings |
named list of settings |
returns list with data and settings
Initialize Settings for Safety Results Over Time widget
init_safetyResultsOverTime(data, settings)
init_safetyResultsOverTime(data, settings)
data |
labs data structured as one record per person per visit per measurement. See details for column requirements. |
settings |
named list of settings |
returns list with data and settings
Initialize Settings for Safety Shift Plot widget
init_safetyShiftPlot(data, settings)
init_safetyShiftPlot(data, settings)
data |
labs data structured as one record per person per visit per measurement. See details for column requirements. |
settings |
named list of settings |
returns list with data and settings
A simple server for a shiny module looking at lab histograms. Intended primarily for technical demos.
lab_distribution_server(input, output, session, params)
lab_distribution_server(input, output, session, params)
input |
module input |
output |
module output |
session |
module session |
params |
parameters object with |
returns shiny module Server function
A simple UI for a shiny module looking at lab histograms. Intended primarily for technical demos.
lab_distribution_ui(id)
lab_distribution_ui(id)
id |
module id |
returns shiny module UI
Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the ae domain. One record per unique data mapping
meta_aes
meta_aes
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics for the Concomitant medications Domain. One record per unique data mapping
meta_cm
meta_cm
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the dm domain. One record per unique data mapping
meta_dm
meta_dm
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the ecg domain. One record per unique data mapping
meta_ecg
meta_ecg
A data frame with 22 rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics for the Exposure Domain. One record per unique data mapping
meta_ex
meta_ex
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics for the hepExplorer Chart. One record per unique data mapping
meta_hepExplorer
meta_hepExplorer
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the labs domain. One record per unique data mapping
meta_labs
meta_labs
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics for the Medical History Domain. One record per unique data mapping
meta_mh
meta_mh
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the vital signs domain. One record per unique data mapping
meta_vitals
meta_vitals
A data frame with X rows and 10 columns
Data domain
Text key indicating the setting name. '--'
delimiter indicates a field level data mapping
Key for the column mapping
Key for the field mapping (if any)
type of mapping - "field" or "column"
Label
Description
Mapping supports multiple columns/fields
Default values for the ADaM data standard
Default values for the SDTM data standard
Created for this package
Convience mapping of render_widget for paneledOutlierExplorer.
paneledOutlierExplorer(df = safetyData::adam_adlbc, mapping = NULL, ...)
paneledOutlierExplorer(df = safetyData::adam_adlbc, mapping = NULL, ...)
df |
data frame containing lab data used to render for paneledOutlierExplorer. Default is safetyData::adam_adlbc. |
mapping |
named list with the current data mappings. See details for default mapping. |
... |
additional options to be added to mapping. Will overwrite mapping. |
The data and mapping should match the specs described in the paneledOutlierExplorer javascript library. Items passed in ... are added to mapping, and then the list is converted to json via jsonlite::toJSON(mapping, auto_unbox=TRUE, null="null")
.
The default mapping shown below is designed to work with data in the CDISC ADaM format (like safetydata::adam_adlbc
).
mapping <- list( measure_col = 'PARAM', time_cols = list( list( value_col = "VISIT", order_col = "VISITNUM", label = "VISIT", type = 'ordinal', label="Visit", rotate_tick_labels = TRUE, vertical_space = 75 ), list( value_col = "ADY", order_col = "ADY", label = "Study Day", type = 'linear', label="Visit", rotate_tick_labels = FALSE, vertical_space = 0 ) ), value_col = 'AVAL', id_col = 'USUBJID', lln_col = 'A1LO', uln_col = 'A1HI' )
Parameters that are not included in the default mapping can be accessed via ...; Key options and defaults for safetyData::adam_adlbc shown below:
filters
: list of columns to be included as data filters formatted as 'filters=c("SEX","AGEGR1")“)
For more options see the full specs in the javascript library.
## Not run: # Render widget with defaults paneledOutlierExplorer() # Add Sex and Age Filters paneledOutlierExplorer( filters=list( list(value_col="SEX"), list(value_col="AGEGR1",label="Age") ) ) # customize panel size (in pixels) paneledOutlierExplorer(multiples_sizing=list("width"= 500,"height"= 300)) # customize default normal range paneledOutlierExplorer( normal_range_method = 'quantiles', normal_range_quantile_low = 0.2, normal_range_quantile_high = 0.8, ) ## End(Not run)
## Not run: # Render widget with defaults paneledOutlierExplorer() # Add Sex and Age Filters paneledOutlierExplorer( filters=list( list(value_col="SEX"), list(value_col="AGEGR1",label="Age") ) ) # customize panel size (in pixels) paneledOutlierExplorer(multiples_sizing=list("width"= 500,"height"= 300)) # customize default normal range paneledOutlierExplorer( normal_range_method = 'quantiles', normal_range_quantile_low = 0.2, normal_range_quantile_high = 0.8, ) ## End(Not run)
QT Outlier Explorer
QT_Outlier_Explorer(data, settings)
QT_Outlier_Explorer(data, settings)
data |
ECG data structured as one record per person per visit per measurement. See details for column requirements. |
settings |
named list of settings with the parameters specified below. |
The settings object provides details the columns in the data set.
"id_col"ID column
"value_col"Value column
"measure_col"Measure column
"measure_values"Measure values
"visit_col"Visit column
"visitn_col"Visit number column (numeric)
"baseline_flag_colBaseline flag column
"baseline_flag_valuesBaseline flag value
returns a chart object
QT Outlier Explorer Module - UI
QT_OutlierExplorer_server(input, output, session, params)
QT_OutlierExplorer_server(input, output, session, params)
input |
module input |
output |
module output |
session |
module session |
params |
parameters object with |
returns shiny module Server function
QT Outlier Explorer Module - UI
QT_OutlierExplorer_ui(id)
QT_OutlierExplorer_ui(id)
id |
module id |
returns shiny module UI
Render an htmlwidget using standard safetyGraphics workflow
render_widget(widgetName, data, mapping)
render_widget(widgetName, data, mapping)
widgetName |
name of the widget saved in safetyCharts |
data |
named list of current data sets |
mapping |
named list with the current data mappings |
Safety Outlier Explorer
safety_outlier_explorer(data, settings)
safety_outlier_explorer(data, settings)
data |
labs data structured as one record per person per visit per measurement. See details for column requirements. |
settings |
named list of settings with the parameters specified below. |
The settings object provides details the columns in the data set.
"id_col"ID column
"value_col"Value column
"measure_col"Measure column
"measure_values"Measure values
"studyday_col"Study Day (numeric)
returns a chart object
settings <- list( id_col = "USUBJID", measure_col = "LBTEST", measure_values = c("Albumin", "Bilirubin", "Chloride"), studyday_col = "VISITDY", value_col = "LBORRES" ) safety_outlier_explorer(safetyData::sdtm_lb, settings)
settings <- list( id_col = "USUBJID", measure_col = "LBTEST", measure_values = c("Albumin", "Bilirubin", "Chloride"), studyday_col = "VISITDY", value_col = "LBORRES" ) safety_outlier_explorer(safetyData::sdtm_lb, settings)
Safety Results Over Time plot
safety_results_over_time(data, settings)
safety_results_over_time(data, settings)
data |
labs data structured as one record per person per visit per measurement. See details for column requirements. |
settings |
named list of settings with the parameters specified below. |
The settings object provides details the columns in the data set.
"value_col"Value column
"measure_col"Measure column
"measure_values"Measure values
"visit_col"Study Visit
"visitn_col"Study Number
"group_col"Grouping column
"violins"Show Violin plots?
"boxplots"Show Box Plots?
"axis"set to "log" to use a log transformed axis, linear otherwise
"drop_visit_string"Drop visits that contain this string. e.g. "unscheduled"
returns a chart object
library(dplyr) lb <- safetyData::sdtm_lb sub_ids <- unique(lb$USUBJID)[1:100] lb<-lb %>% filter(USUBJID %in% sub_ids) settings <- list( value_col = "LBORRES", measure_col = "LBTEST", measure_values = c("Chloride"), visit_col = "VISIT", visitn_col = "VISITNUM", axis = "log" ) safety_results_over_time(lb, settings) # remove unscheduled visits, add violin plot and 2nd panel settings$drop_visit_string <- "unscheduled" settings$violins <- TRUE settings$measure_values <- c("Albumin") safety_results_over_time(lb, settings) # add grouping by treatment dm_sub <- safetyData::sdtm_dm %>% select(USUBJID, ARM) dm_lb <- dm_sub %>% left_join(lb) settings$group_col <- "ARM" safety_results_over_time(dm_lb, settings)
library(dplyr) lb <- safetyData::sdtm_lb sub_ids <- unique(lb$USUBJID)[1:100] lb<-lb %>% filter(USUBJID %in% sub_ids) settings <- list( value_col = "LBORRES", measure_col = "LBTEST", measure_values = c("Chloride"), visit_col = "VISIT", visitn_col = "VISITNUM", axis = "log" ) safety_results_over_time(lb, settings) # remove unscheduled visits, add violin plot and 2nd panel settings$drop_visit_string <- "unscheduled" settings$violins <- TRUE settings$measure_values <- c("Albumin") safety_results_over_time(lb, settings) # add grouping by treatment dm_sub <- safetyData::sdtm_dm %>% select(USUBJID, ARM) dm_lb <- dm_sub %>% left_join(lb) settings$group_col <- "ARM" safety_results_over_time(dm_lb, settings)
Safety Outlier Explorer Module - UI
safetyOutlierExplorer_server(input, output, session, params)
safetyOutlierExplorer_server(input, output, session, params)
input |
module input |
output |
module output |
session |
module session |
params |
parameters object with |
returns shiny module Server function
Safety Outlier Explorer Module - UI
safetyOutlierExplorer_ui(id)
safetyOutlierExplorer_ui(id)
id |
module id |
returns shiny module UI
Combine Event Domains
stack_events( data = list(aes = safetyData::sdtm_ae, cm = safetyData::sdtm_cm, ex = safetyData::sdtm_ex), settings = list(aes = rlang::set_names(as.list(safetyCharts::meta_aes$standard_sdtm), safetyCharts::meta_aes$col_key), cm = rlang::set_names(as.list(safetyCharts::meta_cm$standard_sdtm), safetyCharts::meta_cm$col_key), ex = rlang::set_names(as.list(safetyCharts::meta_ex$standard_sdtm), safetyCharts::meta_ex$col_key)), domains = c("aes", "cm", "ex") )
stack_events( data = list(aes = safetyData::sdtm_ae, cm = safetyData::sdtm_cm, ex = safetyData::sdtm_ex), settings = list(aes = rlang::set_names(as.list(safetyCharts::meta_aes$standard_sdtm), safetyCharts::meta_aes$col_key), cm = rlang::set_names(as.list(safetyCharts::meta_cm$standard_sdtm), safetyCharts::meta_cm$col_key), ex = rlang::set_names(as.list(safetyCharts::meta_ex$standard_sdtm), safetyCharts::meta_ex$col_key)), domains = c("aes", "cm", "ex") )
data |
|
settings |
|
domains |
|
combined dataset with stacked AE and CM data
stack_events()
stack_events()
Create an event data set with a standard set of hard-coded column names using standard safetyGraphics settings and data. The settings for each specified domain should contain valid mappings for ID ("id_col"), event start date ("stdy_col") and event end date ("endy_col"). Missing start day and end day values are extrapolated to NA. All other columns specified in settings are collapsed into a single "details" column. The final standardized data contains the following columns: "id", "domain", "stdy", "endy", "details".
standardize_events(data, settings, domain = "")
standardize_events(data, settings, domain = "")
data |
|
settings |
|
domain |
|
combined dataset with stacked AE and CM data
Create a plot using the Tendril package
tendril_chart(data, settings)
tendril_chart(data, settings)
data |
list of data frames including dataframes named |
settings |
named list of domain-specific settings with the parameters specified below. |
The settings object provides details regarding the columns in the data sets.
"settings$dm$id_col"ID column
"settings$dm$treatment_col"Treatment column
"settings$dm$treatment_values–group1"Name of treatment 1
"settings$dm$treatment_values–group2"Name of treatment 2
"settings$aes$id_col"ID column)
"settings$aes$bodsys_col"Body System
"settings$aes$stdy_col"Study Day
returns a chart object