Package 'safetyCharts'

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

Help Index


Make standalone aeExplorer html widget

Description

Convience mapping of render_widget for aeExplorer.

Usage

aeExplorer(
  data = list(dm = safetyData::sdtm_dm, aes = safetyData::sdtm_ae),
  mapping = NULL,
  ...
)

Arguments

data

list Named list of data frames that includes participant-level subject data (dm) and event-level adverse event data (aes).

mapping

list Named list with current data mappings. See details for default mapping.

...

additional options to be added to mapping. Will overwrite mapping.

Details

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.

Examples

## 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

Description

Demographics Table RTF - UI

Usage

demogRTF_server(input, output, session, params)

Arguments

input

module input

output

module output

session

module session

params

parameters object with data and settings options.

Value

returns shiny module Server function


create demographics RTF table

Description

create demographics RTF table

Usage

demogRTF_table(data, settings)

Arguments

data

demographics data frame with columns specified in settings object

settings

list with parameters specifying the column names for:

  • sex (settings$sex_col),

  • race (settings$race_col)

  • age (settings$age_Col)

Value

rtf doc object

Examples

settings <- list(treatment_col = "ARM", sex_col = "SEX", race_col = "RACE", age_col = "AGE")
demogRTF_table(safetyData::sdtm_dm, settings)

Demographics Table RTF - UI

Description

Demographics Table RTF - UI

Usage

demogRTF_ui(id)

Arguments

id

module id

Value

returns shiny module UI


Make standalone hepExplorer html widget

Description

Convience mapping of render_widget for hepExplorer.

Usage

hepExplorer(data = safetyData::adam_adlbc, mapping = NULL, ...)

Arguments

data

data.frame Data frame containing lab data used to render hepExplorer. Default: safetyData::adam_adlbc

mapping

list named list with the current data mappings. See details for default mapping.

...

additional options to be added to mapping. Will overwrite mapping.

Details

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.

Examples

## 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

Description

Initialize Settings for Adverse Event Explorer widget

Usage

init_aeExplorer(data, settings)

Arguments

data

list Named list of data frames that includes participant-level subject data (dm) and event-level adverse event data (aes).

settings

list Named list of settings.

Value

returns list with data and settings


Initialize Settings for AE Timeline widget

Description

Initialize Settings for AE Timeline widget

Usage

init_aeTimelines(data, settings)

Arguments

data

adverse events data structured as one record per event. See details for column requirements.

settings

named list of settings

Value

returns list with data and settings


Initialize Settings for Conmeds Explorer widget

Description

Initialize Settings for Conmeds Explorer widget

Usage

init_cmExplorer(data, settings)

Arguments

data

Con meds and demographics data. See details for column requirements.

settings

named list of settings

Value

returns list with data and settings


Initialize Settings for Medical History Explorer widget

Description

Initialize Settings for Medical History Explorer widget

Usage

init_mhExplorer(data, settings)

Arguments

data

medical history and demographics data.

settings

named list of settings

Value

returns list with data and settings


Initialize Settings for Paneled Outlier Explorer widget

Description

Initialize Settings for Paneled Outlier Explorer widget

Usage

init_paneledOutlierExplorer(data, settings)

Arguments

data

labs data structured as one record per person per visit per measurement. See details for column requirements.

settings

named list of settings

Value

returns list with data and settings


Initialize Settings for Safety Outlier Explorer widget

Description

Initialize Settings for Safety Outlier Explorer widget

Usage

init_safetyOutlierExplorer(data, settings)

Arguments

data

labs data structured as one record per person per visit per measurement. See details for column requirements.

settings

named list of settings

Value

returns list with data and settings


Initialize Settings for Safety Results Over Time widget

Description

Initialize Settings for Safety Results Over Time widget

Usage

init_safetyResultsOverTime(data, settings)

Arguments

data

labs data structured as one record per person per visit per measurement. See details for column requirements.

settings

named list of settings

Value

returns list with data and settings


Initialize Settings for Safety Shift Plot widget

Description

Initialize Settings for Safety Shift Plot widget

Usage

init_safetyShiftPlot(data, settings)

Arguments

data

labs data structured as one record per person per visit per measurement. See details for column requirements.

settings

named list of settings

Value

returns list with data and settings


lab distribution Module - Server

Description

A simple server for a shiny module looking at lab histograms. Intended primarily for technical demos.

Usage

lab_distribution_server(input, output, session, params)

Arguments

input

module input

output

module output

session

module session

params

parameters object with data and settings options.

Value

returns shiny module Server function


Lab distribution Module - UI

Description

A simple UI for a shiny module looking at lab histograms. Intended primarily for technical demos.

Usage

lab_distribution_ui(id)

Arguments

id

module id

Value

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the ae domain. One record per unique data mapping

Usage

meta_aes

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics for the Concomitant medications Domain. One record per unique data mapping

Usage

meta_cm

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the dm domain. One record per unique data mapping

Usage

meta_dm

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the ecg domain. One record per unique data mapping

Usage

meta_ecg

Format

A data frame with 22 rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics for the Exposure Domain. One record per unique data mapping

Usage

meta_ex

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics for the hepExplorer Chart. One record per unique data mapping

Usage

meta_hepExplorer

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics charts for the labs domain. One record per unique data mapping

Usage

meta_labs

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

Metadata data frame containing information about the data mapping used to configure safetyGraphics for the Medical History Domain. One record per unique data mapping

Usage

meta_mh

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

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

Description

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

Usage

meta_vitals

Format

A data frame with X rows and 10 columns

domain

Data domain

text_key

Text key indicating the setting name. '--' delimiter indicates a field level data mapping

col_key

Key for the column mapping

field_key

Key for the field mapping (if any)

type

type of mapping - "field" or "column"

label

Label

description

Description

multiple

Mapping supports multiple columns/fields

standard_adam

Default values for the ADaM data standard

standard_sdtm

Default values for the SDTM data standard

Source

Created for this package


Make standalone paneledOutlierExplorer html widget

Description

Convience mapping of render_widget for paneledOutlierExplorer.

Usage

paneledOutlierExplorer(df = safetyData::adam_adlbc, mapping = NULL, ...)

Arguments

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.

Details

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.

Examples

## 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

Description

QT Outlier Explorer

Usage

QT_Outlier_Explorer(data, settings)

Arguments

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.

Details

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

Value

returns a chart object


QT Outlier Explorer Module - UI

Description

QT Outlier Explorer Module - UI

Usage

QT_OutlierExplorer_server(input, output, session, params)

Arguments

input

module input

output

module output

session

module session

params

parameters object with data and settings options.

Value

returns shiny module Server function


QT Outlier Explorer Module - UI

Description

QT Outlier Explorer Module - UI

Usage

QT_OutlierExplorer_ui(id)

Arguments

id

module id

Value

returns shiny module UI


Render an htmlwidget using standard safetyGraphics workflow

Description

Render an htmlwidget using standard safetyGraphics workflow

Usage

render_widget(widgetName, data, mapping)

Arguments

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

Description

Safety Outlier Explorer

Usage

safety_outlier_explorer(data, settings)

Arguments

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.

Details

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)

Value

returns a chart object

Examples

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

Description

Safety Results Over Time plot

Usage

safety_results_over_time(data, settings)

Arguments

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.

Details

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"

Value

returns a chart object

Examples

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

Description

Safety Outlier Explorer Module - UI

Usage

safetyOutlierExplorer_server(input, output, session, params)

Arguments

input

module input

output

module output

session

module session

params

parameters object with data and settings options.

Value

returns shiny module Server function


Safety Outlier Explorer Module - UI

Description

Safety Outlier Explorer Module - UI

Usage

safetyOutlierExplorer_ui(id)

Arguments

id

module id

Value

returns shiny module UI


Combine Event Domains

Description

Combine Event Domains

Usage

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")
)

Arguments

data

list Named list of data domains.

settings

list Named list of settings objects containing column and value mappings.

domains

character Vector of data domain names to stack.

Value

combined dataset with stacked AE and CM data

Examples

stack_events()

Create a standardized event data set

Description

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".

Usage

standardize_events(data, settings, domain = "")

Arguments

data

data.frame Data domain.

settings

list List of column and value mappings.

domain

character Name of data domain.

Value

combined dataset with stacked AE and CM data


Tendril plot

Description

Create a plot using the Tendril package

Usage

tendril_chart(data, settings)

Arguments

data

list of data frames including dataframes named aes (adverse events) and dm (demographics)

settings

named list of domain-specific settings with the parameters specified below.

Details

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

Value

returns a chart object