Title: | Interactive Graphics for Monitoring Clinical Trial Safety |
---|---|
Description: | A framework for evaluation of clinical trial safety. Users can interactively explore their data using the included 'Shiny' application. |
Authors: | Jeremy Wildfire [cre, aut], Becca Krouse [aut], Preston Burns [aut], Xiao Ni [aut], James Buchanan [aut], Susan Duke [aut] |
Maintainer: | Jeremy Wildfire <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.1.1 |
Built: | 2025-01-24 05:44:45 UTC |
Source: | https://github.com/safetygraphics/safetygraphics |
Prepare inputs for safetyGraphics app - run before app is initialized.
app_startup( domainData = NULL, meta = NULL, charts = NULL, mapping = NULL, autoMapping = NULL, filterDomain = NULL, chartSettingsPaths = NULL, appName = NULL, hexPath = NULL, homeTabPath = NULL )
app_startup( domainData = NULL, meta = NULL, charts = NULL, mapping = NULL, autoMapping = NULL, filterDomain = NULL, chartSettingsPaths = NULL, appName = NULL, hexPath = NULL, homeTabPath = NULL )
domainData |
named list of data.frames to be loaded in to the app. Sample AdAM data from the safetyData package used by default |
meta |
data frame containing the metadata for use in the app. If no metadata is provided (default value is NULL), metatdata is generated by |
charts |
list of charts in the format produced by safetyGraphics::makeChartConfig() |
mapping |
list specifying the initial mapping values for each data mapping for each domain (e.g. list(aes= list(id_col='USUBJID', seq_col='AESEQ')). |
autoMapping |
boolean indicating whether the app should attempt to automatically detect data standards and generate mappings for the data provided. Values specified in the |
filterDomain |
domain used for the data/filter tab. Demographics (" |
chartSettingsPaths |
path(s) where customization functions are saved relative to your working directory. All charts can have initialization (e.g. myChart_Init.R) and static charts can have charting functions (e.g. myGraphic_Chart.R). All R files in this folder are sourced and files with the correct naming convention are linked to the chart. See the Custom Charts vignette for more details. |
appName |
character string defining the name of the app (default = "safetyGraphics") |
hexPath |
path to image file with a hex or other logo. safetyGraphics hex used by default. |
homeTabPath |
path to html content to be used on the home page. default is a summary of the safetyGraphics framework. |
List of elements for used to initialize the shiny app with the following parameters
"meta" List of configuration metadata
"charts" List of charts
"domainData" List of domain level data sets
"mapping" Initial Data Mapping
"standards" List of domain level data standards
Server for chart module, designed to be re-used for each chart generated.
chartsTab(input, output, session, chart, data, mapping, status)
chartsTab(input, output, session, chart, data, mapping, status)
input |
Input objects from module namespace |
output |
Output objects from module namespace |
session |
An environment that can be used to access information and functionality relating to the session |
chart |
list containing a safetyGraphics chart object like those returned by makeChartConfig. |
data |
named list of current data sets (Reactive). |
mapping |
tibble capturing the current data mappings (Reactive). |
status |
chart status (Reactive) |
UI for chart module, designed to be re-used for each chart generated.
chartsTabUI(id, chart)
chartsTabUI(id, chart)
id |
module id |
chart |
list containing chart specifications like those returned by makeChartConfig. |
This function attempts to detect the clinical data standard used in a given R data frame.
detectStandard(data, domain = NULL, meta = NULL)
detectStandard(data, domain = NULL, meta = NULL)
data |
A data frame in which to detect the data standard - required. |
domain |
the domain to evaluate - should match a value of |
meta |
the metadata containing the data standards. |
This function compares the columns in the provided "data"
with the required columns for a given data standard/domain combination. The function is designed to work with the SDTM and ADaM CDISC(https://www.cdisc.org/) standards for clinical trial data by default. Additional standards can be added by modifying the "meta"
data set included as part of this package.
A data frame describing the detected standard for each "text_key"
in the provided metadata. Columns are "domain"
, "text_key"
, "column"
and "standard"
.
detectStandard(data=safetyData::adam_adae, meta=safetyCharts::meta_aes) detectStandard(data=safetyData::adam_adlbc,meta=safetyCharts::meta_labs, domain="labs" )
detectStandard(data=safetyData::adam_adae, meta=safetyCharts::meta_aes) detectStandard(data=safetyData::adam_adlbc,meta=safetyCharts::meta_labs, domain="labs" )
Determines whether the required data elements in a data standard are found in a given data frame
evaluateStandard(data, meta, domain, standard)
evaluateStandard(data, meta, domain, standard)
data |
A data frame in which to detect the data standard |
meta |
the metadata containing the data standards. |
domain |
the domain to evaluate - should match a value of |
standard |
standard to evaluate |
a list describing to what degree the data set matches the data standard. The "match" property describes compliance with the standard as "full", "partial" or "none". The "checks" property is a list of the data elements expected for the standard and whether they are "valid" in the given data set. "total_checks", "valid_checks" and "invalid_checks" provide counts of the specified checks. "match_percent" is calculated as valid_checks/total_checks. "mapping" is a data frame describing the detected standard for each "text_key"
in the provided metadata. Columns are "text_key"
, "current"
containing the name of the matched column or field value in the data and "match"
a boolean indicating whether the data matches the standard.
# Match is TRUE evaluateStandard( data=safetyData::adam_adlbc, meta=safetyCharts::meta_labs, domain="labs", standard="adam" ) # Match is FALSE evaluateStandard( data=safetyData::adam_adlbc, meta=safetyCharts::meta_labs, domain="labs", standard="sdtm" )
# Match is TRUE evaluateStandard( data=safetyData::adam_adlbc, meta=safetyCharts::meta_labs, domain="labs", standard="adam" ) # Match is FALSE evaluateStandard( data=safetyData::adam_adlbc, meta=safetyCharts::meta_labs, domain="labs", standard="sdtm" )
Server for the filter module in datamods::filter_data_ui
filterTab( input, output, session, domainData, filterDomain, current_mapping, tabID = "Filtering", filterVars = NULL )
filterTab( input, output, session, domainData, filterDomain, current_mapping, tabID = "Filtering", filterVars = NULL )
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
domainData |
list of data files for each domain |
filterDomain |
domain to use for filtering (typically "dm") |
current_mapping |
current data mapping |
tabID |
ID for the tab containing the filter UI (used for testing) |
filterVars |
Variables to use for filtering (used for testing) |
filtered data set
Checks for whether the current data and settings support a filter tab
filterTabChecks(domainData, filterDomain, current_mapping)
filterTabChecks(domainData, filterDomain, current_mapping)
domainData |
list of data files for each domain |
filterDomain |
domain to use for filtering (typically "dm") |
current_mapping |
current data mapping (REACTIVE) |
reactive that returns a boolean indicating whether the checks passed and filtering can be initialized
UI for the filter module in datamods::filter_data_ui
filterTabUI(id)
filterTabUI(id)
id |
module id |
Convert mapping data.frame to a list
generateMappingList(settingsDF, domain = NULL, pull = FALSE)
generateMappingList(settingsDF, domain = NULL, pull = FALSE)
settingsDF |
data frame containing current mapping |
domain |
mapping domain to return (returns all domains as a named list by default) |
pull |
call pull() the value for each parameter - needed for testing only. default: FALSE |
Server for the filter module in datamods::filter_data_ui
homeTab(input, output, session, config)
homeTab(input, output, session, config)
input |
mod input |
output |
mod output |
session |
mod session |
UI for the home module
homeTabUI(id)
homeTabUI(id)
id |
module id |
Server for the chart loading module used in safetyGraphicsInit()
loadCharts(input, output, session, charts = makeChartConfig())
loadCharts(input, output, session, charts = makeChartConfig())
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
charts |
list containing chart specifications like those returned by makeChartConfig. |
UI for the chart loading module used in safetyGraphicsInit()
loadChartsUI(id, charts = makeChartConfig())
loadChartsUI(id, charts = makeChartConfig())
id |
module id |
charts |
list containing chart specifications like those returned by makeChartConfig. |
Server for the data loading module used in safetyGraphicsInit()
loadData(input, output, session, domain)
loadData(input, output, session, domain)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
domain |
data domain to be loaded |
UI for the data loading module used in safetyGraphicsInit()
loadDataUI(id, domain = NULL)
loadDataUI(id, domain = NULL)
id |
module id |
domain |
character vector with domains to be loaded |
Converts YAML chart configuration files to an R list and binds workflow functions. See the vignette about creating custom charts for more details.
makeChartConfig( dirs, packages = "safetyCharts", packageLocation = "config", sourceFiles = FALSE )
makeChartConfig( dirs, packages = "safetyCharts", packageLocation = "config", sourceFiles = FALSE )
dirs |
path to one or more directories containing yaml config files (relative to working directory) |
packages |
installed packages names containing yaml config files in the /inst/packageLocation folder |
packageLocation |
inst folder where yaml config files (and possibly R functions referenced in yaml workflow) are located in |
sourceFiles |
boolean indicating whether to source all R files found in dirs. |
returns a named list of charts derived from YAML files. Each element of the list contains information about a single chart, and has the following parameters:
"env" Environment for the chart. Must be set to "safetyGraphics" or the chart is dropped.
"name" Name of the chart. Also the name of the element in the list - e.g. charts$aeExplorer$name is "aeExplorer"
"label" Short description of the chart
"type" Type of chart; options are: 'htmlwidget', 'module', 'plot', 'table', 'html' or 'plotly'.
"domain" Data domain. Should correspond to one or more domains in meta
"package" Primary package (if any). Other packages can be loaded directly in workflow functions.
"order" Integer order in which to display the chart. If order is a negative number, the chart is dropped.
"export" Logical flag indicating whether the chart can be exported to an html report. True by default, except for when type is module.
"path" Path to YAML file
"links" Named list of link names/urls to be shown in the chart header.
"workflow" List of functions names used to render chart. See vignette for details.
"functions" List of functions for use in chart renderering. These functions must be located in the global environment or package
field of the YAML config. Function names must include either the name
or workflow
fields of the YAML config.
Creates R code that allows chart to be exported
makeChartExport(chart, mapping)
makeChartExport(chart, mapping)
chart |
chart object like the one generated by makeChartConfig(). |
mapping |
mapping object like the one generated by makeMapping(). |
returns a character vector that can be saved as R code.
Updates raw data and mapping for use with a specific chart
makeChartParams(data, chart, mapping)
makeChartParams(data, chart, mapping)
data |
list of domain-level data |
chart |
list containing chart specifications |
mapping |
data frame with current mapping |
makes a nicely formatted html summary for a chart object
makeChartSummary( chart, status = NULL, showLinks = TRUE, class = "chart-header" )
makeChartSummary( chart, status = NULL, showLinks = TRUE, class = "chart-header" )
chart |
list containing chart specifications |
status |
(optional) chart status from |
showLinks |
boolean indicating whether to include links |
class |
character to include as class |
Create data mapping based on data standards and user input
makeMapping(domainData, meta, autoMapping, customMapping)
makeMapping(domainData, meta, autoMapping, customMapping)
domainData |
named list of data.frames to be loaded in to the app. Sample AdAM data from the safetyData package used by default |
meta |
data frame containing the metadata for use in the app. |
autoMapping |
boolean indicating whether the app should use |
customMapping |
optional list specifying initial mapping values within each data mapping (e.g. list(aes= list(id_col='USUBJID', seq_col='AESEQ')). |
List containing data standard information and mapping
"mapping" Initial Data Mapping
"standards" List of domain level data standards (or NULL if autoMapping is false)
Generates metadata object for a list of charts. makeMeta()
looks for metadata in 3 locations for each chart
object:
Domain-level metadata saved as meta_chart$name in the chart$package namespace
Chart-specific metadata saved as meta_chart$domain in the chart$package namespace
Chart-specific metadata saved directly to the chart object as chart$meta After checking all charts, all metadata files are stacked in to a single dataframe and returned. If duplicate metadata rows (domain + text_key) are found, an error is thrown.
makeMeta(charts)
makeMeta(charts)
charts |
list of safetyGraphics chart objects for which to create metadata |
tibble of metadata with the following 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
Server that facilitates the mapping of a column data (and any associated fields)
mappingColumn(input, output, session, meta, data)
mappingColumn(input, output, session, meta, data)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
meta |
metadata data frame for the object |
data |
current data file for the domain |
A reactive data.frame providing the current value for text_key associated with the selected column
UI that facilitates the mapping of a column data (and any associated fields)
mappingColumnUI(id, meta, data, mapping = NULL)
mappingColumnUI(id, meta, data, mapping = NULL)
id |
module id |
meta |
metadata for the column (and related fields) |
data |
current data file for the domain |
mapping |
current data mapping for the column (and related fields) |
Server that facilitates the mapping of a full data domain
mappingDomain(input, output, session, meta, data)
mappingDomain(input, output, session, meta, data)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
meta |
metadata for the domain |
data |
clinical data for the domain |
A reactive data frame containing the mapping for the domain
UI that facilitates the mapping of a full data domain
mappingDomainUI(id, meta, data, mapping = NULL)
mappingDomainUI(id, meta, data, mapping = NULL)
id |
module id |
meta |
metadata for the domain |
data |
data file for the domain |
mapping |
current data mapping |
Server that facilitates the mapping of a single data element (column or field) with a simple select UI
mappingSelect(input, output, session)
mappingSelect(input, output, session)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
A reactive containing the selected column
UI that facilitates the mapping of a single data element (column or field) with a simple select UI
mappingSelectUI(id, label, choices = NULL, default = NULL)
mappingSelectUI(id, label, choices = NULL, default = NULL)
id |
unique id for the UI |
label |
label associated with the control |
choices |
a list of options for the control |
default |
default value for the control |
returns the selected value wrapped in a reactive()
.
Server for mapping tab covering of all data domains
mappingTab(input, output, session, meta, domainData)
mappingTab(input, output, session, meta, domainData)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
meta |
metadata for all domains |
domainData |
clinical data for all domains |
list of mappings for all domains
UI for mapping tab covering of all data domains
mappingTabUI(id, meta, domainData, mappings = NULL, standards = NULL)
mappingTabUI(id, meta, domainData, mappings = NULL, standards = NULL)
id |
module id |
meta |
metadata for all domains |
domainData |
list of data files for each domain |
mappings |
optional data frame containing stacked mappings for all domains |
standards |
optional list of data standards like the ones generated by |
Sets default values and binds needed functions to a chart object based on chart type.
prepareChart(chart)
prepareChart(chart)
chart |
chart object like the one generated by makeChartConfig(). |
returns the chart object with a new functions object added.
Server for the patient profile in safetyProfile::profile_server
profileTab(input, output, session, params)
profileTab(input, output, session, params)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
params |
reactive containing mapping and data |
current_id |
reactive containing currently selected participant |
current_id
UI for the profile module in safetyProfile::profile_ui
profileTabUI(id)
profileTabUI(id)
id |
module id |
Run the core safetyGraphics App
safetyGraphicsApp( domainData = list(labs = safetyData::adam_adlbc, aes = safetyData::adam_adae, dm = safetyData::adam_adsl), meta = NULL, charts = NULL, mapping = NULL, autoMapping = TRUE, filterDomain = "dm", chartSettingsPaths = NULL, appName = "safetyGraphics", hexPath = system.file("resources/safetyGraphicsHex.png", package = "safetyGraphics"), homeTabPath = system.file("resources/safetyGraphicsHomeTab.html", package = "safetyGraphics"), launchBrowser = FALSE, runNow = TRUE )
safetyGraphicsApp( domainData = list(labs = safetyData::adam_adlbc, aes = safetyData::adam_adae, dm = safetyData::adam_adsl), meta = NULL, charts = NULL, mapping = NULL, autoMapping = TRUE, filterDomain = "dm", chartSettingsPaths = NULL, appName = "safetyGraphics", hexPath = system.file("resources/safetyGraphicsHex.png", package = "safetyGraphics"), homeTabPath = system.file("resources/safetyGraphicsHomeTab.html", package = "safetyGraphics"), launchBrowser = FALSE, runNow = TRUE )
domainData |
named list of data.frames to be loaded in to the app. Sample AdAM data from the safetyData package used by default |
meta |
data frame containing the metadata for use in the app. If no metadata is provided, metatdata is generated by |
charts |
list of charts in the format produced by safetyGraphics::makeChartConfig() |
mapping |
list specifying the initial mapping values for each data mapping for each domain (e.g. list(aes= list(id_col='USUBJID', seq_col='AESEQ')). |
autoMapping |
boolean indicating whether the app should attempt to automatically detect data standards and generate mappings for the data provided. Values specified in the |
filterDomain |
domain used for the data/filter tab. Demographics (" |
chartSettingsPaths |
path(s) where customization functions are saved relative to your working directory. All charts can have initialization (e.g. myChart_Init.R) and static charts can have charting functions (e.g. myGraphic_Chart.R). All R files in this folder are sourced and files with the correct naming convention are linked to the chart. See the Custom Charts vignette for more details. |
appName |
character string defining the name of the app (default = "safetyGraphics") |
hexPath |
path to image file with a hex or other logo. safetyGraphics hex used by default. |
homeTabPath |
path to html content to be used on the home page. default is a summary of the safetyGraphics framework. |
launchBrowser |
boolean indicating whether to launch the app in a browser. default is false |
runNow |
Should the shiny app object created be run directly? Helpful when writing functions to dispatch to shinyapps, rsconnect, or shinyproxy. |
App to select charts, load data and then initialize the core safetyGraphics app
safetyGraphicsInit( charts = makeChartConfig(), delayTime = 1000, maxFileSize = NULL )
safetyGraphicsInit( charts = makeChartConfig(), delayTime = 1000, maxFileSize = NULL )
charts |
chart object |
delayTime |
time (in ms) between drawing app UI and starting server. Default set to 1000 (1 second), but could need to be higher on slow machine. |
maxFileSize |
maximum file size in MB allowed for file upload |
This function returns a server function suitable for use in shiny::runApp()
safetyGraphicsServer( input, output, session, meta, mapping, domainData, charts, filterDomain, config )
safetyGraphicsServer( input, output, session, meta, mapping, domainData, charts, filterDomain, config )
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
meta |
data frame containing the metadata for use in the app. |
mapping |
current mapping |
domainData |
named list of data.frames to be loaded in to the app. |
charts |
list of charts to include in the app |
filterDomain |
domain used for the data/filter tab. Demographics (" |
UI for the core safetyGraphics app including Home, Mapping, Filter, Charts and Settings modules.
safetyGraphicsUI(id, meta, mapping, domainData, charts, standards, config)
safetyGraphicsUI(id, meta, mapping, domainData, charts, standards, config)
id |
module ID |
meta |
data frame containing the metadata for use in the app. |
mapping |
data.frame specifying the initial values for each data mapping. If no mapping is provided, the app will attempt to generate one via |
domainData |
named list of data.frames to be loaded in to the app. |
charts |
list of charts in the format produced by safetyGraphics::makeChartConfig() |
standards |
a list of information regarding data standards. Each list item should use the format returned by safetyGraphics::detectStandard. |
Server for settings tab showing details for the charts loaded in the app
settingsCharts(input, output, session, charts)
settingsCharts(input, output, session, charts)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
charts |
list data frame summarizing the charts |
UI for settings tab showing details for the charts loaded in the app
settingsChartsUI(id)
settingsChartsUI(id)
id |
module id |
Server for settings tab providing code to re-start the app with current data/settings
settingsCode(input, output, session, mapping, charts, domainData)
settingsCode(input, output, session, mapping, charts, domainData)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
mapping |
mapping |
charts |
charts |
domainData |
data list |
UI for settings tab providing code to re-start the app with current data/settings
settingsCodeUI(id)
settingsCodeUI(id)
id |
module ID |
Server for settings tab showing current data
settingsData(input, output, session, domains)
settingsData(input, output, session, domains)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
domains |
named list of the data.frames for each domain |
UI for settings tab showing current data
settingsDataUI(id)
settingsDataUI(id)
id |
module id |
Server for settings tab showing current mapping
settingsMapping(input, output, session, metadata, mapping)
settingsMapping(input, output, session, metadata, mapping)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
metadata |
Data mapping metadata used for initial loading of app |
mapping |
reactive data frame representing the current metadata mapping. columns = "domain", "text_id" and "current" |
UI for settings tab showing current mapping
settingsMappingUI(id)
settingsMappingUI(id)
id |
module id |
Server for the setting page
settingsTab(input, output, session, domains, metadata, mapping, charts)
settingsTab(input, output, session, domains, metadata, mapping, charts)
input |
Shiny input object |
output |
Shiny output object |
session |
Shiny session object |
domains |
domains |
metadata |
metadata |
mapping |
mapping |
charts |
charts |
UI for the settings tab
settingsTabUI(id)
settingsTabUI(id)
id |
module ID |