Skip to content

Commit

Permalink
Merge pull request #313 from SafetyGraphics/dev-v1.0
Browse files Browse the repository at this point in the history
dev-v1.0
  • Loading branch information
jwildfire authored Jun 14, 2019
2 parents b18e48c + 5ff55b4 commit 6e3192c
Show file tree
Hide file tree
Showing 41 changed files with 1,114 additions and 512 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: safetyGraphics
Title: Create Interactive Graphics Related to Clinical Trial Safety
Version: 0.11.0
Version: 1.0.0
Authors@R: c(
person("Jeremy", "Wildfire", email = "jeremy_wildfire@rhoworld.com", role = c("cre","aut")),
person("Becca", "Krouse", role="aut"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ importFrom(purrr,map_lgl)
importFrom(rlang,.data)
importFrom(rlang,parse_expr)
importFrom(shiny,runApp)
importFrom(shiny,shinyOptions)
importFrom(shinyWidgets,materialSwitch)
importFrom(stringr,str_detect)
importFrom(stringr,str_split)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# safetyGraphics v1.0.0

The first production release of safetyGraphics includes many inprovements including the addition of 5 new interactive graphics and an embedded help page with a detailed clinical workflow for using the tool.

# safetyGraphics v0.7.3

Initial CRAN release for safetyGraphics. The safetyGraphics package provides framework for evaluation of clinical trial safety. Users can interactively explore their data using the 'Shiny' application or create standalone 'htmlwidget' charts. Interactive charts are built using 'd3.js' and 'webcharts.js' 'JavaScript' libraries.

See the [github release tracker](https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics/releases) for additional release documentation and links to issues.
See the [GitHub release tracker](https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics/releases) for additional release documentation and links to issues.
2 changes: 1 addition & 1 deletion R/adlbc.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Safety measures sample data
#'
#' A dataset containing anonymized lab data from a clinical trial in the CDISC ADaM format. The structure is 1 record per measure per visit per participant. See a full description of the ADaM data standard \href{https://www.cdisc.org/sites/default/files/members/standard/foundational/adam/adam_implementation_guide_v1.0.pdf}{here}.
#' A dataset containing anonymized lab data from a clinical trial in the CDISC ADaM format. The structure is 1 record per measure per visit per participant. See a full description of the ADaM data standard \href{https://www.cdisc.org/standards/foundational/adam/adam-implementation-guide-v11}{here}.
#'
#' @format A data frame with 10288 rows and 46 variables.
#' \describe{
Expand Down
2 changes: 1 addition & 1 deletion R/detectStandard.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' This function attempts to detect the clinical data standard used in a given R data frame.
#'
#' This function compares the columns in the provided \code{"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 \code{"standardMetadata"} data set included as part of this package. Currently, "labs" is the only domain supported.
#' This function compares the columns in the provided \code{"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 \code{"standardMetadata"} data set included as part of this package. Currently, "labs" is the only domain supported.
#'
#' @param data A data frame in which to detect the data standard
#' @param includeFields specifies whether to check the data set for field level data in addition to columns. Default: \code{TRUE}.
Expand Down
2 changes: 1 addition & 1 deletion R/evaluateStandard.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ evaluateStandard <- function(data, standard, includeFields=TRUE, domain="labs"){
# Get metadata for settings using the specified standard and see if required data elements are found
standardChecks <- getSettingsMetadata(cols=c("text_key", "column_mapping", "field_mapping", "field_column_key", "setting_required","standard_val",standard)) %>%
rename("standard_val"=standard) %>%
filter(.data$column_mapping == TRUE || .data$field_mapping ==TRUE) %>%
filter(.data$column_mapping == TRUE | .data$field_mapping ==TRUE) %>%
filter(.data$setting_required==TRUE) %>%
mutate(type = ifelse(.data$column_mapping, "column", "field")) %>%
rowwise %>%
Expand Down
28 changes: 19 additions & 9 deletions R/generateSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#'
#' This function returns a settings object for the eDish chart based on the specified data standard.
#'
#' The function is designed to work with the SDTM and AdAM CDISC(<https://www.cdisc.org/>) standards for clinical trial data. Currently, eDish is the only chart supported.
#' The function is designed to work with the SDTM and ADaM CDISC(<https://www.cdisc.org/>) standards for clinical trial data. Currently, eDish is the only chart supported.
#'
#' @param standard The data standard for which to create settings. Valid options are "SDTM", "AdAM" or "None". Default: \code{"None"}.
#' @param standard The data standard for which to create settings. Valid options are "sdtm", "adam" or "none". Default: \code{"None"}.
#' @param charts The chart or charts for which settings should be generated. Default: \code{NULL} (uses all available charts).
#' @param useDefaults Specifies whether default values from settingsMetadata should be included in the settings object. Default: \code{TRUE}.
#' @param partial Boolean for whether or not the standard is a partial standard. Default: \code{FALSE}.
#' @param partial_keys Optional character vector of the matched settings if partial is TRUE. Settings should be identified using the text_key format described in ?settingsMetadata. Setting is ignored when partial is FALSE. Default: \code{NULL}.
#' @param custom_settings a tibble with text_key and customValue columns specifiying customizations to be applied to the settings object. Default: \code{NULL}.
#' @param custom_settings A tibble describing custom settings to be added to the settings object. Custom values overwrite default values when provided. Tibble should have text_key and customValue columns. Default: \code{NULL}.
#'
#' @return A list containing the appropriate settings for the selected chart
#'
#' @examples
Expand Down Expand Up @@ -123,14 +124,23 @@ generateSettings <- function(standard="None", charts=NULL, useDefaults=TRUE, par
}
}

#Coerce empty string to NULL
for (i in names(shell)){
if (!is.null(shell[[i]])){
if (shell[[i]][1]==""){
shell[i] <- list(NULL)
#Coerce empty string to NULL for data mappings

data_mappings <- safetyGraphics::getSettingsMetadata(
charts = charts,
cols="text_key",
filter_expr=.data$column_mapping
)
for(text_key in data_mappings){
key <- textKeysToList(text_key)[[1]]
current <- getSettingValue(key,shell)
if (!is.null(current)){
if(length(current) <=1) {
if(current == ""){
shell<-setSettingsValue(key=key, value=NULL, settings=shell)
}
}
}
}

return(shell)
}
2 changes: 1 addition & 1 deletion R/generateShell.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @examples
#'
#' safetyGraphics:::generateShell(charts = "eDish")
#' safetyGraphics:::generateShell(charts = "hepexplorer")
#'
#' @keywords internal

Expand Down
2 changes: 1 addition & 1 deletion R/settingsMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @format A data frame with 29 rows and 17 columns
#' \describe{
#' \item{chart_edish}{Flag indicating if the settings apply to the eDish Chart}
#' \item{chart_hepexplorer}{Flag indicating if the settings apply to the Hepatic Explorer Chart}
#' \item{chart_paneledoutlierexplorer}{Flag indicating if the settings apply to the Paneled Safety Outlier Explorer Chart}
#' \item{chart_safetyhistogram}{Flag indicating if the settings apply to the Safety Histogram Chart}
#' \item{chart_safetyoutlierexplorer}{Flag indicating if the settings apply to the Safety Outlier Explorer Chart}
Expand Down
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

# safetyGraphics: Clinical Trial Safety Graphics with R <img src="inst/safetyGraphicsHex/safetyGraphicsHex.png" width = "175" height = "200" align="right" />

The **safetyGraphics** package provides a framework for evaluation of clinical trial safety in R. The initial release focuses on Evaluation of Drug-Induced Serious Hepatotoxicity (eDISH). A prototype of the eDish interactive graphic is available [here](https://safetygraphics.github.io/safety-eDISH/test/) and is shown below.
The **safetyGraphics** package provides a framework for evaluation of clinical trial safety in R. It includes several safety-focused visualizations to empower clinical data monitoring. Chief among these is the Hepatic Explorer, based on the [Evaluation of the Drug-Induced Serious Hepatotoxicity (eDish)](https://www.ncbi.nlm.nih.gov/pubmed/21332248) visualization. A demo of the Hepatic Explorer interactive graphic is available [here](https://safetygraphics.github.io/hep-explorer/test-page/example1/) and is shown below.

This package is being built in conjunction with the [safety-eDISH](https://github.com/safetyGraphics/safety-eDISH) javascript library. Both packages are under active development with beta testing and an initial release planned for early 2019.
This package is being built in conjunction with the [hep-explorer](https://github.com/SafetyGraphics/hep-explorer) javascript library.

![edishgif](https://user-images.githubusercontent.com/3680095/45834450-02b3a000-bcbc-11e8-8172-324c2fe43521.gif)

Expand All @@ -23,7 +23,7 @@ The Shiny app provides a simple interface for:
```r
devtools::install_github("SafetyGraphics/safetyGraphics")
library("safetyGraphics")
chartBuilderApp() #open the shiny application
safetyGraphicsApp() #open the shiny application
```

### Standalone charts
Expand All @@ -33,17 +33,22 @@ Users can also initialize customized standalone charts with a few lines of code.
```r
devtools::install_github("safetyGraphics/safetyGraphics")
library("safetyGraphics")
eDISH(data=adlbc,
id_col = "USUBJID",
value_col = "AVAL",
measure_col = "PARAM",
visit_col = "VISIT",
visitn_col = "VISITNUM",
studyday_col = "ADY",
normal_col_low = "A1LO",
normal_col_high = "A1HI",
measure_values = list(ALT = "Alanine Aminotransferase (U/L)",
AST = "Aspartate Aminotransferase (U/L)",
TB = "Bilirubin (umol/L)",
ALP = "Alkaline Phosphatase (U/L)"))

settings <- list(
id_col = "USUBJID",
value_col = "AVAL",
measure_col = "PARAM",
visit_col = "VISIT",
visitn_col = "VISITNUM",
studyday_col = "ADY",
normal_col_low = "A1LO",
normal_col_high = "A1HI",
measure_values = list(ALT = "Alanine Aminotransferase (U/L)",
AST = "Aspartate Aminotransferase (U/L)",
TB = "Bilirubin (umol/L)",
ALP = "Alkaline Phosphatase (U/L)")
)

chartRenderer(data=adlbc, settings=settings, chart="hepexplorer")

```
14 changes: 7 additions & 7 deletions data-raw/chartsMetadata.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
chart,main,label,description,repo_url,settings_url,type,maxWidth
edish,safetyedish,eDish,Interactive graphic for the Evaluation of Drug-Induced Serious Hepatotoxicity (eDISH),https://github.com/SafetyGraphics/safety-eDISH,https://github.com/SafetyGraphics/safety-eDISH/wiki/Configuration,htmlwidget,620
safetyhistogram,safetyHistogram,Histogram,"Histogram showing distribution of lab measures, vital signs and other measures related to safety in clinical trials.",https://github.com/RhoInc/safety-histogram,https://github.com/RhoInc/safety-histogram/wiki/Configuration,htmlwidget,1000
safetyoutlierexplorer,safetyOutlierExplorer,Outlier Explorer,"Line Chart highlighting abnormal lab measures, vital signs and other measures related to safety in clinical trials.",https://github.com/RhoInc/safety-outlier-explorer,https://github.com/RhoInc/safety-outlier-explorer/wiki/Configuration,htmlwidget,1000
safetyshiftplot,safetyShiftPlot,Shift Plot,Shift Plot for Safety Explorer,https://github.com/RhoInc/safety-shift-plot,https://github.com/RhoInc/safety-shift-plot/wiki/Configuration,htmlwidget,620
safetyresultsovertime,safetyResultsOverTime,Results Over Time,Population Test Results Over Time,https://github.com/RhoInc/safety-results-over-time,https://github.com/RhoInc/safety-results-over-time/wiki/Configuration,htmlwidget,1000
paneledoutlierexplorer,paneledOutlierExplorer,Paneled Outlier Explorer,Charts showing clinical participant results for multiple measures,https://github.com/RhoIncpaneled-outlier-explorer,https://github.com/RhoInc/paneled-outlier-explorer/wiki/Configuration,htmlwidget,1000
chart,main,label,description,repo_url,settings_url,type,maxWidth
hepexplorer,hepexplorer,Hepatic Safety Explorer,Interactive Graphic for Exploring Liver Function Data in Clinical Trials,https://github.com/SafetyGraphics/hep-explorer,https://github.com/SafetyGraphics/hep-explorer/wiki/Configuration,htmlwidget,620
safetyhistogram,safetyHistogram,Histogram,"Histogram showing distribution of lab measures, vital signs and other measures related to safety in clinical trials.",https://github.com/RhoInc/safety-histogram,https://github.com/RhoInc/safety-histogram/wiki/Configuration,htmlwidget,1000
safetyoutlierexplorer,safetyOutlierExplorer,Outlier Explorer,"Line Chart highlighting abnormal lab measures, vital signs and other measures related to safety in clinical trials.",https://github.com/RhoInc/safety-outlier-explorer,https://github.com/RhoInc/safety-outlier-explorer/wiki/Configuration,htmlwidget,1000
safetyshiftplot,safetyShiftPlot,Shift Plot,Shift Plot for Safety Explorer,https://github.com/RhoInc/safety-shift-plot,https://github.com/RhoInc/safety-shift-plot/wiki/Configuration,htmlwidget,620
safetyresultsovertime,safetyResultsOverTime,Results Over Time,Population Test Results Over Time,https://github.com/RhoInc/safety-results-over-time,https://github.com/RhoInc/safety-results-over-time/wiki/Configuration,htmlwidget,1000
paneledoutlierexplorer,paneledOutlierExplorer,Paneled Outlier Explorer,Charts showing clinical participant results for multiple measures,https://github.com/RhoIncpaneled-outlier-explorer,https://github.com/RhoInc/paneled-outlier-explorer/wiki/Configuration,htmlwidget,1000
52 changes: 52 additions & 0 deletions data-raw/csv_to_rda.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(usethis)
library(dplyr)
library(Hmisc)

### Prepare settingsMetadata and save to /data ###

Expand Down Expand Up @@ -29,4 +30,55 @@ usethis::use_data(chartsMetadata, overwrite = TRUE)
### Save sample data set to /data ###
# This is loaded by default in the app and used for testing
adlbc <- read.csv("data-raw/adlbc.csv", stringsAsFactors = FALSE)

### Add labels to sample data set
adlbc_labels <- c("STUDYID" = "Study Identifier",
"SUBJID" = "Subject Identifier for the Study",
"USUBJID" = "Unique Subject Identifier",
"TRTP" = "Planned Treatment",
"TRTPN" = "Planned Treatment (N)",
"TRTA" = "Actual Treatment",
"TRTAN" = "Actual Treatment (N)",
"TRTSDT" = "Date of First Exposure to Treatment",
"TRTEDT" = "Date of Last Exposure to Treatment",
"AGE" = "Age",
"AGEGR1" = "Age Group",
"AGEGR1N" = "Age Group (N)",
"RACE" = "Race",
"RACEN" = "Race (N)",
"SEX" = "Sex",
"COMP24FL" = "Completers Flag",
"DSRAEFL" = "Discontinued due to AE?",
"SAFFL" = "Safety Population Flag",
"AVISIT" = "Analysis Visit",
"AVISITN" = "Analysis Visit (N)",
"ADY" = "Analysis Relative Day",
"ADT" = "Analysis Relative Date",
"VISIT" = "Visit",
"VISITNUM" = "Visit (N)",
"PARAM" = "Parameter",
"PARAMCD" = "Parameter Code",
"PARAMN" = "Parameter (N)",
"PARCAT1" = "Parameter Category",
"AVAL" = "Analysis Value",
"BASE" = "Baseline Value",
"CHG" = "Change from Baseline",
"A1LO" = "Analysis Normal Range Lower Limit",
"A1HI" = "Analysis Normal Range Upper Limit",
"R2A1LO" = "Ratio to Low limit of Analysis Range",
"R2A1HI" = "Ratio to High limit of Analysis Range",
"BR2A1LO" = "Base Ratio to Analysis Range 1 Lower Lim",
"BR2A1HI" = "Base Ratio to Analysis Range 1 Upper Lim",
"ANL01FL" = "Analysis Population Flag",
"ALBTRVAL" = "Amount Threshold Range",
"ANRIND" = "Analysis Reference Range Indicator",
"BNRIND" = "Baseline Reference Range Indicator",
"ABLFL" = "Baseline Record Flag",
"AENTMTFL" = "Analysis End Date Flag",
"LBSEQ" = "Lab Sequence Number",
"LBNRIND" = "Reference Range Indicator",
"LBSTRESN" = "Numeric Result/Finding in Std Units")

label(adlbc) = as.list(adlbc_labels[match(names(adlbc), names(adlbc_labels))])

usethis::use_data(adlbc, overwrite = TRUE)
2 changes: 2 additions & 0 deletions data-raw/generateSettingsMetadataDefaults.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
library(tibble)

defaults <- tribble(~text_key, ~default,
"id_col", NULL,
"value_col", NULL,
Expand Down
5 changes: 4 additions & 1 deletion data-raw/settingsMetadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ warningText,Warning text,"Informational text to be displayed near the top of the
unit_col,Unit column,Unit of measure variable name,character,FALSE,TRUE,character,FALSE,,data
start_value,Measure start value,Value of variable defined in measure_col to be rendered in the histogram when the widget loads,character,FALSE,FALSE,NA,TRUE,measure_col,data
details,Details columns,"An optional list of specifications for details listing. Each column to be added to details listing is a nested, named list (containing the variable name: ""value_col"" and associated label: ""label"") within the larger list.",vector,FALSE,TRUE,NA,FALSE,,data
missingValues,Missing values,Values defining a missing value in the selected 'value' column,vector,FALSE,FALSE,NA,FALSE,,data
missingValues,Missing values,Values defining a missing value in the selected 'value' column,vector,FALSE,FALSE,NA,FALSE,,data
visits_without_data,Visits without data,Controls display of visits without data for the current measure,logical,FALSE,FALSE,NA,FALSE,,data
unscheduled_visits,Unscheduled visits,Controls display of unscheduled visits,logical,FALSE,FALSE,NA,FALSE,,data
unscheduled_visit_pattern,Unscheduled visit pattern,A regular expression that identifies unscheduled visits,character,FALSE,FALSE,NA,FALSE,,data
7 changes: 5 additions & 2 deletions data-raw/settingsMetadataCharts.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
text_key,edish,safetyhistogram,safetyoutlierexplorer,safetyshiftplot,safetyresultsovertime,paneledoutlierexplorer
text_key,hepexplorer,safetyhistogram,safetyoutlierexplorer,safetyshiftplot,safetyresultsovertime,paneledoutlierexplorer
id_col,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
value_col,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
measure_col,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
Expand Down Expand Up @@ -27,4 +27,7 @@ warningText,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE
unit_col,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
start_value,FALSE,TRUE,TRUE,TRUE,TRUE,FALSE
details,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE
missingValues,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE
missingValues,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE
visits_without_data,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
unscheduled_visits,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
unscheduled_visit_pattern,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
Binary file modified data-raw/settingsMetadataDefaults.Rds
Binary file not shown.
5 changes: 4 additions & 1 deletion data-raw/standardsMetadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ warningText,,
unit_col,STRESU,
start_value,,
details,,
missingValues,,
missingValues,,
visits_without_data,,
unscheduled_visits,,
unscheduled_visit_pattern,,
Binary file modified data/adlbc.rda
Binary file not shown.
Binary file modified data/chartsMetadata.rda
Binary file not shown.
Binary file modified data/settingsMetadata.rda
Binary file not shown.
Binary file modified data/standardsMetadata.rda
Binary file not shown.
12 changes: 6 additions & 6 deletions inst/htmlwidgets/chartRenderer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ dependencies:
src: htmlwidgets/lib/d3-3.5.17
script: d3.v3.min.js
- name: webcharts
version: 1.11.5
src: htmlwidgets/lib/webcharts-1.11.5
version: 1.11.6
src: htmlwidgets/lib/webcharts-1.11.6
script: webcharts.js
stylesheet: webcharts.css
- name: safety-eDish
version: 0.17.0
src: htmlwidgets/lib/safety-eDISH-0.17.0
script: safetyedish.js
src: htmlwidgets/lib/hep-explorer-1.0.1
script: hepexplorer.js
- name: safety-histogram
version: 2.3.0
src: htmlwidgets/lib/safety-histogram-2.3.0
version: 2.4.0
src: htmlwidgets/lib/safety-histogram-2.4.0-dev
script: safetyHistogram.js
- name: safety-outlier-explorer
version: 2.5.4
Expand Down
Loading

0 comments on commit 6e3192c

Please sign in to comment.