diff --git a/DESCRIPTION b/DESCRIPTION
index 07e47a2a..b2c8c4d1 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: safetyGraphics
Title: Create Interactive Graphics Related to Clinical Trial Safety
-Version: 0.7.3
+Version: 0.8.0
Authors@R: c(
person("Jeremy", "Wildfire", email = "jeremy_wildfire@rhoworld.com", role = c("cre","aut")),
person("Becca", "Krouse", role="aut"),
@@ -11,6 +11,8 @@ Authors@R: c(
person("Rho Inc.", role = "cph"))
Maintainer: Jeremy Wildfire
Description: A 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.
+URL: https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics
+BugReports: https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics/issues
Depends: R (>= 3.5)
License: MIT + file LICENSE
Encoding: UTF-8
@@ -21,16 +23,17 @@ Suggests:
shinytest,
knitr
Imports:
- dplyr,
- htmlwidgets,
- purrr,
- stringr,
- jsonlite,
- shiny,
- magrittr,
- DT,
- shinyjs,
- rmarkdown,
- rlang
+ dplyr,
+ htmlwidgets,
+ purrr,
+ stringr,
+ jsonlite,
+ shiny,
+ magrittr,
+ DT,
+ shinyjs,
+ rmarkdown,
+ rlang,
+ tibble,
+ utils
VignetteBuilder: knitr
-
diff --git a/NAMESPACE b/NAMESPACE
index 5b3e526a..cb58fb76 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -15,13 +15,18 @@ import(htmlwidgets)
import(rmarkdown)
import(shinyjs)
importFrom(dplyr,"filter")
+importFrom(dplyr,filter)
importFrom(magrittr,"%>%")
importFrom(purrr,keep)
importFrom(purrr,map)
+importFrom(purrr,map_chr)
importFrom(purrr,map_dbl)
importFrom(purrr,map_lgl)
importFrom(rlang,.data)
+importFrom(rlang,parse_expr)
importFrom(shiny,runApp)
importFrom(stringr,str_detect)
importFrom(stringr,str_split)
importFrom(stringr,str_subset)
+importFrom(tibble,tibble)
+importFrom(utils,globalVariables)
diff --git a/R/checkColumnSetting.R b/R/checkColumn.R
similarity index 81%
rename from R/checkColumnSetting.R
rename to R/checkColumn.R
index d3f334f7..3674be7b 100644
--- a/R/checkColumnSetting.R
+++ b/R/checkColumn.R
@@ -18,28 +18,29 @@
#' testSettings$filters[[3]]<-list(value_col="NotAColumn",label="Invalid Column")
#'
#' #pass ($valid == TRUE)
-#' safetyGraphics:::checkColumnSetting(key=list("id_col"),
+#' safetyGraphics:::checkColumn(key=list("id_col"),
#' settings=testSettings, adlbc)
#'
#' #pass
-#' safetyGraphics:::checkColumnSetting(key=list("filters",1,"value_col"),
+#' safetyGraphics:::checkColumn(key=list("filters",1,"value_col"),
#' settings=testSettings, adlbc)
#'
#' #NULL column pass
-#' safetyGraphics:::checkColumnSetting(key=list("filters",2,"value_col"),
+#' safetyGraphics:::checkColumn(key=list("filters",2,"value_col"),
#' settings=testSettings, adlbc)
#'
#' #invalid column fails
-#' safetyGraphics:::checkColumnSetting(key=list("filters",3,"value_col"),
+#' safetyGraphics:::checkColumn(key=list("filters",3,"value_col"),
#' settings=testSettings, adlbc)
+#' @keywords internal
-checkColumnSetting <- function(key, settings, data){
+checkColumn <- function(key, settings, data){
stopifnot(typeof(key)=="list",typeof(settings)=="list")
-
- validCols <- names(data)
+
current <- list(key=key)
current$text_key <- paste( unlist(current$key), collapse='--')
- current$check <- "'_col' parameter from setting setting found in data?"
+ current$type <- "column"
+ current$description <- "column parameter from setting setting found in data?"
current$value <- getSettingValue(key=key,settings=settings)
if(is.null(current$value)){
current$value <- "--No Value Given--"
@@ -47,7 +48,7 @@ checkColumnSetting <- function(key, settings, data){
current$message <- ""
return(current)
}else{
- current$valid <- current$value %in% validCols
+ current$valid <- hasColumn(current$value, data)
current$message <- ifelse(current$valid,"",paste0(current$value," column not found in data."))
return(current)
}
diff --git a/R/checkField.R b/R/checkField.R
new file mode 100644
index 00000000..ec6c48d6
--- /dev/null
+++ b/R/checkField.R
@@ -0,0 +1,45 @@
+#' Check that a setting parameter has a matching data field
+#'
+#' Checks that a single parameter from the settings list matches a field value in a specified data set
+#'
+#' This function compares settings with field values as part of the \code{validateSettings()} function. More specifically, the function checks whether the \code{fieldKey} in a \code{settings} object matches a column/field combination in \code{"data"}. The function makes 2 major assumptions about the structure of the settings object. First, it assumes that the first value in fieldKey is "settingName_values" and there is a corresponding "settingName_col" setting that defines the column to search for field-level data. Second, it expects that the value specified by key/settings is a list, and that each value in the list is a field of the variable above.
+#'
+#' @param fieldKey a list (like those provided by \code{getSettingKeys())} defining the position of parameter in the settings object.
+#' @param settings The settings list used to generate a chart like \code{eDISH()}
+#' @param data A data frame to check for the specified field
+#' @return A list containing the results of the check following the format specified in \code{validateSettings()[["checkList"]]}
+#'
+#'
+#' @examples
+#' testSettings<-generateSettings(standard="AdAM")
+#' fields<-list("measure_values","TB")
+#' safetyGraphics:::checkFieldSettings(fieldKey=fields,settings=testSettings, data=adlbc)
+#'
+#' @keywords internal
+
+checkFieldSettings <- function(fieldKey, settings, data){
+ stopifnot(typeof(fieldKey)=="list", typeof(settings)=="list")
+
+ # Check to see that the field data specified in the seetings is found in the data
+ fieldCheck <- list()
+ fieldCheck$key<-fieldKey
+ fieldCheck$text_key<- paste( unlist(fieldKey), collapse='--')
+ fieldCheck$type <- "field value from setting found in data"
+ fieldCheck$description <- "field value from setting found in data"
+ fieldCheck$value <- getSettingValue(key=fieldCheck$key,settings=settings)
+
+ #get the name of the column containing the field
+ columnTextKey<-getSettingsMetadata(cols="field_column_key",text_keys=fieldCheck$text_key)
+ columnKey<-textKeysToList(columnTextKey)[[1]]
+ columnName<-getSettingValue(key=columnKey,settings=settings)
+
+ if(length(fieldCheck$value)>0){
+ fieldCheck$valid <- hasField(fieldValue=fieldCheck$value, columnName=columnName,data=data)
+ }else{
+ fieldCheck$value <- "--No Value Given--"
+ fieldCheck$valid <- TRUE #null values are ok
+ }
+ fieldCheck$message <- ifelse(!fieldCheck$valid, paste0("Value of ",fieldCheck$value, " for '",fieldCheck$text_key,"' not found in ",columnName),"")
+
+ return(fieldCheck)
+}
diff --git a/R/checkFieldSettings.R b/R/checkFieldSettings.R
index d5095a3a..ececcecc 100644
--- a/R/checkFieldSettings.R
+++ b/R/checkFieldSettings.R
@@ -12,75 +12,37 @@
#'
#' @examples
#' testSettings<-generateSettings(standard="AdAM")
-#'
-#' #list of 4 checks. all pass ($valid ==TRUE)
-#' safetyGraphics:::checkFieldSettings(fieldKey=list("measure_values"),
-#' settings=testSettings, adlbc)
+#' fields<-list("measure_values","TB")
+#' safetyGraphics:::checkField(fieldKey=fields,settings=testSettings, data=adlbc)
#'
#' @importFrom stringr str_split
#' @importFrom magrittr "%>%"
#' @importFrom purrr map
-#'
-
-checkFieldSettings <- function(fieldKey, settings, data){
-
- # compare the fields in the settings to the fields in the data.
- key <- NULL
-
- fieldCheck <- function(key){
- function(key){
- current <- list()
- current$key<-fieldKey
- nextKey<-length(current$key)+1
- current$key[[nextKey]]<-key
-
- current$text_key <- paste( unlist(current$key), collapse='--')
- current$check <- "'_values' field from setting found in data?"
- current$value <- getSettingValue(key=current$key,settings=settings)
- if(is.null(current$value)){
- current$value <- "--No Value Given--"
- current$valid <- TRUE
- current$message <- ""
- return(current)
- }else if(!columnSpecified){
- current$valid<-FALSE
- current$message<-paste0("No column for ",columnKey," found in settings.")
- }else{
- current$valid <- current$value %in% validFields
- current$message <- ifelse(current$valid,"",paste0(current$value," field not found in the ",columnName," column"))
- return(current)
- }
- }
- }
-
+#' @keywords internal
+checkField<- function(fieldKey, settings, data){
stopifnot(typeof(fieldKey)=="list", typeof(settings)=="list")
-
- # get a list of all of the column's values from the data
- key_base<-stringr::str_split(fieldKey, "_")[[1]][1] # get the name of the column containing the fields(e.g. fields = "measure_values" -> column = "measure_col")
- columnKey<-getSettingKeys(patterns=paste0(key_base,"_col") ,settings=settings)[[1]]
- columnName<-getSettingValue(key=columnKey, settings=settings) # get the name of the column from the value associated with columnKey
- columnSpecified <- is.character(columnName)
- if(columnSpecified){
- validFields <- unique(data[[columnName]])
- } else{
- validFields <- c()
- }
-
- # get a list of fields from the settings object
- fieldList<-getSettingValue(key=fieldKey, settings=settings)
-
- if(typeof(fieldList)=="list"){
- fieldChecks <- fieldList %>% names %>% purrr::map(fieldCheck(key))
- } else {
- current <- list()
- current$key<-fieldKey
- current$check <- "'_values' field from setting found in data?"
- current$text_key <- paste( unlist(current$key), collapse='--')
- current$value <- NULL
- current$valid <- FALSE
- current$message <- "No list of values found in settings."
- fieldChecks <- list(current)
+
+ # Check to see that the field data specified in the seetings is found in the data
+ fieldCheck <- list()
+ fieldCheck$key<-fieldKey
+ fieldCheck$text_key<- paste( unlist(fieldKey), collapse='--')
+ fieldCheck$type <- "field"
+ fieldCheck$description <- "field value from setting found in data"
+ fieldCheck$value <- getSettingValue(key=fieldCheck$key,settings=settings)
+
+ #get the name of the column containing the field
+ columnTextKey<-getSettingsMetadata(cols="field_column_key",text_keys=fieldCheck$text_key)
+ columnKey<-textKeysToList(columnTextKey)[[1]]
+ columnName<-getSettingValue(key=columnKey,settings=settings)
+
+ if(length(fieldCheck$value)>0){
+ fieldCheck$valid <- hasField(fieldValue=fieldCheck$value, columnName=columnName,data=data)
+ }else{
+ fieldCheck$value <- "--No Value Given--"
+ fieldCheck$valid <- TRUE #null values are ok
}
- return(fieldChecks)
+ fieldCheck$message <- ifelse(!fieldCheck$valid, paste0("Value of ",fieldCheck$value, " for '",fieldCheck$text_key,"' not found in ",columnName),"")
+
+ return(fieldCheck)
}
diff --git a/R/checkNumericColumns.R b/R/checkNumeric.R
similarity index 76%
rename from R/checkNumericColumns.R
rename to R/checkNumeric.R
index d2ba46be..435d4627 100644
--- a/R/checkNumericColumns.R
+++ b/R/checkNumeric.R
@@ -9,28 +9,30 @@
#'
#' @examples
#' testSettings<-generateSettings(standard="AdAM")
-#' #pass ($valid == TRUE)
-#' safetyGraphics:::checkSettingProvided(key=list("id_col"),settings=testSettings)
+#' #pass ($valid == FALSE)
+#' safetyGraphics:::checkNumeric(key=list("id_col"),settings=testSettings, data=adlbc)
#'
-#' #fails since filters aren't specified by default
-#' safetyGraphics:::checkSettingProvided(key=list("filters"),settings=testSettings)
+#' #pass ($valid == TRUE)
+#' safetyGraphics:::checkNumeric(key=list("value_col"),settings=testSettings, data=adlbc)
#'
-#' #fails since groups aren't specified by default
-#' safetyGraphics:::checkSettingProvided(key=list("groups",1,"value_col"),settings=testSettings)
-#'
+#' @keywords internal
-checkNumericColumns <- function(key, settings, data){
+checkNumeric <- function(key, settings, data){
stopifnot(typeof(key)=="list",typeof(settings)=="list")
current <- list(key=key)
current$text_key <- paste( unlist(current$key), collapse='--')
- current$check <- "specified column is numeric?"
+ current$type <- "numeric"
+ current$description <- "specified column is numeric?"
current$value <- getSettingValue(key=key,settings=settings)
if(is.null(current$value)){
current$value <- "--No Value Given--"
current$valid <- TRUE
current$message <- ""
- return(current)
+ }else if(!hasColumn(current$value,data)){
+ current$value <- "--Column not found--"
+ current$valid <- TRUE
+ current$message <- ""
}else{
#check to see if the specified column contains numeric values
values<- data[[current$value]]
@@ -42,7 +44,6 @@ checkNumericColumns <- function(key, settings, data){
current$valid <- percentNonNumeric < 0.5
current$message <- paste0(nonNumericCount," of ", totalCount," values were not numeric.")
if(nonNumericCount>0){current$message<-paste0(current$message, " Records with non-numeric values may not appear in the graphic.")}
-
- return(current)
}
+ return(current)
}
diff --git a/R/checkSettingProvided.R b/R/checkRequired.R
similarity index 80%
rename from R/checkSettingProvided.R
rename to R/checkRequired.R
index f837e9ea..2e93f975 100644
--- a/R/checkSettingProvided.R
+++ b/R/checkRequired.R
@@ -10,24 +10,25 @@
#' testSettings<-generateSettings(standard="AdAM")
#'
#' #pass ($valid == TRUE)
-#' safetyGraphics:::checkSettingProvided(key=list("id_col"),
+#' safetyGraphics:::checkRequired(key=list("id_col"),
#' settings=testSettings)
#'
#' #fails since filters aren't specified by default
-#' safetyGraphics:::checkSettingProvided(key=list("filters"),
+#' safetyGraphics:::checkRequired(key=list("filters"),
#' settings=testSettings)
#'
#' #fails since groups aren't specified by default
-#' safetyGraphics:::checkSettingProvided(key=list("groups",1,"value_col"),
+#' safetyGraphics:::checkRequired(key=list("groups",1,"value_col"),
#' settings=testSettings)
-#'
+#' @keywords internal
-checkSettingProvided <- function(key, settings){
+checkRequired <- function(key, settings){
stopifnot(typeof(key)=="list",typeof(settings)=="list")
current <- list(key=key)
current$text_key <- paste( unlist(current$key), collapse='--')
- current$check <- "value for specified key found in settings?"
+ current$type<-"required"
+ current$description <- "value for specified key found in settings?"
current$value <- getSettingValue(key=key,settings=settings)
if(is.null(current$value)){
current$value <- "--No Value Given--"
diff --git a/R/compare_cols.R b/R/compare_cols.R
deleted file mode 100644
index 47f2c3ac..00000000
--- a/R/compare_cols.R
+++ /dev/null
@@ -1,38 +0,0 @@
-#' Compares contents of 2 vectors
-#'
-#' Function to compare contents of 2 vectors - used to summarize of which data columns are found in a given standard. Used in \code{detectStandard()} and \code{validateSettings()}
-#'
-#' @param data_cols A character vector with column names in the data frame
-#' @param standard_cols A character vector with column names in the data standard
-#' @return A list summarizing the comparison between \code{data_cols} and \code{standard_cols}. List has character vectors for "matched_columns", "extra_columns" and "missing_columns" parameters, and a boolean "match" parameter indicating that there are no missing columns.
-#'
-#'
-#' @examples
-#' #match == FALSE
-#' safetyGraphics:::compare_cols(data_cols=c("a","b","c"),
-#' standard_cols=c("d","e","f"))
-#'
-#' # match == TRUE
-#' safetyGraphics:::compare_cols(names(adlbc),
-#' safetyGraphics:::getRequiredColumns(standard="ADaM"))
-#'
-
-compare_cols<-function(data_cols, standard_cols){
- compare_summary <- list()
- compare_summary[["matched_columns"]]<-intersect(data_cols, standard_cols)
- compare_summary[["extra_columns"]]<-setdiff(data_cols,standard_cols)
- compare_summary[["missing_columns"]]<-setdiff(standard_cols,data_cols)
-
- #if there are no missing columns then call this a match
-
- if (length(compare_summary[["missing_columns"]])==0) {
- compare_summary[["match"]] <- "Full"
- } else if(length(compare_summary[["matched_columns"]])>0) {
- compare_summary[["match"]] <- "Partial"
- } else {
- compare_summary[["match"]] <- "None"
- }
-
-
- return(compare_summary)
-}
diff --git a/R/detectStandard.R b/R/detectStandard.R
index 936bbf41..6a7acf5a 100644
--- a/R/detectStandard.R
+++ b/R/detectStandard.R
@@ -1,37 +1,37 @@
#' Detect the data standard used for a data set
#'
-#' This function attempts to detect the data CDISC clinical standard used in a given R data frame.
+#' This function attempts to detect the data CDISC clinical 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() standards for clinical trial data. Currently, only "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() standards for clinical trial data. Currently, "labs" is the only domain supported.
#'
-#' @param data A data frame in which to detect the data standard
+#' @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}.
#' @param domain The data domain for the data set provided. Default: \code{"labs"}.
-#' @return A list containing the matching \code{"standard"} ("ADaM", "SDTM" or "None") and a list of \code{"details"} describing each standard considered. #'
+#' @return A list containing the matching \code{"standard"} ("ADaM", "SDTM" or "None") and a list of \code{"details"} describing each standard considered.
#' @examples
+
#' detectStandard(adlbc)[["standard"]] #AdAM
#' detectStandard(iris)[["standard"]] #none
-#'
+#'
#' \dontrun{
-#' detectStandard(adlbc,domain="AE") #throws error. AE domain not supported in this release.
+#' detectStandard(adlbc,domain="AE") #throws error. AE domain not supported in this release.
#' }
-#'
+#'
#' @export
-detectStandard <- function(data, domain="labs"){
+detectStandard <- function(data, includeFields=TRUE, domain="labs"){
stopifnot(
domain=="labs",
typeof(domain)=="character"
)
-
+
+
# Create placeholder list, with Standard = None.
standard_list <- list()
standard_list[["details"]] = list()
- data_cols<-toupper(colnames(data))
-
- # Check to see if data columns match the standards
- standard_list[["details"]][["ADaM"]]<-compare_cols(data_cols,getRequiredColumns(standard="ADaM"))
- standard_list[["details"]][["SDTM"]]<-compare_cols(data_cols,getRequiredColumns(standard="SDTM"))
-
+ standard_list[["details"]][["ADaM"]]<-evaluateStandard(data,standard="ADaM", includeFields=includeFields, domain=domain)
+ standard_list[["details"]][["SDTM"]]<-evaluateStandard(data,standard="SDTM", includeFields=includeFields, domain=domain)
+
# Determine the final standard
if(standard_list[["details"]][["SDTM"]][["match"]] == "Full"){
standard_list[["standard"]]<- "SDTM"
@@ -40,14 +40,14 @@ detectStandard <- function(data, domain="labs"){
} else if(standard_list[["details"]][["SDTM"]][["match"]] == "Partial" |
standard_list[["details"]][["ADaM"]][["match"]] == "Partial"){
standard_list[["standard"]] <- ifelse(
- length(standard_list[["details"]][["ADaM"]][["matched_columns"]]) >
- length(standard_list[["details"]][["SDTM"]][["matched_columns"]]),
+ length(standard_list[["details"]][["ADaM"]][["valid_count"]]) >
+ length(standard_list[["details"]][["SDTM"]][["valid_count"]]),
"ADaM" , "SDTM" #SDTM if they are equal
)
-
+
} else {
standard_list[["standard"]]<-"None"
}
-
+
return(standard_list)
-}
\ No newline at end of file
+}
diff --git a/R/eDISH.R b/R/eDISH.R
index 909a4862..73b592d0 100644
--- a/R/eDISH.R
+++ b/R/eDISH.R
@@ -11,17 +11,19 @@
#' @param visit_col Visit variable name. Default: \code{"VISIT"}.
#' @param visitn_col Visit number variable name. Default: \code{"VISITN"}.
#' @param studyday_col Visit day variable name. Default: \code{"DY"}.
-#' @param baseline An optional list defining which column \code{"value_col"} and values (one or more) \code{values} represent the baseline visit(s) of the study.
+#' @param baseline An optional list defining which column (\code{value_col}) and \code{values} (one or more) represent the baseline visit(s) of the study.
#' @param filters An optional list of specifications for filters. Each filter is a nested, named list (containing the filter value column: "value_col" and associated label: "label") within the larger list. Default: \code{NULL}.
#' @param group_cols An optional list of specifications for grouping columns. Each group column is a nested, named list (containing the group variable column: "value_col" and associated label: "label") within the larger list. Default: \code{NULL}.
#' @param measure_values A list defining the data values from \code{measure_col} for the lab measures
-#' used in eDish evaluations. Default: \code{list(ALT = 'Aminotransferase, alanine (ALT)',
-#' AST = 'Aminotransferase, aspartate (AST)', TB = 'Total Bilirubin', ALP = 'Alkaline phosphatase (ALP)')}.
+#' used in eDish evaluations. Default: \preformatted{list(ALT = 'Aminotransferase, alanine (ALT)',
+#' AST = 'Aminotransferase, aspartate (AST)',
+#' TB = 'Total Bilirubin',
+#' ALP = 'Alkaline phosphatase (ALP)')}
#' @param x_options Specifies variable options for the x-axis using the key values from \code{measure_values} (e.g. "ALT").
#' When multiple options are specified, a control allowing the user to interactively change the x variable is shown. Default: \code{c("ALT", "AST", "ALP")}.
#' @param y_options Specifies variable options for the y-axis using the key values from \code{measure_values} (e.g. "TB").
-#' When multiple options are specified, a control allowing the user to interactively change the y variable is shown. Default: \code{c("TB", "ALP")}.
-#' @param analysisFlag An optional list defining which column \code{value_col} and values \code{values} should be used to records for use in eDish and mDish analyses. Default: \code{NULL}.
+#' When multiple options are specified, a control allowing the user to interactively change the y variable is shown. Default: \code{"TB"}.
+#' @param analysisFlag An optional list defining which column (\code{value_col}) and \code{values} should be used in eDish and mDish analyses. Default: \code{NULL}.
#' @param visit_window Default visit window used to highlight eDish points where x and y measures occurred within the specified number of days.
#' Editable by user after render. Default: \code{30}.
#' @param r_ratio_filter Specifies whether the R Ratio filter should be shown. R ratio is defined as:
@@ -36,7 +38,10 @@
#' standard operating procedures.").
#' @param debug_js print settings in javascript before rendering chart. Default: \code{FALSE}.
-#' @param settings Optional list of settings arguments to be converted to JSON using \code{jsonlite::toJSON(settings, auto_unbox = TRUE, dataframe = "rows", null = "null")}. If provided, all other function parameters are ignored. Default: \code{NULL}.
+#' @param settings Optional list of settings arguments to be converted to JSON using: \preformatted{
+#' jsonlite::toJSON(settings, auto_unbox = TRUE,
+#' dataframe = "rows", null = "null")}
+#' If provided, all other function parameters are ignored. Default: \code{NULL}.
#'
#' @examples
#' \dontrun{
diff --git a/R/evaluateStandard.R b/R/evaluateStandard.R
new file mode 100644
index 00000000..ae820df5
--- /dev/null
+++ b/R/evaluateStandard.R
@@ -0,0 +1,74 @@
+#' Evaluate a data set against a data standard
+#'
+#' Determines whether the required data elements in a data standard are found in a given data frame
+#'
+#' @param data data.frame to evaluate
+#' @param standard standard to evaluate
+#' @param includeFields should field level data be evaluated?
+#' @param domain data domain. "labs" only for now.
+#'
+#' @return 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. "valid_checks" and "invalid_checks" provide counts of the specified checks.
+#'
+#' @examples
+#' safetyGraphics:::evaluateStandard(data=adlbc, standard="adam") # Match is TRUE
+#' safetyGraphics:::evaluateStandard(data=adlbc, standard="sdtm") # Match is FALSE
+#'
+#' @import dplyr
+#' @importFrom purrr map
+#' @importFrom rlang .data
+#'
+#' @keywords internal
+
+
+evaluateStandard <- function(data, standard, includeFields=TRUE, domain="labs"){
+
+ stopifnot(
+ is.data.frame(data),
+ is.character(standard),
+ is.logical(includeFields),
+ is.character(domain),
+ tolower(standard) %in% c("adam","sdtm")
+ )
+
+ standard<-tolower(standard)
+
+ compare_summary<-list()
+ compare_summary[["standard"]]<-standard
+
+ # 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$setting_required==TRUE) %>%
+ mutate(type = ifelse(.data$column_mapping, "column", "field")) %>%
+ rowwise %>%
+ mutate(field_column_name = ifelse(.data$field_mapping, getSettingsMetadata(cols=standard, text_keys=.data$field_column_key),"")) %>%
+ mutate(valid = ifelse(.data$column_mapping,
+ hasColumn(data=data, columnName=.data$standard_val),
+ hasField(data=data, columnName=.data$field_column_name, fieldValue=.data$standard_val)
+ )) %>%
+ select(.data$text_key, .data$standard_val, .data$type, .data$valid)
+
+ # filter out the field level checks if includeChecks is false
+ if(!includeFields){
+ standardChecks <- standardChecks %>% filter(.data$type != "field")
+ }
+
+ # compare_summary[["checks"]] <- split(standardChecks, seq(nrow(standardChecks)))%>%map(~as.list(.)) #coerce to list of lists?
+ compare_summary[["checks"]] <- standardChecks #or just keep the tibble ...
+
+ # count valid/invalid data elements
+ compare_summary[["valid_count"]] <- standardChecks %>% filter(.data$valid) %>% nrow()
+ compare_summary[["invalid_count"]] <- standardChecks %>% filter(!.data$valid) %>% nrow()
+
+
+ if (compare_summary[["invalid_count"]]==0) {
+ compare_summary[["match"]] <- "Full"
+ } else if(compare_summary[["valid_count"]]>0) {
+ compare_summary[["match"]] <- "Partial"
+ } else {
+ compare_summary[["match"]] <- "None"
+ }
+
+ return(compare_summary)
+}
\ No newline at end of file
diff --git a/R/generateSettings.R b/R/generateSettings.R
index c82c4302..ac5530d1 100644
--- a/R/generateSettings.R
+++ b/R/generateSettings.R
@@ -6,16 +6,17 @@
#'
#' @param standard The data standard for which to create settings. Valid options are "SDTM", "AdAM" or "None". Default: \code{"SDTM"}
#' @param chart The chart for which standards should be generated ("eDish" only for now) . Default: \code{"eDish"}.
-#' @param partial Boolean for whether or not the standard is a partial standard. Default: \code{"NULL"}.
-#' @param partial_cols Optional character vector of the matched cols if partial is TRUE. It will not be used if partial is FALSE Default: \code{"NULL"}.
+#' @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}.
#' @return A list containing the appropriate settings for the selected chart
#'
#' @examples
#'
#' generateSettings(standard="SDTM")
#' generateSettings(standard="SdTm") #also ok
-#' generateSettings(standard="SDTM", partial=TRUE, partial_cols = c("USUBJID","TEST","STRESN"))
-#' generateSettings(standard="AdAM")
+#' generateSettings(standard="ADaM")
+#' pkeys<- c("id_col","measure_col","value_col")
+#' generateSettings(standard="adam", partial=TRUE, partial_keys=pkeys)
#'
#' generateSettings(standard="a different standard")
#' #returns shell settings list with no data mapping
@@ -30,26 +31,40 @@
#'
#' @export
-generateSettings <- function(standard="None", chart="eDish", partial=FALSE, partial_cols=NULL){
+generateSettings <- function(standard="None", chart="eDish", partial=FALSE, partial_keys=NULL){
if(tolower(chart)!="edish"){
stop(paste0("Can't generate settings for the specified chart ('",chart,"'). Only the 'eDish' chart is supported for now."))
}
- # Check that partial_cols is supplied if partial is true
- if (is.null(partial_cols) & partial ) {
- stop("partial_cols must be supplied if the standard is partial")
+ # Check that partial_keys is supplied if partial is true
+ if (is.null(partial_keys) & partial ) {
+ stop("partial_keys must be supplied if the standard is partial")
}
- metadata <- safetyGraphics::getSettingsMetadata(
- charts = chart,
- cols=c("text_key","adam","sdtm"),
- filter_expr = .data$adam != '' & .data$sdtm != ''
- )
-
- # Split on -- for multi-level handling
- hierarchical_metadata <- str_split(metadata$text_key, "--")
+ # Coerce options to lowercase
+ standard<-tolower(standard)
+ chart<-tolower(chart)
+
+ # Build a table of data mappings for the selected standard and partial settings
+ standardList<-c("adam","sdtm") #TODO: automatically generate this from metadata
+ if(standard %in% standardList){
+ dataMappings <- safetyGraphics::getSettingsMetadata(
+ charts = chart,
+ cols=c("text_key",standard,"setting_required")
+ ) %>%
+ filter(.data$setting_required)%>%
+ rename("column_name" = standard)%>%
+ filter(.data$column_name != '')
+
+ if(partial){
+ dataMappings<-dataMappings%>%filter(.data$text_key %in% partial_keys)
+ }
+ }
- settings<-list(
+ # build shell settings for each chart
+ # TODO: move these to `/data` eventually
+ shells<-list()
+ shells[["edish"]]<-list(
id_col = NULL,
value_col = NULL,
measure_col = NULL,
@@ -69,7 +84,7 @@ generateSettings <- function(standard="None", chart="eDish", partial=FALSE, part
analysisFlag = list(value_col=NULL,
values=list()),
- x_options = c("LT", "AST", "ALP"),
+ x_options = c("ALT", "AST", "ALP"),
y_options = c("TB", "ALP"),
visit_window = 30,
r_ratio_filter = TRUE,
@@ -78,42 +93,12 @@ generateSettings <- function(standard="None", chart="eDish", partial=FALSE, part
warningText = "Caution: This interactive graphic is not validated. Any clinical recommendations based on this tool should be confirmed using your organizations standard operating procedures."
)
- potential_settings <- settings
-
- standard_low <- tolower(standard)
-
- if (standard_low == "adam" | standard_low == "sdtm") {
-
- for (row in hierarchical_metadata) {
- if (length(row) == 1) {
- potential_settings[row] <- filter(metadata,.data$text_key == !!row)[[standard_low]]
- } else if (length(row) == 2) {
- potential_settings[row[[1]]][[1]][row[[2]]] <- filter(metadata, grepl(!!row[[2]],.data$text_key))[[standard_low]]
- } else{
- stop("Three level setting nests are not currently supported")
- }
-
- }
-
- }
-
- if(partial) {
-
- settings_names <- names(settings)
-
- potential_names <- names(potential_settings)
-
- for(i in 1:length(settings)) {
- if (potential_settings[i] %in% partial_cols) {
- settings[[which(settings_names == potential_names[i])]] <- potential_settings[[i]]
- }
- }
-
- } else {
-
- settings <- potential_settings
-
+ # loop through dataMappings and apply them to the shell
+ if(standard %in% standardList){
+ for(row in 1:nrow(dataMappings)){
+ shells[[chart]]<-setSettingsValue(settings = shells[[chart]], key = textKeysToList(dataMappings[row,"text_key"])[[1]], value = dataMappings[row, "column_name"])
+ }
}
-
- return(settings)
+
+ return(shells[[chart]])
}
\ No newline at end of file
diff --git a/R/getRequiredColumns.R b/R/getRequiredColumns.R
index 8b1c6546..7c588adc 100644
--- a/R/getRequiredColumns.R
+++ b/R/getRequiredColumns.R
@@ -11,6 +11,7 @@
#' safetyGraphics:::getRequiredColumns(standard="SDTM")
#'
#' @importFrom rlang .data
+#' @keywords internal
getRequiredColumns<-function(standard,chart="eDish"){
stopifnot(
diff --git a/R/getSettingKeys.R b/R/getSettingKeys.R
index 4fcdbeff..90729da7 100644
--- a/R/getSettingKeys.R
+++ b/R/getSettingKeys.R
@@ -31,7 +31,7 @@
#' matchLists=TRUE)
#'
#' @importFrom stringr str_detect
-#'
+#' @keywords internal
diff --git a/R/getSettingValue.R b/R/getSettingValue.R
index c50382ca..9794482c 100644
--- a/R/getSettingValue.R
+++ b/R/getSettingValue.R
@@ -15,6 +15,7 @@
#' safetyGraphics:::getSettingValue(list("measure_values","ALP"),testSettings)
#' safetyGraphics:::getSettingValue(list("NotASetting"),testSettings) #returns NULL
#'
+#' @keywords internal
getSettingValue <- function(key,settings){
stopifnot(typeof(settings)=="list")
diff --git a/R/getSettingsMetadata.R b/R/getSettingsMetadata.R
index c928d9d6..14257138 100644
--- a/R/getSettingsMetadata.R
+++ b/R/getSettingsMetadata.R
@@ -47,7 +47,7 @@ getSettingsMetadata<-function(charts=NULL, text_keys=NULL, cols=NULL, filter_exp
return(NULL)
}else{
# see if any of the matched chart flags are TRUE
- md<-md%>%filter_at(vars(matched_chart_columns),any_vars(.data$.==TRUE))
+ md<-md%>%filter_at(vars(matched_chart_columns),any_vars(.))
}
}
diff --git a/R/hasColumn.R b/R/hasColumn.R
new file mode 100644
index 00000000..d64fc52d
--- /dev/null
+++ b/R/hasColumn.R
@@ -0,0 +1,23 @@
+#' Check whether a column is found in a data set
+#'
+#' Checks whether a specified column is found in a specified data set
+#'
+#' @param columnName The column to look for.
+#' @param data the data.frame to search.
+#' @return logical scalar. TRUE if the column is found. FALSE otherwise
+#'
+#' @examples
+#' safetyGraphics:::hasColumn(columnName="PARAM",data=adlbc) #TRUE
+#' safetyGraphics:::hasColumn(columnName="Not_a_column",data=adlbc) #FALSE
+#'
+#' @keywords internal
+
+hasColumn <- function(columnName, data){
+ stopifnot(
+ typeof(columnName)=="character",
+ length(columnName)==1,
+ is.data.frame(data)
+ )
+
+ return(toupper(columnName) %in% toupper(colnames(data)))
+}
diff --git a/R/hasField.R b/R/hasField.R
new file mode 100644
index 00000000..ab038568
--- /dev/null
+++ b/R/hasField.R
@@ -0,0 +1,33 @@
+#' Check whether a specified field value is found in a data set
+#'
+#' This checks whether a specific value is found in a specified column in a specified data set
+#'
+#' @param fieldValue A value to check for.
+#' @param columnName The column to check.
+#' @param data the data.frame to search.
+#' @return logical scalar. TRUE if field_value is found. FALSE otherwise
+#'
+#' @examples
+#' safetyGraphics:::hasField(fieldValue="Bilirubin (umol/L)",columnName="PARAM",data=adlbc) #TRUE
+#' safetyGraphics:::hasField(fieldValue="Not_a_real_value",columnName="",data=adlbc) #FALSE
+#'
+#' @keywords internal
+
+hasField<- function(fieldValue, columnName, data){
+ stopifnot(
+ length(fieldValue)==1,
+ typeof(columnName)=="character",
+ length(columnName)==1,
+ is.data.frame(data)
+ )
+
+ columnFound <- hasColumn(columnName=columnName, data=data)
+ if(columnFound){
+ validFields <- unique(data[[columnName]])
+ } else{
+ validFields <- c()
+ }
+
+ validFields <- unique(data[[columnName]])
+ return(fieldValue %in% validFields)
+}
diff --git a/R/safetyGraphics.R b/R/safetyGraphics.R
new file mode 100644
index 00000000..11d7ea0d
--- /dev/null
+++ b/R/safetyGraphics.R
@@ -0,0 +1,16 @@
+#' \code{safetyGraphics} package
+#'
+#' Create Interactive Graphics Related to Clinical Trial Safety
+#'
+#' Learn more on
+#' \href{https://CRAN.R-project.org/package=safetyGraphics}{CRAN}
+#' or \href{https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics}{GitHub}
+#'
+#' @docType package
+#' @name SafetyGraphics
+#' @importFrom utils globalVariables
+#' @keywords internal
+NULL
+
+## quiets concerns of R CMD check re: the .'s that appear in pipelines
+utils::globalVariables(c("."))
\ No newline at end of file
diff --git a/R/safetyGraphicsApp.R b/R/safetyGraphicsApp.R
index d9ea71c0..4b29d35b 100644
--- a/R/safetyGraphicsApp.R
+++ b/R/safetyGraphicsApp.R
@@ -1,5 +1,7 @@
#' Run the interactive safety graphics builder
#'
+#' @param maxFileSize maximum file size in MB allowed for file upload.
+#'
#' @importFrom shiny runApp
#' @import shinyjs
#' @import dplyr
@@ -10,7 +12,10 @@
#'
#' @export
#'
-safetyGraphicsApp <- function() {
+safetyGraphicsApp <- function(maxFileSize = 20) {
+ #increase maximum file upload limit
+ options(shiny.maxRequestSize=(maxFileSize*1024^2))
+
path <- system.file("eDISH_app", package = "safetyGraphics")
shiny::runApp(path, launch.browser = TRUE)
}
diff --git a/R/setSettingsValue.R b/R/setSettingsValue.R
new file mode 100644
index 00000000..8052d237
--- /dev/null
+++ b/R/setSettingsValue.R
@@ -0,0 +1,37 @@
+#' Set the value for a given named parameter
+#'
+#' Sets the value for a named parameter (\code{key}) to given \code{value} in a list (\code{settings})
+#'
+#' @param key a list (like those provided by \code{getSettingKeys()}) defining the position of parameter in the settings object.
+#' @param value the value to set
+#' @param settings The settings list used to generate a chart like \code{eDISH()}
+#' @return the updated settings object
+#'
+#' @examples
+#' testSet<-list(a=list(b="myValue"))
+#' safetyGraphics:::setSettingsValue(key=list("a","b"), value="notMyValue", settings=testSet)
+#' #returns list(a=list(b="notMyValue")))
+#'
+#' adamSettings<-generateSettings(standard="AdAM")
+#' safetyGraphics:::setSettingsValue(list("id_col"),"customID",adamSettings)
+#' safetyGraphics:::setSettingsValue(list("measure_values","ALP"),"Alanine Aminotrans",adamSettings)
+#' safetyGraphics:::setSettingsValue(list("myCustomSetting"),"customized",adamSettings)
+#' #adds myCustomSetting to adamSettings
+#'
+#' @keywords internal
+
+
+setSettingsValue <- function(key, value, settings){
+ stopifnot(
+ typeof(settings)=="list"
+ )
+
+ firstKey <- key[[1]]
+ if(length(key)==1){
+ settings[[firstKey]]<-value
+ return(settings)
+ }else{
+ settings[[firstKey]]<-setSettingsValue(settings = settings[[firstKey]],key = key[2:length(key)], value)
+ return(settings)
+ }
+}
\ No newline at end of file
diff --git a/R/settingsMetadata.R b/R/settingsMetadata.R
index 5f395407..d74a076a 100644
--- a/R/settingsMetadata.R
+++ b/R/settingsMetadata.R
@@ -5,15 +5,15 @@
#' @format A data frame with 25 rows and 10 columns
#' \describe{
#' \item{chart_edish}{Flag indicating if the settings apply to the eDish Chart}
-#' \item{text_key}{Text key indicating the setting name. '--' delimiter indicates a nested setting}
+#' \item{text_key}{Text key indicating the setting name. \code{'--'} delimiter indicates a nested setting}
#' \item{label}{Label}
#' \item{description}{Description}
#' \item{setting_type}{Expected type for setting value. Should be "character", "vector", "numeric" or "logical"}
#' \item{setting_required}{Flag indicating if the setting is required}
#' \item{column_mapping}{Flag indicating if the setting corresponds to a column in the associated data}
#' \item{column_type}{Expected type for the data column values. Should be "character","logical" or "numeric"}
-#' \item{column_required}{Flag indicating whether the associated data column should be considered required}
#' \item{field_mapping}{Flag indicating whether the setting corresponds to a field-level mapping in the data}
+#' \item{field_column_key}{Key for the column that provides options for the field-level mapping in the data}
#' \item{adam}{Settings values for the ADaM standard}
#' \item{sdtm}{Settings values for the SDTM standard}
#' }
diff --git a/R/textKeysToList.R b/R/textKeysToList.R
index 62f89020..495d00e6 100644
--- a/R/textKeysToList.R
+++ b/R/textKeysToList.R
@@ -11,6 +11,8 @@
#'
#' #list(list("id_col"),list("measure_col","label"))
#' safetyGraphics:::textKeysToList(c("id_col","measure_col--label"))
+#'
+#' @keywords internal
textKeysToList <- function(textKeys){
diff --git a/R/trimData.R b/R/trimData.R
new file mode 100644
index 00000000..4ed44b52
--- /dev/null
+++ b/R/trimData.R
@@ -0,0 +1,62 @@
+#' Removes unnecessary rows and columns
+#'
+#' Removes unnecessary rows and columns from data based on current settings
+#'
+#' @param data a data frame to trim
+#' @param settings the settings list used to determine which rows and columns to drop
+#' @return A dataframe with unnecessary columns and rows removed
+#'
+#' @examples
+#' testSettings <- generateSettings(standard="adam")
+#' safetyGraphics:::trimData(data=adlbc, settings=testSettings)
+#'
+#' @importFrom dplyr filter
+#' @importFrom purrr map
+#' @importFrom rlang parse_expr
+#'
+#' @keywords internal
+
+
+trimData <- function(data, settings){
+
+ ## Remove columns not in settings ##
+
+ col_names <- colnames(data)
+ settings_keys <- safetyGraphics::getSettingsMetadata(cols="text_key", filter_expr=column_mapping==TRUE) %>%
+ str_split("--")
+
+ settings_values <- map(settings_keys, function(x) {return(safetyGraphics:::getSettingValue(x, settings))})
+
+ common_cols <- intersect(col_names,settings_values)
+
+ data_subset <- select(data, unlist(common_cols))
+
+ ## Remove rows if baseline or analysisFlag is specified ##
+
+ if(!is.null(settings[['baseline']][['value_col']]) | !is.null(settings[['analysisFlag']][['value_col']])) {
+
+ # Create Baseline String
+ baseline_string <- ifelse(!is.null(settings[['baseline']][['value_col']]),
+ paste(settings[['baseline']][['value_col']], "%in% settings[['baseline']][['values']]"),
+ "")
+
+ # Create AnalysisFlag String
+ analysis_string <- ifelse(!is.null(settings[['analysisFlag']][['value_col']]),
+ paste(settings[['analysisFlag']][['value_col']], "%in% settings[['analysisFlag']][['values']]"),
+ "")
+
+ # Include OR operator if both are specified
+ operator <- ifelse(!is.null(settings[['baseline']][['value_col']]) & !is.null(settings[['analysisFlag']][['value_col']]),
+ "|","")
+
+ # Create filter string and make it an expression
+ filter_string <- paste(baseline_string, operator, analysis_string)
+ filter_expression <- parse_expr(filter_string)
+
+ #Filter on baseline and analysisFlag
+ data_subset <- filter(data_subset, !!filter_expression)
+
+ }
+
+ return(data_subset)
+}
diff --git a/R/validateSettings.R b/R/validateSettings.R
index 894279b4..fd5af710 100644
--- a/R/validateSettings.R
+++ b/R/validateSettings.R
@@ -9,23 +9,31 @@
#' @param chart The chart type being created ("eDish" only for now)
#' @return
#' A list describing the validation state for the data/settings combination. The returned list has the following properties:
-#'- `valid` - boolean indicating whether the settings/data combo creates a valid chart
-#'- `status` - a string summarizing of the validation results
-#'- `checkList` - list of lists giving details about checks performed on individual setting specifications. Each embedded item has the following properties:
-#' - `key` - a list specifying the position of the property being checked. For example, `list("group_cols",1,"value_col")` corresponds to `settings[["group_cols"]][[1]][["value_col"]]`
-#' - `text_key` - list from `key` parsed to character with a "--" separator.
-#' - `value` - value of the setting
-#' - `check` - description of the check performed.
-#' - `valid` - a boolean indicating whether the check was passed
-#' - `message` - a string describing failed checks (where `valid=FALSE`). returns an empty string when `valid==TRUE`
+#' \itemize{
+#' \item{"valid"}{ - boolean indicating whether the settings/data combo creates a valid chart}
+#' \item{"status"}{ - string summarizing the validation results}
+#' \item{"checkList"}{ - list of lists giving details about checks performed on individual setting specifications. Each embedded item has the following properties:}
+#' \item{"key"}{ - list specifying the position of the property being checked. For example, `list("group_cols",1,"value_col")` corresponds to `settings[["group_cols"]][[1]][["value_col"]]`}
+#' \item{"text_key"}{ - list from `key` parsed to character with a "--" separator.}
+#' \item{"value"}{ - value of the setting}
+#' \item{"type"}{ - type of the check performed.}
+#' \item{"description"}{ - description of the check performed.}
+#' \item{"valid"}{ - boolean indicating whether the check was passed}
+#' \item{"message"}{ - string describing failed checks (where `valid=FALSE`). returns an empty string when `valid==TRUE`}
+#' }
+#'
+#' @examples
+#' testSettings <- generateSettings(standard="adam")
+#' validateSettings(data=adlbc, settings=testSettings)
+#' # .$valid is TRUE
+#' testSettings$id_col <- "NotAColumn"
+#' validateSettings(data=adlbc, settings=testSettings)
+#' # .$valid is now FALSE
#'
-#' @examples
-#' testSettings <- generateSettings(standard="adam")
-#' validateSettings(data=adlbc, settings=testSettings) # .$valid is TRUE
-#' testSettings$id_col <- "NotAColumn"
-#' validateSettings(data=adlbc, settings=testSettings) # .$valid is now FALSE
#' @export
-#' @importFrom purrr map map_lgl map_dbl
+#' @import dplyr
+#' @importFrom tibble tibble
+#' @importFrom purrr map map_lgl map_dbl map_chr
#' @importFrom magrittr "%>%"
#' @importFrom rlang .data
@@ -35,28 +43,43 @@ validateSettings <- function(data, settings, chart="eDish"){
settingStatus<-list()
# Check that all required parameters are not null
- requiredChecks <- getRequiredSettings(chart = chart) %>% purrr::map(checkSettingProvided, settings = settings)
+ requiredChecks <- getRequiredSettings(chart = chart) %>% purrr::map(checkRequired, settings = settings)
#Check that non-null setting columns are found in the data
- columnChecks <- getSettingKeys(patterns="_col",settings=settings) %>% purrr::map(checkColumnSetting, settings=settings, data=data)
+ dataKeys <- getSettingsMetadata(charts=chart, filter_expr = .data$column_mapping, cols = "text_key")%>%textKeysToList()
+ columnChecks <- dataKeys %>% purrr::map(checkColumn, settings=settings, data=data)
#Check that non-null field/column combinations are found in the data
- fieldChecks <- getSettingKeys(patterns="_values",settings=settings, matchLists=TRUE) %>% purrr::map(checkFieldSettings, settings=settings, data=data )
- fieldChecks_flat <- unlist(fieldChecks, recursive=FALSE)
+ fieldKeys <- getSettingsMetadata(charts=chart, filter_expr = .data$field_mapping)%>%
+ filter(.data$setting_type!="vector")%>% #TODO: check the vectorized fields as well. Not sure a big deal now, since none are required ...
+ select(.data$text_key)%>%
+ unlist()%>%
+ textKeysToList()
+ fieldChecks <- fieldKeys %>% purrr::map(checkField, settings=settings, data=data )
#Check that settings for mapping numeric data are associated with numeric columns
- numericKeys <- getSettingsMetadata(charts=chart, cols="text_key", filter_expr=.data$column_type=="numeric")%>%textKeysToList()
- numericChecks <- numericKeys %>% purrr::map(checkNumericColumns, settings=settings, data=data )
+ numericKeys <- getSettingsMetadata(charts=chart, filter_expr=.data$column_type=="numeric", cols="text_key")%>%textKeysToList()
+ numericChecks <- numericKeys %>% purrr::map(checkNumeric, settings=settings, data=data )
#Combine different check types in to a master list
- settingStatus$checkList<-c(requiredChecks, columnChecks, fieldChecks_flat, numericChecks)
-
+ settingStatus$checks <-c(requiredChecks, columnChecks, fieldChecks, numericChecks) %>% {
+ tibble(
+ key = map(., "key"),
+ text_key = map_chr(., "text_key"),
+ type = map_chr(., "type"),
+ description= map_chr(., "description"),
+ value = map_chr(., "value"),
+ valid = map_lgl(., "valid"),
+ message = map_chr(., "message")
+ )
+ }
+
#valid=true if all checks pass, false otherwise
- settingStatus$valid <- settingStatus$checkList%>%purrr::map_lgl(~.x[["valid"]])%>%all
+ settingStatus$valid <- settingStatus$checks%>%select(.data$valid)%>%unlist%>%all
#create summary string
- failCount <- settingStatus$checkList%>%purrr::map_dbl(~!.x[["valid"]])%>%sum
- checkCount <- length(settingStatus$checkList)
+ failCount <- nrow(settingStatus$checks%>%filter(!.data$valid))
+ checkCount <- nrow(settingStatus$checks)
settingStatus$status <- paste0(failCount," of ",checkCount," checks failed.")
return (settingStatus)
}
diff --git a/README.md b/README.md
index 80087d6b..9b95cc03 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-[](https://travis-ci.org/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics)
+[](https://travis-ci.org/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics) [](https://cran.r-project.org/package=safetyGraphics)
-# safetyGraphics: Clinical Trial Safety Graphics with R
+# safetyGraphics: Clinical Trial Safety Graphics with R
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://asa-dia-interactivesafetygraphics.github.io/safety-eDISH/test/) and is shown below.
@@ -11,7 +11,7 @@ This package is being built in conjunction with the [safety-eDISH](https://githu
## Usage
-Users can interactively explore their data with a shiny application or create standalone interactive charts.
+Users can interactively explore their data with a shiny application or create standalone interactive charts.
### Shiny application
@@ -33,15 +33,15 @@ Users can also initialize customized standalone charts with a few lines of code.
```r
devtools::install_github("ASA-DIA-InteractiveSafetyGraphics/safetyGraphics")
library("safetyGraphics")
-eDISH(data=adlbc,
+eDISH(data=adlbc,
id_col = "USUBJID",
- value_col = "AVAL",
- measure_col = "PARAM",
+ value_col = "AVAL",
+ measure_col = "PARAM",
visit_col = "VISIT",
- visitn_col = "VISITNUM",
+ visitn_col = "VISITNUM",
studyday_col = "ADY",
- normal_col_low = "A1LO",
- normal_col_high = "A1HI",
+ 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)",
diff --git a/data-raw/settingsMetadata.csv b/data-raw/settingsMetadata.csv
index 3ac67a28..ce95c2f3 100644
--- a/data-raw/settingsMetadata.csv
+++ b/data-raw/settingsMetadata.csv
@@ -1,26 +1,26 @@
-chart_edish,text_key,label,description,setting_type,setting_required,column_mapping,column_type,column_required,field_mapping,adam,sdtm
-TRUE,id_col,ID column,Unique subject identifier variable name.,character,TRUE,TRUE,character,TRUE,FALSE,USUBJID,USUBJID
-TRUE,value_col,Value column,Lab result variable name.,character,TRUE,TRUE,numeric,TRUE,FALSE,AVAL,STRESN
-TRUE,measure_col,Measure column,Lab measure variable name,character,TRUE,TRUE,character,TRUE,FALSE,PARAM,TEST
-TRUE,normal_col_low,Lower Limit of Normal column,Lower limit of normal variable name,character,TRUE,TRUE,numeric,TRUE,FALSE,A1LO,STNRLO
-TRUE,normal_col_high,Upper Limit of Normal column,Upper limit of normal variable name,character,TRUE,TRUE,numeric,TRUE,FALSE,A1HI,STNRHI
-TRUE,studyday_col,Study Day column,Visit day variable name,character,TRUE,TRUE,numeric,TRUE,FALSE,ADY,DY
-TRUE,visit_col,Visit column,Visit variable name,character,FALSE,TRUE,character,FALSE,FALSE,VISIT,VISIT
-TRUE,visitn_col,Visit Number column,Visit number variable name,character,FALSE,TRUE,numeric,FALSE,FALSE,VISITNUM,VISITNUM
-TRUE,filters,Filters columns,"An optional list of specifications for filters. Each filter is a nested, named list (containing the filter value column: 'value_col' and associated label: 'label') within the larger list.",vector,FALSE,TRUE,NA,FALSE,FALSE,,
-TRUE,group_cols,Group columns,"An optional list of specifications for grouping columns. Each group column is a nested, named list (containing the group variable column: 'value_col' and associated label: 'label') within the larger list. ",vector,FALSE,TRUE,NA,FALSE,FALSE,,
-TRUE,measure_values--ALT,Alanine Aminotransferase value,Value used for Alanine Aminotransferase in the specified measure column,character,FALSE,FALSE,NA,NA,TRUE,Alanine Aminotransferase (U/L),"Aminotransferase, alanine (ALT)"
-TRUE,measure_values--AST,Aspartate Aminotransferase value,Value used for Aspartate Aminotransferase in the specified measure column,character,FALSE,FALSE,NA,NA,TRUE,Aspartate Aminotransferase (U/L),"Aminotransferase, aspartate (AST)"
-TRUE,measure_values--TB,Total Bilirubin value,Value used for Total Bilirubin in the specified measure column,character,FALSE,FALSE,NA,NA,TRUE,Bilirubin (umol/L),Total Bilirubin
-TRUE,measure_values--ALP,Alkaline Phosphatase value,Value used for Alkaline Phosphatase in the specified measure column,character,FALSE,FALSE,NA,NA,TRUE,Alkaline Phosphatase (U/L),Alkaline phosphatase (ALP)
-TRUE,baseline--value_col,Baseline column,An optional list defining which column represent the baseline visit(s) of the study.,character,FALSE,TRUE,NA,FALSE,FALSE,,
-TRUE,baseline--values,Baseline values,An optional list defining which values (one or more) represent the baseline visit(s) of the study.,vector,FALSE,FALSE,NA,NA,TRUE,,
-TRUE,analysisFlag--value_col,Analysis Flag column,An optional list defining which column should be used in eDish and mDish analyses.,character,FALSE,TRUE,NA,FALSE,FALSE,,
-TRUE,analysisFlag--values,Analysis Flag values,An optional list defining which values should be used in eDish and mDish analyses.,vector,FALSE,FALSE,NA,NA,TRUE,,
-TRUE,x_options,X axis options,"Specifies variable options for the x-axis using the key values from measure_values (e.g. 'ALT'). When multiple options are specified, a control allowing the user to interactively change the x variable is shown. ",vector,FALSE,FALSE,NA,NA,FALSE,,
-TRUE,y_options,Y axis options,"Specifies variable options for the y-axis using the key values from measure_values (e.g. 'TB'). When multiple options are specified, a control allowing the user to interactively change the y variable is shown. ",vector,FALSE,FALSE,NA,NA,FALSE,,
-TRUE,visit_window,Default Visit Window in Days ,Default visit window used to highlight eDish points where x and y measures occurred within the specified number of days. Editable by user after render. ,numeric,FALSE,FALSE,NA,NA,FALSE,,
-TRUE,r_ratio_filter,Show R Ratio Filter?,Specifies whether the R Ratio filter should be shown. R ratio is defined as: (ALT value/ULN for ALT) / (ALP value/ULN for ALP).,logical,FALSE,FALSE,NA,NA,FALSE,,
-TRUE,r_ratio_cut,Default R Ratio Cut,Default cut point for R Ratio filter. Ignored when r_ratio_filter = FALSE. User can update this setting via the UI when r_ratio_filter = TRUE. ,numeric,FALSE,FALSE,NA,NA,FALSE,,
-TRUE,showTitle,Show Chart Title? ,Specifies whether the title should be drawn above the controls.,logical,FALSE,FALSE,NA,NA,FALSE,,
-TRUE,warningText,Warning text,"Informational text to be displayed near the top of the controls (beneath the title, if any). No warning is displayed if warningText = ''. ",Character,FALSE,FALSE,NA,NA,FALSE,,
+chart_edish,text_key,label,description,setting_type,setting_required,column_mapping,column_type,field_mapping,field_column_key,adam,sdtm
+TRUE,id_col,ID column,Unique subject identifier variable name.,character,TRUE,TRUE,character,FALSE,,USUBJID,USUBJID
+TRUE,value_col,Value column,Lab result variable name.,character,TRUE,TRUE,numeric,FALSE,,AVAL,STRESN
+TRUE,measure_col,Measure column,Lab measure variable name,character,TRUE,TRUE,character,FALSE,,PARAM,TEST
+TRUE,normal_col_low,Lower Limit of Normal column,Lower limit of normal variable name,character,TRUE,TRUE,numeric,FALSE,,A1LO,STNRLO
+TRUE,normal_col_high,Upper Limit of Normal column,Upper limit of normal variable name,character,TRUE,TRUE,numeric,FALSE,,A1HI,STNRHI
+TRUE,studyday_col,Study Day column,Visit day variable name,character,TRUE,TRUE,numeric,FALSE,,ADY,DY
+TRUE,visit_col,Visit column,Visit variable name,character,FALSE,TRUE,character,FALSE,,VISIT,VISIT
+TRUE,visitn_col,Visit Number column,Visit number variable name,character,FALSE,TRUE,numeric,FALSE,,VISITNUM,VISITNUM
+TRUE,filters,Filters columns,"An optional list of specifications for filters. Each filter is a nested, named list (containing the filter value column: 'value_col' and associated label: 'label') within the larger list.",vector,FALSE,TRUE,NA,FALSE,,,
+TRUE,group_cols,Group columns,"An optional list of specifications for grouping columns. Each group column is a nested, named list (containing the group variable column: 'value_col' and associated label: 'label') within the larger list. ",vector,FALSE,TRUE,NA,FALSE,,,
+TRUE,measure_values--ALT,Alanine Aminotransferase value,Value used for Alanine Aminotransferase in the specified measure column,character,TRUE,FALSE,NA,TRUE,measure_col,Alanine Aminotransferase (U/L),"Aminotransferase, alanine (ALT)"
+TRUE,measure_values--AST,Aspartate Aminotransferase value,Value used for Aspartate Aminotransferase in the specified measure column,character,TRUE,FALSE,NA,TRUE,measure_col,Aspartate Aminotransferase (U/L),"Aminotransferase, aspartate (AST)"
+TRUE,measure_values--TB,Total Bilirubin value,Value used for Total Bilirubin in the specified measure column,character,TRUE,FALSE,NA,TRUE,measure_col,Bilirubin (umol/L),Total Bilirubin
+TRUE,measure_values--ALP,Alkaline Phosphatase value,Value used for Alkaline Phosphatase in the specified measure column,character,TRUE,FALSE,NA,TRUE,measure_col,Alkaline Phosphatase (U/L),Alkaline phosphatase (ALP)
+TRUE,baseline--value_col,Baseline column,An optional list defining which column represent the baseline visit(s) of the study.,character,FALSE,TRUE,NA,FALSE,,,
+TRUE,baseline--values,Baseline values,An optional list defining which values (one or more) represent the baseline visit(s) of the study.,vector,FALSE,FALSE,NA,TRUE,baseline--value_col,,
+TRUE,analysisFlag--value_col,Analysis Flag column,An optional list defining which column should be used in eDish and mDish analyses.,character,FALSE,TRUE,NA,FALSE,,,
+TRUE,analysisFlag--values,Analysis Flag values,An optional list defining which values should be used in eDish and mDish analyses.,vector,FALSE,FALSE,NA,TRUE,analysisFlag--value_col,,
+TRUE,x_options,X axis options,"Specifies variable options for the x-axis using the key values from measure_values (e.g. 'ALT'). When multiple options are specified, a control allowing the user to interactively change the x variable is shown. ",vector,FALSE,FALSE,NA,FALSE,,,
+TRUE,y_options,Y axis options,"Specifies variable options for the y-axis using the key values from measure_values (e.g. 'TB'). When multiple options are specified, a control allowing the user to interactively change the y variable is shown. ",vector,FALSE,FALSE,NA,FALSE,,,
+TRUE,visit_window,Default Visit Window in Days ,Default visit window used to highlight eDish points where x and y measures occurred within the specified number of days. Editable by user after render. ,numeric,FALSE,FALSE,NA,FALSE,,,
+TRUE,r_ratio_filter,Show R Ratio Filter?,Specifies whether the R Ratio filter should be shown. R ratio is defined as: (ALT value/ULN for ALT) / (ALP value/ULN for ALP).,logical,FALSE,FALSE,NA,FALSE,,,
+TRUE,r_ratio_cut,Default R Ratio Cut,Default cut point for R Ratio filter. Ignored when r_ratio_filter = FALSE. User can update this setting via the UI when r_ratio_filter = TRUE. ,numeric,FALSE,FALSE,NA,FALSE,,,
+TRUE,showTitle,Show Chart Title? ,Specifies whether the title should be drawn above the controls.,logical,FALSE,FALSE,NA,FALSE,,,
+TRUE,warningText,Warning text,"Informational text to be displayed near the top of the controls (beneath the title, if any). No warning is displayed if warningText = ''. ",Character,FALSE,FALSE,NA,FALSE,,,
\ No newline at end of file
diff --git a/data/adlbc.rda b/data/adlbc.rda
index aea28611..aa28c2db 100644
Binary files a/data/adlbc.rda and b/data/adlbc.rda differ
diff --git a/data/settingsMetadata.rda b/data/settingsMetadata.rda
index 82ebf9c0..c70c9c65 100644
Binary files a/data/settingsMetadata.rda and b/data/settingsMetadata.rda differ
diff --git a/inst/eDISH_app/global.R b/inst/eDISH_app/global.R
index 5abc8a29..2d4f75f9 100644
--- a/inst/eDISH_app/global.R
+++ b/inst/eDISH_app/global.R
@@ -1,4 +1,3 @@
-# temporarily load deps
library(safetyGraphics)
library(shiny)
library(shinyjs)
diff --git a/inst/eDISH_app/modules/dataUpload/dataUpload.R b/inst/eDISH_app/modules/dataUpload/dataUpload.R
index 9169e4e2..57f4de9c 100644
--- a/inst/eDISH_app/modules/dataUpload/dataUpload.R
+++ b/inst/eDISH_app/modules/dataUpload/dataUpload.R
@@ -2,7 +2,6 @@ dataUpload <- function(input, output, session){
ns <- session$ns
-
# initiate reactive values - list of uploaded data files
# standard to imitate output of detectStandard.R
dd <- reactiveValues(data = list("Example data" = adlbc), current = 1, standard = list(list("standard" = "ADaM", "details" = list("ADaM"=list("match"="Full")))))
@@ -63,12 +62,14 @@ dataUpload <- function(input, output, session){
names(choices)[i] <- paste0("", names(dd$data)[i], " - ", dd$standard[[i]]$standard, "
")
# If partial data spec match - give the fraction of variables matched
} else {
- fraction_cols <- paste0(toString(length(dd$standard[[i]]$details[[temp_standard]]$matched_columns)), "/" ,
- toString(length(dd$standard[[i]]$details[[temp_standard]]$missing_columns) +
- length(dd$standard[[i]]$details[[temp_standard]]$matched_columns)))
+ valid_count <- dd$standard[[i]]$details[[temp_standard]]$valid_count
+ total_count <- dd$standard[[i]]$details[[temp_standard]]$invalid_count + valid_count
+
+ fraction_cols <- paste0(valid_count, "/" ,total_count)
+
names(choices)[i] <- paste0("", names(dd$data)[i], " - ", "Partial ",
- dd$standard[[i]]$standard, " (", fraction_cols, " columns)", "
")
+ dd$standard[[i]]$standard, " (", fraction_cols, " data settings)", "
")
}
}
return(choices)
@@ -129,9 +130,12 @@ dataUpload <- function(input, output, session){
partial <- ifelse(standard()$details[[current_standard]]$match == "Partial", TRUE, FALSE)
if (partial) {
- partial_cols <- standard()$details[[current_standard]]$matched_columns
+ partial_keys <- standard()$details[[current_standard]]$checks %>%
+ filter(valid==TRUE) %>%
+ select(text_key) %>%
+ pull()
- generateSettings(standard=current_standard, chart="eDish", partial=partial, partial_cols = partial_cols)
+ generateSettings(standard=current_standard, chart="eDish", partial=partial, partial_keys = partial_keys)
} else {
generateSettings(standard=current_standard, chart="eDish")
diff --git a/inst/eDISH_app/modules/renderChart/eDishReport/eDishReport.Rmd b/inst/eDISH_app/modules/renderChart/eDishReport/eDishReport.Rmd
index 8ab2edab..f3202e56 100644
--- a/inst/eDISH_app/modules/renderChart/eDishReport/eDishReport.Rmd
+++ b/inst/eDISH_app/modules/renderChart/eDishReport/eDishReport.Rmd
@@ -12,14 +12,10 @@ params:
## Customized Interactive Safety Graphic {.tabset .tabset-fade}
-```{r, echo = FALSE}
-library(safetyGraphics)
-library(knitr)
-```
-
### Chart
```{r, fig.width=12, fig.height=15, echo = FALSE}
+library(safetyGraphics)
eDISH(data = params$data,
settings = params$settings)
@@ -35,9 +31,17 @@ safetyGraphics is an open source project built using standard web technology and
-#### Code
+#### Code to Reproduce Chart
+
+Use the script below to (1) load the safetyGraphics package, (2) load your data and (3) render the chart. Make sure to update the second line to point at your data.
+
```{r, comment=NA, echo=FALSE}
-graphic_code <- bquote(eDISH(data = params$data,
+lib_code <- quote(library(safetyGraphics))
+lib_code
+
+writeLines("path <- 'path_to_data'") ### <-- Update this!
+writeLines("my_data <- read.csv(file.path(path, 'data.csv'))")
+graphic_code <- bquote(eDISH(data = my_data,
settings = .(params$settings)))
graphic_code
diff --git a/inst/eDISH_app/modules/renderChart/renderEDishChart.R b/inst/eDISH_app/modules/renderChart/renderEDishChart.R
index e0b1fd03..15470cca 100644
--- a/inst/eDISH_app/modules/renderChart/renderEDishChart.R
+++ b/inst/eDISH_app/modules/renderChart/renderEDishChart.R
@@ -8,7 +8,8 @@ renderEDishChart <- function(input, output, session, data, settings, valid){
req(settings())
if (valid()==TRUE){
- eDISH(data = data(), settings = settings())
+ trimmed_data <- safetyGraphics:::trimData(data = data(), settings = settings())
+ eDISH(data = trimmed_data, settings = settings())
} else{
return()
}
diff --git a/inst/eDISH_app/modules/renderSettings/renderSettings.R b/inst/eDISH_app/modules/renderSettings/renderSettings.R
index af6d96c9..3c6aa6d9 100644
--- a/inst/eDISH_app/modules/renderSettings/renderSettings.R
+++ b/inst/eDISH_app/modules/renderSettings/renderSettings.R
@@ -22,10 +22,26 @@ renderSettings <- function(input, output, session, data, settings, status){
choices_tb <- unique(c(settings$measure_values$TB, as.character(data()[,settings$measure_col])))
choices_alp <- unique(c(settings$measure_values$ALP, as.character(data()[,settings$measure_col])))
- updateSelectizeInput(session, "measure_values--ALT", choices = choices_alt)
- updateSelectizeInput(session, "measure_values--AST", choices = choices_ast)
- updateSelectizeInput(session, "measure_values--TB", choices = choices_tb)
- updateSelectizeInput(session, "measure_values--ALP", choices = choices_alp)
+ updateSelectizeInput(session, "measure_values--ALT", choices = choices_alt,
+ options = list (onInitialize = I('function() {
+ //console.log("initializing input with value")
+ //console.log(this)
+ }')))
+ updateSelectizeInput(session, "measure_values--AST", choices = choices_ast,
+ options = list (onInitialize = I('function() {
+ //console.log("initializing input with value")
+ //console.log(this)
+ }')))
+ updateSelectizeInput(session, "measure_values--TB", choices = choices_tb,
+ options = list (onInitialize = I('function() {
+ //console.log("initializing input with value")
+ //console.log(this)
+ }')))
+ updateSelectizeInput(session, "measure_values--ALP", choices = choices_alp,
+ options = list (onInitialize = I('function() {
+ //console.log("initializing input with value")
+ //console.log(this)
+ }')))
} else {
choices_ast <- unique(data()[,input$measure_col])
choices_alt <- unique(data()[,input$measure_col])
@@ -34,20 +50,32 @@ renderSettings <- function(input, output, session, data, settings, status){
updateSelectizeInput(session, "measure_values--ALT", choices = choices_alt,
options = list(
- placeholder = '',
- onInitialize = I('function() { this.setValue(""); }')))
+ onInitialize = I('function() {
+ //console.log("initializing input w/o value")
+ //console.log(this)
+ this.setValue("");
+ }')))
updateSelectizeInput(session, "measure_values--AST", choices = choices_ast,
options = list(
- placeholder = '',
- onInitialize = I('function() { this.setValue(""); }')))
+ onInitialize = I('function() {
+ //console.log("initializing input w/o value")
+ //console.log(this)
+ this.setValue("");
+ }')))
updateSelectizeInput(session, "measure_values--TB", choices = choices_tb,
options = list(
- placeholder = '',
- onInitialize = I('function() { this.setValue(""); }')))
+ onInitialize = I('function() {
+ //console.log("initializing input w/o value")
+ //console.log(this)
+ this.setValue("");
+ }')))
updateSelectizeInput(session, "measure_values--ALP", choices = choices_alp,
options = list(
- placeholder = '',
- onInitialize = I('function() { this.setValue(""); }')))
+ onInitialize = I('function() {
+ //console.log("initializing input w/o value")
+ //console.log(this)
+ this.setValue("");
+ }')))
}
} else {
updateSelectizeInput(session, "measure_values--ALT", choices = "")
@@ -71,15 +99,22 @@ renderSettings <- function(input, output, session, data, settings, status){
choices <- unique(c(settings$baseline$values, as.character(data()[,settings$baseline$value_col])))
choices <- sort(choices)
- updateSelectizeInput(session, "baseline--values", choices = choices)
+ updateSelectizeInput(session, "baseline--values", choices = choices,
+ options = list (onInitialize = I('function() {
+ //console.log("initializing input with value")
+ //console.log(this)
+ }')))
} else {
choices <- unique(data()[,input$`baseline--value_col`])
choices <- sort(choices)
updateSelectizeInput(session, "baseline--values", choices = choices,
options = list(
- placeholder = '',
- onInitialize = I('function() { this.setValue(""); }')))
+ onInitialize = I('function() {
+ //console.log("initializing input w/o value")
+ //console.log(this)
+ this.setValue("");
+ }')))
}
} else {
updateSelectizeInput(session, "baseline--values", choices = "")
@@ -99,14 +134,21 @@ renderSettings <- function(input, output, session, data, settings, status){
if (!is.null(settings$analysisFlag$value_col) && input$`analysisFlag--value_col`==settings$analysisFlag$value_col){
choices <- unique(c(settings$analysisFlag$values, as.character(data()[,settings$analysisFlag$value_col])))
- updateSelectizeInput(session, "analysisFlag--values", choices = choices)
+ updateSelectizeInput(session, "analysisFlag--values", choices = choices,,
+ options = list (onInitialize = I('function() {
+ //console.log("initializing input with value")
+ //console.log(this)
+ }')))
} else {
choices <- unique(data()[,input$`analysisFlag--value_col`])
updateSelectizeInput(session, "analysisFlag--values", choices = choices,
options = list(
- placeholder = '',
- onInitialize = I('function() { this.setValue(""); }')))
+ onInitialize = I('function() {
+ //console.log("initializing input w/o value")
+ //console.log(this)
+ this.setValue("");
+ }')))
}
} else {
updateSelectizeInput(session, "analysisFlag--values", choices = "")
@@ -222,10 +264,8 @@ renderSettings <- function(input, output, session, data, settings, status){
#Setting Status information (from failed checks only)
status_df <- reactive({
req(status_new())
- status_new()$checkList %>%
- map(., ~ keep(., names(.) %in% c("text_key","valid","message")) %>%
- data.frame(., stringsAsFactors = FALSE)) %>%
- bind_rows %>%
+
+ status_new()$checks %>%
group_by(text_key) %>%
mutate(num_fail = sum(valid==FALSE)) %>%
mutate(message_long = paste(message, collapse = " ") %>% trimws(),
@@ -336,7 +376,6 @@ renderSettings <- function(input, output, session, data, settings, status){
}
})
-
### return updated settings and status to global env.
return(list(settings = reactive(settings_new()),
status = reactive(status_new())))
diff --git a/inst/eDISH_app/modules/renderSettings/renderSettingsUI.R b/inst/eDISH_app/modules/renderSettings/renderSettingsUI.R
index caeea3c5..0738d245 100644
--- a/inst/eDISH_app/modules/renderSettings/renderSettingsUI.R
+++ b/inst/eDISH_app/modules/renderSettings/renderSettingsUI.R
@@ -4,207 +4,227 @@ renderSettingsUI <- function(id){
ns <- NS(id)
tagList(
- fluidRow(
- splitLayout(
- tagList(
- wellPanel(
- fluidRow(
- column(6,
- h3("Data Mapping"),
- div(
- span(id = ns("tt_lbl_id_col"), title = "",
- tags$label(id = ns("lbl_id_col"), "")),
- span(id = ns("tt_msg_id_col"), title = "",
- tags$label(id = ns("msg_id_col"), "")),
- selectizeInput(ns("id_col"),NULL, choices = NULL)
-
- ),
-
- div(
- span(id = ns("tt_lbl_value_col"), title = "",
- tags$label(id = ns("lbl_value_col"), "")),
- span(id = ns("tt_msg_value_col"), title = "",
- tags$label(id = ns("msg_value_col"), "")),
- selectizeInput(ns("value_col"),NULL, choices = NULL)
-
- ),
-
- div(
- span(id = ns("tt_lbl_measure_col"), title = "",
- tags$label(id = ns("lbl_measure_col"), "")),
- span(id = ns("tt_msg_measure_col"), title = "",
- tags$label(id = ns("msg_measure_col"), "")),
- selectizeInput(ns("measure_col"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_measure_values--ALT"), title = "",
- tags$label(id = ns("lbl_measure_values--ALT"), "")),
- span(id = ns("tt_msg_measure_values--ALT"), title = "",
- tags$label(id = ns("msg_measure_values--ALT"), "")),
- selectizeInput(ns("measure_values--ALT"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_measure_values--AST"), title = "",
- tags$label(id = ns("lbl_measure_values--AST"), "")),
- span(id = ns("tt_msg_measure_values--AST"), title = "",
- tags$label(id = ns("msg_measure_values--AST"), "")),
- selectizeInput(ns("measure_values--AST"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_measure_values--TB"), title = "",
- tags$label(id = ns("lbl_measure_values--TB"), "")),
- span(id = ns("tt_msg_measure_values--TB"), title = "",
- tags$label(id = ns("msg_measure_values--TB"), "")),
- selectizeInput(ns("measure_values--TB"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_measure_values--ALP"), title = "",
- tags$label(id = ns("lbl_measure_values--ALP"), "")),
- span(id = ns("tt_msg_measure_values--ALP"), title = "",
- tags$label(id = ns("msg_measure_values--ALP"), "")),
- selectizeInput(ns("measure_values--ALP"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_normal_col_low"), title = "",
- tags$label(id = ns("lbl_normal_col_low"), "")),
- span(id = ns("tt_msg_normal_col_low"), title = "",
- tags$label(id = ns("msg_normal_col_low"), "")),
- selectizeInput(ns("normal_col_low"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_normal_col_high"), title = "",
- tags$label(id = ns("lbl_normal_col_high"), "")),
- span(id = ns("tt_msg_normal_col_high"), title = "",
- tags$label(id = ns("msg_normal_col_high"), "")),
- selectizeInput(ns("normal_col_high"),NULL, choices = NULL)
- )
- ) ,
- column(6,
- br(),
- br(),
- br(),
- div(
- span(id = ns("tt_lbl_visit_col"), title = "",
- tags$label(id = ns("lbl_visit_col"), "")),
- span(id = ns("tt_msg_visit_col"), title = "",
- tags$label(id = ns("msg_visit_col"), "")),
- selectizeInput(ns("visit_col"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_visitn_col"), title = "",
- tags$label(id = ns("lbl_visitn_col"), "")),
- span(id = ns("tt_msg_visitn_col"), title = "",
- tags$label(id = ns("msg_visitn_col"), "")),
- selectizeInput(ns("visitn_col"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_studyday_col"), title = "",
- tags$label(id = ns("lbl_studyday_col"), "")),
- span(id = ns("tt_msg_studyday_col"), title = "",
- tags$label(id = ns("msg_studyday_col"), "")),
- selectizeInput(ns("studyday_col"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_baseline--value_col"), title = "",
- tags$label(id = ns("lbl_baseline--value_col"), "")),
- span(id = ns("tt_msg_baseline--value_col"), title = "",
- tags$label(id = ns("msg_baseline--value_col"), "")),
- selectizeInput(ns("baseline--value_col"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_baseline--values"), title = "",
- tags$label(id = ns("lbl_baseline--values"), "")),
- span(id = ns("tt_msg_baseline--values"), title = "",
- tags$label(id = ns("msg_baseline--values"), "")),
- selectizeInput(ns("baseline--values"),NULL, choices = NULL, multiple = TRUE)
- ),
- div(
- span(id = ns("tt_lbl_filters"), title = "",
- tags$label(id = ns("lbl_filters"), "")),
- span(id = ns("tt_msg_filters"), title = "",
- tags$label(id = ns("msg_filters"), "")),
- selectInput(ns("filters"),NULL, choices = NULL, selected = NULL, multiple = TRUE)
- ),
- div(
- span(id = ns("tt_lbl_group_cols"), title = "",
- tags$label(id = ns("lbl_group_cols"), "")),
- span(id = ns("tt_msg_group_cols"), title = "",
- tags$label(id = ns("msg_group_cols"), "")),
- selectInput(ns("group_cols"),NULL, choices = NULL, selected = NULL, multiple = TRUE)
- ),
- div(
- span(id = ns("tt_lbl_analysisFlag--value_col"), title = "",
- tags$label(id = ns("lbl_analysisFlag--value_col"), "")),
- span(id = ns("tt_msg_analysisFlag--value_col"), title = "",
- tags$label(id = ns("msg_analysisFlag--value_col"), "")),
- selectizeInput(ns("analysisFlag--value_col"),NULL, choices = NULL)
- ),
- div(
- span(id = ns("tt_lbl_analysisFlag--values"), title = "",
- tags$label(id = ns("lbl_analysisFlag--values"), "")),
- span(id = ns("tt_msg_analysisFlag--values"), title = "",
- tags$label(id = ns("msg_analysisFlag--values"), "")),
- selectizeInput(ns("analysisFlag--values"),NULL, choices = NULL, multiple = TRUE)
- ),
- br(),
- br(),
- br(),
- br(),
- br()
- ))
- )
- ),
- tagList(
- column(6,
- wellPanel(
- h3("Measure Settings"),
- div(
- div(id = ns("tt_lbl_x_options"), title = "",
- tags$label(id = ns("lbl_x_options"), "")),
- selectizeInput(ns("x_options"),NULL, choices = c("ALT", "AST", "ALP","TB"), selected = c("ALT", "AST", "ALP"), multiple=TRUE)
- ),
- div(
- div(id = ns("tt_lbl_y_options"), title = "",
- tags$label(id = ns("lbl_y_options"), "")),
- selectizeInput(ns("y_options"),NULL, choices = c("ALT", "AST", "ALP","TB"), selected = c("TB"), multiple = TRUE)
- )
-
- ),
- wellPanel(
- h3("Appearance Settings"),
- div(
- div(id = ns("tt_lbl_visit_window"), title = "",
- tags$label(id = ns("lbl_visit_window"), "")),
- sliderInput(ns("visit_window"),NULL, value = 30, min=0, max=50)
- ),
- div(
- div(id = ns("tt_lbl_r_ratio_filter"), title = "",
- tags$label(id = ns("lbl_r_ratio_filter"), "")),
- checkboxInput(ns("r_ratio_filter"),NULL, value = TRUE)
- ),
- conditionalPanel(
- condition="input.r_ratio_filter==true", ns=ns,
- div(
- div(id = ns("tt_lbl_r_ratio_cut"), title = "",
- tags$label(id = ns("lbl_r_ratio_cut"), "")),
- sliderInput(ns("r_ratio_cut"),NULL, value = 0, min=0, max =1)
- )
- ),
- div(
- div(id = ns("tt_lbl_showTitle"), title = "",
- tags$label(id = ns("lbl_showTitle"), "")),
- checkboxInput(ns("showTitle"),NULL, value = TRUE)
- ),
- div(
- div(id = ns("tt_lbl_warningText"), title = "",
- tags$label(id = ns("lbl_warningText"), "")),
- textAreaInput (ns("warningText"),NULL, rows =4,
- value = "Caution: This interactive graphic is not validated. Any clinical recommendations based on this tool should be confirmed using your organizations standard operating procedures.")
- )
- )
- )
- ))
- )
-
- )
+ verticalLayout(
+
+ fluidRow(
+ column(6,
+ div(
+ div(style="display: inline-block;", h3("Data Mapping")),
+ div(style="display: inline-block;", checkboxInput(ns("show_data_mapping"), "show", TRUE))
+ )
+ )
+ ),
+ conditionalPanel(condition="input.show_data_mapping", ns=ns,
+ fluidRow(
+ column(4,
+ wellPanel(
+ div(
+ span(id = ns("tt_lbl_id_col"), title = "",
+ tags$label(id = ns("lbl_id_col"), "")),
+ span(id = ns("tt_msg_id_col"), title = "",
+ tags$label(id = ns("msg_id_col"), "")),
+ selectizeInput(ns("id_col"),NULL, choices = NULL)
+
+ ),
+
+ div(
+ span(id = ns("tt_lbl_value_col"), title = "",
+ tags$label(id = ns("lbl_value_col"), "")),
+ span(id = ns("tt_msg_value_col"), title = "",
+ tags$label(id = ns("msg_value_col"), "")),
+ selectizeInput(ns("value_col"),NULL, choices = NULL)
+
+ ),
+
+ div(
+ span(id = ns("tt_lbl_measure_col"), title = "",
+ tags$label(id = ns("lbl_measure_col"), "")),
+ span(id = ns("tt_msg_measure_col"), title = "",
+ tags$label(id = ns("msg_measure_col"), "")),
+ selectizeInput(ns("measure_col"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_measure_values--ALT"), title = "",
+ tags$label(id = ns("lbl_measure_values--ALT"), "")),
+ span(id = ns("tt_msg_measure_values--ALT"), title = "",
+ tags$label(id = ns("msg_measure_values--ALT"), "")),
+ selectizeInput(ns("measure_values--ALT"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_measure_values--AST"), title = "",
+ tags$label(id = ns("lbl_measure_values--AST"), "")),
+ span(id = ns("tt_msg_measure_values--AST"), title = "",
+ tags$label(id = ns("msg_measure_values--AST"), "")),
+ selectizeInput(ns("measure_values--AST"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_measure_values--TB"), title = "",
+ tags$label(id = ns("lbl_measure_values--TB"), "")),
+ span(id = ns("tt_msg_measure_values--TB"), title = "",
+ tags$label(id = ns("msg_measure_values--TB"), "")),
+ selectizeInput(ns("measure_values--TB"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_measure_values--ALP"), title = "",
+ tags$label(id = ns("lbl_measure_values--ALP"), "")),
+ span(id = ns("tt_msg_measure_values--ALP"), title = "",
+ tags$label(id = ns("msg_measure_values--ALP"), "")),
+ selectizeInput(ns("measure_values--ALP"),NULL, choices = NULL)
+ ),
+ # ),
+ div(
+ span(id = ns("tt_lbl_normal_col_low"), title = "",
+ tags$label(id = ns("lbl_normal_col_low"), "")),
+ span(id = ns("tt_msg_normal_col_low"), title = "",
+ tags$label(id = ns("msg_normal_col_low"), "")),
+ selectizeInput(ns("normal_col_low"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_normal_col_high"), title = "",
+ tags$label(id = ns("lbl_normal_col_high"), "")),
+ span(id = ns("tt_msg_normal_col_high"), title = "",
+ tags$label(id = ns("msg_normal_col_high"), "")),
+ selectizeInput(ns("normal_col_high"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_visit_col"), title = "",
+ tags$label(id = ns("lbl_visit_col"), "")),
+ span(id = ns("tt_msg_visit_col"), title = "",
+ tags$label(id = ns("msg_visit_col"), "")),
+ selectizeInput(ns("visit_col"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_visitn_col"), title = "",
+ tags$label(id = ns("lbl_visitn_col"), "")),
+ span(id = ns("tt_msg_visitn_col"), title = "",
+ tags$label(id = ns("msg_visitn_col"), "")),
+ selectizeInput(ns("visitn_col"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_studyday_col"), title = "",
+ tags$label(id = ns("lbl_studyday_col"), "")),
+ span(id = ns("tt_msg_studyday_col"), title = "",
+ tags$label(id = ns("msg_studyday_col"), "")),
+ selectizeInput(ns("studyday_col"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_baseline--value_col"), title = "",
+ tags$label(id = ns("lbl_baseline--value_col"), "")),
+ span(id = ns("tt_msg_baseline--value_col"), title = "",
+ tags$label(id = ns("msg_baseline--value_col"), "")),
+ selectizeInput(ns("baseline--value_col"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_baseline--values"), title = "",
+ tags$label(id = ns("lbl_baseline--values"), "")),
+ span(id = ns("tt_msg_baseline--values"), title = "",
+ tags$label(id = ns("msg_baseline--values"), "")),
+ selectizeInput(ns("baseline--values"),NULL, choices = NULL, multiple = TRUE)
+ ),
+ div(
+ span(id = ns("tt_lbl_filters"), title = "",
+ tags$label(id = ns("lbl_filters"), "")),
+ span(id = ns("tt_msg_filters"), title = "",
+ tags$label(id = ns("msg_filters"), "")),
+ selectInput(ns("filters"),NULL, choices = NULL, selected = NULL, multiple = TRUE)
+ ),
+ div(
+ span(id = ns("tt_lbl_group_cols"), title = "",
+ tags$label(id = ns("lbl_group_cols"), "")),
+ span(id = ns("tt_msg_group_cols"), title = "",
+ tags$label(id = ns("msg_group_cols"), "")),
+ selectInput(ns("group_cols"),NULL, choices = NULL, selected = NULL, multiple = TRUE)
+ ),
+ div(
+ span(id = ns("tt_lbl_analysisFlag--value_col"), title = "",
+ tags$label(id = ns("lbl_analysisFlag--value_col"), "")),
+ span(id = ns("tt_msg_analysisFlag--value_col"), title = "",
+ tags$label(id = ns("msg_analysisFlag--value_col"), "")),
+ selectizeInput(ns("analysisFlag--value_col"),NULL, choices = NULL)
+ ),
+ div(
+ span(id = ns("tt_lbl_analysisFlag--values"), title = "",
+ tags$label(id = ns("lbl_analysisFlag--values"), "")),
+ span(id = ns("tt_msg_analysisFlag--values"), title = "",
+ tags$label(id = ns("msg_analysisFlag--values"), "")),
+ selectizeInput(ns("analysisFlag--values"),NULL, choices = NULL, multiple = TRUE)
+ )
+ ))
+
+ )
+ ),
+
+ fluidRow(
+ column(6,
+ div(
+ div(style="display: inline-block;", h3("Measure Settings")),
+ div(style="display: inline-block;", checkboxInput(ns("show_measure_settings"), "show", TRUE))
+ )
+ )
+ ),
+ conditionalPanel(condition="input.show_measure_settings", ns=ns,
+ fluidRow(
+ column(4,
+ wellPanel(
+ div(
+ div(id = ns("tt_lbl_x_options"), title = "",
+ tags$label(id = ns("lbl_x_options"), "")),
+ selectizeInput(ns("x_options"),NULL, choices = c("ALT", "AST", "ALP","TB"), selected = c("ALT", "AST", "ALP"), multiple=TRUE)
+ ),
+ div(
+ div(id = ns("tt_lbl_y_options"), title = "",
+ tags$label(id = ns("lbl_y_options"), "")),
+ selectizeInput(ns("y_options"),NULL, choices = c("ALT", "AST", "ALP","TB"), selected = c("TB"), multiple = TRUE)
+ )
+
+ )
+ )
+ )
+ ),
+ fluidRow(
+ column(6,
+ div(
+ div(style="display: inline-block;", h3("Appearance Settings")),
+ div(style="display: inline-block;", checkboxInput(ns("show_appearance_settings"), "show", TRUE))
+ )
+ )
+ ),
+ conditionalPanel(condition="input.show_appearance_settings", ns=ns,
+ fluidRow(
+ column(4,
+ wellPanel(
+ div(
+ div(id = ns("tt_lbl_visit_window"), title = "",
+ tags$label(id = ns("lbl_visit_window"), "")),
+ sliderInput(ns("visit_window"),NULL, value = 30, min=0, max=50)
+ ),
+ div(
+ div(id = ns("tt_lbl_r_ratio_filter"), title = "",
+ tags$label(id = ns("lbl_r_ratio_filter"), "")),
+ checkboxInput(ns("r_ratio_filter"),NULL, value = TRUE)
+ ),
+ conditionalPanel(
+ condition="input.r_ratio_filter==true", ns=ns,
+ div(
+ div(id = ns("tt_lbl_r_ratio_cut"), title = "",
+ tags$label(id = ns("lbl_r_ratio_cut"), "")),
+ sliderInput(ns("r_ratio_cut"),NULL, value = 0, min=0, max =1)
+ )
+ ),
+ div(
+ div(id = ns("tt_lbl_showTitle"), title = "",
+ tags$label(id = ns("lbl_showTitle"), "")),
+ checkboxInput(ns("showTitle"),NULL, value = TRUE)
+ ),
+ div(
+ div(id = ns("tt_lbl_warningText"), title = "",
+ tags$label(id = ns("lbl_warningText"), "")),
+ textAreaInput (ns("warningText"),NULL, rows =4,
+ value = "Caution: This interactive graphic is not validated. Any clinical recommendations based on this tool should be confirmed using your organizations standard operating procedures.")
+ )
+ )
+ )
+ )
+ )
+ ))
}
diff --git a/inst/eDISH_app/modules/renderSettings/util/flagSetting.R b/inst/eDISH_app/modules/renderSettings/util/flagSetting.R
index e09ce26c..eb0b6542 100644
--- a/inst/eDISH_app/modules/renderSettings/util/flagSetting.R
+++ b/inst/eDISH_app/modules/renderSettings/util/flagSetting.R
@@ -1,4 +1,7 @@
flagSetting<-function(session, name, originalLabel){
+
+ originalLabel <- paste("", originalLabel)
+
shinyjs::html(id = paste0("lbl_", name),
html = paste0(originalLabel, "*"),
add = FALSE)
diff --git a/inst/eDISH_app/modules/renderSettings/util/labelSetting.R b/inst/eDISH_app/modules/renderSettings/util/labelSetting.R
index 013d9e1a..cf0f4cf7 100644
--- a/inst/eDISH_app/modules/renderSettings/util/labelSetting.R
+++ b/inst/eDISH_app/modules/renderSettings/util/labelSetting.R
@@ -1,4 +1,7 @@
labelSetting<-function(ns, name, label, description){
+
+
+ label <- paste("", label)
label_id <- paste0("lbl_", name)
shinyjs::html(id = label_id,
diff --git a/inst/eDISH_app/modules/renderSettings/util/updateSettingStatus.R b/inst/eDISH_app/modules/renderSettings/util/updateSettingStatus.R
index 761acd4a..c594d42b 100644
--- a/inst/eDISH_app/modules/renderSettings/util/updateSettingStatus.R
+++ b/inst/eDISH_app/modules/renderSettings/util/updateSettingStatus.R
@@ -5,13 +5,15 @@ updateSettingStatus<-function(ns, name, status_short, status_long){
if (status_short=="OK"){
shinyjs::html(id = msg_id,
- html = paste0(" ", status_short,""))
+ html = paste(" ", status_short,"",
+ ""))
shinyjs::runjs(paste0('$("#',ns(tooltip_id), '").attr("title", "Selection is valid")'))
} else {
shinyjs::html(id = msg_id,
- html = paste0(" ", status_short,""))
+ html = paste(" ", status_short,"",
+ ""))
shinyjs::runjs(paste0('$("#',ns(tooltip_id), '").attr("title", "', status_long, '")'))
}
diff --git a/inst/eDISH_app/tests/defaultPath-expected/002.json b/inst/eDISH_app/tests/defaultPath-expected/002.json
index 536a9bb0..df17ccdc 100644
--- a/inst/eDISH_app/tests/defaultPath-expected/002.json
+++ b/inst/eDISH_app/tests/defaultPath-expected/002.json
@@ -1,276 +1,313 @@
{
"export": {
"datatab-status": {
- "checkList": [
- {
- "key": [
+ "checks": {
+ "key": [
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "value for specified key found in settings?",
- "value": "USUBJID",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "value for specified key found in settings?",
- "value": "AVAL",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "value for specified key found in settings?",
- "value": "PARAM",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "value for specified key found in settings?",
- "value": "A1LO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "value for specified key found in settings?",
- "value": "A1HI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "value for specified key found in settings?",
- "value": "ADY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "measure_values",
+ "ALT"
+ ],
+ [
+ "measure_values",
+ "AST"
+ ],
+ [
+ "measure_values",
+ "TB"
+ ],
+ [
+ "measure_values",
+ "ALP"
+ ],
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "USUBJID",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "AVAL",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "PARAM",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "A1LO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "A1HI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "ADY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visit_col"
],
- "text_key": "visit_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "VISIT",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visitn_col"
],
- "text_key": "visitn_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "VISITNUM",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "filters"
+ ],
+ [
"group_cols"
],
- "text_key": "group_cols",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"baseline",
"value_col"
],
- "text_key": "baseline--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"analysisFlag",
"value_col"
],
- "text_key": "analysisFlag--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALT"
],
- "text_key": "measure_values--ALT",
- "check": "'_values' field from setting found in data?",
- "value": "Alanine Aminotransferase (U/L)",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"AST"
],
- "text_key": "measure_values--AST",
- "check": "'_values' field from setting found in data?",
- "value": "Aspartate Aminotransferase (U/L)",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"TB"
],
- "text_key": "measure_values--TB",
- "check": "'_values' field from setting found in data?",
- "value": "Bilirubin (umol/L)",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALP"
],
- "text_key": "measure_values--ALP",
- "check": "'_values' field from setting found in data?",
- "value": "Alkaline Phosphatase (U/L)",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "specified column is numeric?",
- "value": "AVAL",
- "valid": true,
- "message": "9 of 10288 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "specified column is numeric?",
- "value": "A1LO",
- "valid": true,
- "message": "0 of 10288 values were not numeric."
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "specified column is numeric?",
- "value": "A1HI",
- "valid": true,
- "message": "0 of 10288 values were not numeric."
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "specified column is numeric?",
- "value": "ADY",
- "valid": true,
- "message": "0 of 10288 values were not numeric."
- },
- {
- "key": [
+ [
"visitn_col"
- ],
- "text_key": "visitn_col",
- "check": "specified column is numeric?",
- "value": "VISITNUM",
- "valid": true,
- "message": "0 of 10288 values were not numeric."
- }
- ],
+ ]
+ ],
+ "text_key": [
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "value_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visitn_col"
+ ],
+ "type": [
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "field",
+ "field",
+ "field",
+ "field",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric"
+ ],
+ "description": [
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?"
+ ],
+ "value": [
+ "USUBJID",
+ "AVAL",
+ "PARAM",
+ "A1LO",
+ "A1HI",
+ "ADY",
+ "Alanine Aminotransferase (U/L)",
+ "Aspartate Aminotransferase (U/L)",
+ "Bilirubin (umol/L)",
+ "Alkaline Phosphatase (U/L)",
+ "USUBJID",
+ "AVAL",
+ "PARAM",
+ "A1LO",
+ "A1HI",
+ "ADY",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "Alanine Aminotransferase (U/L)",
+ "Aspartate Aminotransferase (U/L)",
+ "Bilirubin (umol/L)",
+ "Alkaline Phosphatase (U/L)",
+ "AVAL",
+ "A1LO",
+ "A1HI",
+ "ADY",
+ "--No Value Given--"
+ ],
+ "valid": [
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true
+ ],
+ "message": [
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "9 of 10288 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "0 of 10288 values were not numeric.",
+ "0 of 10288 values were not numeric.",
+ "0 of 10288 values were not numeric.",
+ ""
+ ]
+ },
"valid": true,
- "status": "0 of 26 checks failed."
+ "status": "0 of 31 checks failed."
},
"settingsUI-status_df": {
"text_key": [
@@ -280,12 +317,16 @@
"normal_col_low",
"normal_col_high",
"studyday_col",
- "visit_col",
- "visitn_col",
"measure_values--ALT",
"measure_values--AST",
"measure_values--TB",
- "measure_values--ALP"
+ "measure_values--ALP",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col"
],
"message_long": [
"",
@@ -295,7 +336,11 @@
"0 of 10288 values were not numeric.",
"0 of 10288 values were not numeric.",
"",
- "0 of 10288 values were not numeric.",
+ "",
+ "",
+ "",
+ "",
+ "",
"",
"",
"",
@@ -313,6 +358,10 @@
"OK",
"OK",
"OK",
+ "OK",
+ "OK",
+ "OK",
+ "OK",
"OK"
],
"num_fail": [
@@ -327,6 +376,10 @@
0,
0,
0,
+ 0,
+ 0,
+ 0,
+ 0,
0
]
}
diff --git a/inst/eDISH_app/tests/defaultPath-expected/002.png b/inst/eDISH_app/tests/defaultPath-expected/002.png
index 72f793b8..236766f0 100644
Binary files a/inst/eDISH_app/tests/defaultPath-expected/002.png and b/inst/eDISH_app/tests/defaultPath-expected/002.png differ
diff --git a/inst/eDISH_app/tests/fullSDTM-expected/003.json b/inst/eDISH_app/tests/fullSDTM-expected/003.json
index 3a896aae..bd844f9b 100644
--- a/inst/eDISH_app/tests/fullSDTM-expected/003.json
+++ b/inst/eDISH_app/tests/fullSDTM-expected/003.json
@@ -1,276 +1,313 @@
{
"export": {
"datatab-status": {
- "checkList": [
- {
- "key": [
+ "checks": {
+ "key": [
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "value for specified key found in settings?",
- "value": "USUBJID",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "value for specified key found in settings?",
- "value": "STRESN",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "value for specified key found in settings?",
- "value": "TEST",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "value for specified key found in settings?",
- "value": "STNRLO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "value for specified key found in settings?",
- "value": "STNRHI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "value for specified key found in settings?",
- "value": "DY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "measure_values",
+ "ALT"
+ ],
+ [
+ "measure_values",
+ "AST"
+ ],
+ [
+ "measure_values",
+ "TB"
+ ],
+ [
+ "measure_values",
+ "ALP"
+ ],
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "USUBJID",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STRESN",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "TEST",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STNRLO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STNRHI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "DY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visit_col"
],
- "text_key": "visit_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "VISIT",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visitn_col"
],
- "text_key": "visitn_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "VISITNUM",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "filters"
+ ],
+ [
"group_cols"
],
- "text_key": "group_cols",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"baseline",
"value_col"
],
- "text_key": "baseline--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"analysisFlag",
"value_col"
],
- "text_key": "analysisFlag--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALT"
],
- "text_key": "measure_values--ALT",
- "check": "'_values' field from setting found in data?",
- "value": "Aminotransferase, alanine (ALT)",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"AST"
],
- "text_key": "measure_values--AST",
- "check": "'_values' field from setting found in data?",
- "value": "Aminotransferase, aspartate (AST)",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"TB"
],
- "text_key": "measure_values--TB",
- "check": "'_values' field from setting found in data?",
- "value": "Total Bilirubin",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALP"
],
- "text_key": "measure_values--ALP",
- "check": "'_values' field from setting found in data?",
- "value": "Alkaline phosphatase (ALP)",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "specified column is numeric?",
- "value": "STRESN",
- "valid": true,
- "message": "2592 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "specified column is numeric?",
- "value": "STNRLO",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "specified column is numeric?",
- "value": "STNRHI",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "specified column is numeric?",
- "value": "DY",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"visitn_col"
- ],
- "text_key": "visitn_col",
- "check": "specified column is numeric?",
- "value": "VISITNUM",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- }
- ],
+ ]
+ ],
+ "text_key": [
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "value_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visitn_col"
+ ],
+ "type": [
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "field",
+ "field",
+ "field",
+ "field",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric"
+ ],
+ "description": [
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?"
+ ],
+ "value": [
+ "USUBJID",
+ "STRESN",
+ "TEST",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "Aminotransferase, alanine (ALT)",
+ "Aminotransferase, aspartate (AST)",
+ "Total Bilirubin",
+ "Alkaline phosphatase (ALP)",
+ "USUBJID",
+ "STRESN",
+ "TEST",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "Aminotransferase, alanine (ALT)",
+ "Aminotransferase, aspartate (AST)",
+ "Total Bilirubin",
+ "Alkaline phosphatase (ALP)",
+ "STRESN",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "--No Value Given--"
+ ],
+ "valid": [
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true
+ ],
+ "message": [
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "2592 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ ""
+ ]
+ },
"valid": true,
- "status": "0 of 26 checks failed."
+ "status": "0 of 31 checks failed."
},
"settingsUI-status_df": {
"text_key": [
@@ -280,12 +317,16 @@
"normal_col_low",
"normal_col_high",
"studyday_col",
- "visit_col",
- "visitn_col",
"measure_values--ALT",
"measure_values--AST",
"measure_values--TB",
- "measure_values--ALP"
+ "measure_values--ALP",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col"
],
"message_long": [
"",
@@ -295,7 +336,11 @@
"15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
"15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
"",
- "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "",
+ "",
+ "",
+ "",
+ "",
"",
"",
"",
@@ -313,6 +358,10 @@
"OK",
"OK",
"OK",
+ "OK",
+ "OK",
+ "OK",
+ "OK",
"OK"
],
"num_fail": [
@@ -327,6 +376,10 @@
0,
0,
0,
+ 0,
+ 0,
+ 0,
+ 0,
0
]
}
diff --git a/inst/eDISH_app/tests/fullSDTM-expected/003.png b/inst/eDISH_app/tests/fullSDTM-expected/003.png
index 6716c14c..a4bb7b86 100644
Binary files a/inst/eDISH_app/tests/fullSDTM-expected/003.png and b/inst/eDISH_app/tests/fullSDTM-expected/003.png differ
diff --git a/inst/eDISH_app/tests/noStandard-expected/003.json b/inst/eDISH_app/tests/noStandard-expected/003.json
index 0c92d1aa..cdbede1b 100644
--- a/inst/eDISH_app/tests/noStandard-expected/003.json
+++ b/inst/eDISH_app/tests/noStandard-expected/003.json
@@ -1,276 +1,313 @@
{
"export": {
"datatab-status": {
- "checkList": [
- {
- "key": [
+ "checks": {
+ "key": [
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "id_col not specified in settings."
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "value_col not specified in settings."
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "measure_col not specified in settings."
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "normal_col_low not specified in settings."
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "normal_col_high not specified in settings."
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "studyday_col not specified in settings."
- },
- {
- "key": [
+ [
+ "measure_values",
+ "ALT"
+ ],
+ [
+ "measure_values",
+ "AST"
+ ],
+ [
+ "measure_values",
+ "TB"
+ ],
+ [
+ "measure_values",
+ "ALP"
+ ],
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visit_col"
],
- "text_key": "visit_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visitn_col"
],
- "text_key": "visitn_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "filters"
+ ],
+ [
"group_cols"
],
- "text_key": "group_cols",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"baseline",
"value_col"
],
- "text_key": "baseline--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"analysisFlag",
"value_col"
],
- "text_key": "analysisFlag--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALT"
],
- "text_key": "measure_values--ALT",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"AST"
],
- "text_key": "measure_values--AST",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"TB"
],
- "text_key": "measure_values--TB",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALP"
],
- "text_key": "measure_values--ALP",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "specified column is numeric?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "specified column is numeric?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "specified column is numeric?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "specified column is numeric?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visitn_col"
- ],
- "text_key": "visitn_col",
- "check": "specified column is numeric?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- }
- ],
+ ]
+ ],
+ "text_key": [
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "value_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visitn_col"
+ ],
+ "type": [
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "field",
+ "field",
+ "field",
+ "field",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric"
+ ],
+ "description": [
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?"
+ ],
+ "value": [
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--"
+ ],
+ "valid": [
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true
+ ],
+ "message": [
+ "id_col not specified in settings.",
+ "value_col not specified in settings.",
+ "measure_col not specified in settings.",
+ "normal_col_low not specified in settings.",
+ "normal_col_high not specified in settings.",
+ "studyday_col not specified in settings.",
+ "measure_values--ALT not specified in settings.",
+ "measure_values--AST not specified in settings.",
+ "measure_values--TB not specified in settings.",
+ "measure_values--ALP not specified in settings.",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ""
+ ]
+ },
"valid": false,
- "status": "6 of 26 checks failed."
+ "status": "10 of 31 checks failed."
},
"settingsUI-status_df": {
"text_key": [
@@ -280,9 +317,16 @@
"normal_col_low",
"normal_col_high",
"studyday_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
"visit_col",
"visitn_col",
- "measure_values"
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col"
],
"message_long": [
"id_col not specified in settings.",
@@ -291,9 +335,16 @@
"normal_col_low not specified in settings.",
"normal_col_high not specified in settings.",
"studyday_col not specified in settings.",
+ "measure_values--ALT not specified in settings.",
+ "measure_values--AST not specified in settings.",
+ "measure_values--TB not specified in settings.",
+ "measure_values--ALP not specified in settings.",
+ "",
"",
"",
- "No list of values found in settings."
+ "",
+ "",
+ ""
],
"message_short": [
"1 failed check.",
@@ -302,9 +353,16 @@
"1 failed check.",
"1 failed check.",
"1 failed check.",
+ "1 failed check.",
+ "1 failed check.",
+ "1 failed check.",
+ "1 failed check.",
+ "OK",
+ "OK",
"OK",
"OK",
- "1 failed check."
+ "OK",
+ "OK"
],
"num_fail": [
1,
@@ -313,9 +371,16 @@
1,
1,
1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 0,
+ 0,
+ 0,
0,
0,
- 1
+ 0
]
}
}
diff --git a/inst/eDISH_app/tests/noStandard-expected/003.png b/inst/eDISH_app/tests/noStandard-expected/003.png
index f80c43ad..efd59ed9 100644
Binary files a/inst/eDISH_app/tests/noStandard-expected/003.png and b/inst/eDISH_app/tests/noStandard-expected/003.png differ
diff --git a/inst/eDISH_app/tests/partialSDTM-expected/003.json b/inst/eDISH_app/tests/partialSDTM-expected/003.json
index d3e19a03..7b652083 100644
--- a/inst/eDISH_app/tests/partialSDTM-expected/003.json
+++ b/inst/eDISH_app/tests/partialSDTM-expected/003.json
@@ -1,276 +1,313 @@
{
"export": {
"datatab-status": {
- "checkList": [
- {
- "key": [
+ "checks": {
+ "key": [
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "id_col not specified in settings."
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "value for specified key found in settings?",
- "value": "STRESN",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "value for specified key found in settings?",
- "value": "TEST",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "value for specified key found in settings?",
- "value": "STNRLO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "value for specified key found in settings?",
- "value": "STNRHI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "value for specified key found in settings?",
- "value": "DY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "measure_values",
+ "ALT"
+ ],
+ [
+ "measure_values",
+ "AST"
+ ],
+ [
+ "measure_values",
+ "TB"
+ ],
+ [
+ "measure_values",
+ "ALP"
+ ],
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STRESN",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "TEST",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STNRLO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STNRHI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "DY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visit_col"
],
- "text_key": "visit_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visitn_col"
],
- "text_key": "visitn_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "filters"
+ ],
+ [
"group_cols"
],
- "text_key": "group_cols",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"baseline",
"value_col"
],
- "text_key": "baseline--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"analysisFlag",
"value_col"
],
- "text_key": "analysisFlag--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALT"
],
- "text_key": "measure_values--ALT",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"AST"
],
- "text_key": "measure_values--AST",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"TB"
],
- "text_key": "measure_values--TB",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALP"
],
- "text_key": "measure_values--ALP",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "specified column is numeric?",
- "value": "STRESN",
- "valid": true,
- "message": "2592 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "specified column is numeric?",
- "value": "STNRLO",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "specified column is numeric?",
- "value": "STNRHI",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "specified column is numeric?",
- "value": "DY",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"visitn_col"
- ],
- "text_key": "visitn_col",
- "check": "specified column is numeric?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- }
- ],
+ ]
+ ],
+ "text_key": [
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "value_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visitn_col"
+ ],
+ "type": [
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "field",
+ "field",
+ "field",
+ "field",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric"
+ ],
+ "description": [
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?"
+ ],
+ "value": [
+ "--No Value Given--",
+ "STRESN",
+ "TEST",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "Aminotransferase, alanine (ALT)",
+ "Aminotransferase, aspartate (AST)",
+ "Total Bilirubin",
+ "Alkaline phosphatase (ALP)",
+ "--No Value Given--",
+ "STRESN",
+ "TEST",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "Aminotransferase, alanine (ALT)",
+ "Aminotransferase, aspartate (AST)",
+ "Total Bilirubin",
+ "Alkaline phosphatase (ALP)",
+ "STRESN",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "--No Value Given--"
+ ],
+ "valid": [
+ false,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true
+ ],
+ "message": [
+ "id_col not specified in settings.",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "2592 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ ""
+ ]
+ },
"valid": false,
- "status": "1 of 26 checks failed."
+ "status": "1 of 31 checks failed."
},
"settingsUI-status_df": {
"text_key": [
@@ -280,12 +317,16 @@
"normal_col_low",
"normal_col_high",
"studyday_col",
- "visit_col",
- "visitn_col",
"measure_values--ALT",
"measure_values--AST",
"measure_values--TB",
- "measure_values--ALP"
+ "measure_values--ALP",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col"
],
"message_long": [
"id_col not specified in settings.",
@@ -299,6 +340,10 @@
"",
"",
"",
+ "",
+ "",
+ "",
+ "",
""
],
"message_short": [
@@ -313,6 +358,10 @@
"OK",
"OK",
"OK",
+ "OK",
+ "OK",
+ "OK",
+ "OK",
"OK"
],
"num_fail": [
@@ -327,6 +376,10 @@
0,
0,
0,
+ 0,
+ 0,
+ 0,
+ 0,
0
]
}
diff --git a/inst/eDISH_app/tests/partialSDTM-expected/003.png b/inst/eDISH_app/tests/partialSDTM-expected/003.png
index bb10bca5..dcf9ca44 100644
Binary files a/inst/eDISH_app/tests/partialSDTM-expected/003.png and b/inst/eDISH_app/tests/partialSDTM-expected/003.png differ
diff --git a/inst/eDISH_app/tests/partialSDTM-expected/004.png b/inst/eDISH_app/tests/partialSDTM-expected/004.png
index 77907bae..bb5732df 100644
Binary files a/inst/eDISH_app/tests/partialSDTM-expected/004.png and b/inst/eDISH_app/tests/partialSDTM-expected/004.png differ
diff --git a/inst/eDISH_app/tests/partialSDTM-expected/005.json b/inst/eDISH_app/tests/partialSDTM-expected/005.json
index f6f3aa21..256070f0 100644
--- a/inst/eDISH_app/tests/partialSDTM-expected/005.json
+++ b/inst/eDISH_app/tests/partialSDTM-expected/005.json
@@ -1,276 +1,313 @@
{
"export": {
"datatab-status": {
- "checkList": [
- {
- "key": [
+ "checks": {
+ "key": [
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "value for specified key found in settings?",
- "value": "--No Value Given--",
- "valid": false,
- "message": "id_col not specified in settings."
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "value for specified key found in settings?",
- "value": "STRESN",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "value for specified key found in settings?",
- "value": "TEST",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "value for specified key found in settings?",
- "value": "STNRLO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "value for specified key found in settings?",
- "value": "STNRHI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "value for specified key found in settings?",
- "value": "DY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "measure_values",
+ "ALT"
+ ],
+ [
+ "measure_values",
+ "AST"
+ ],
+ [
+ "measure_values",
+ "TB"
+ ],
+ [
+ "measure_values",
+ "ALP"
+ ],
+ [
"id_col"
],
- "text_key": "id_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STRESN",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_col"
],
- "text_key": "measure_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "TEST",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STNRLO",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "STNRHI",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "DY",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visit_col"
],
- "text_key": "visit_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"visitn_col"
],
- "text_key": "visitn_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
+ "filters"
+ ],
+ [
"group_cols"
],
- "text_key": "group_cols",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"baseline",
"value_col"
],
- "text_key": "baseline--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"analysisFlag",
"value_col"
],
- "text_key": "analysisFlag--value_col",
- "check": "'_col' parameter from setting setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALT"
],
- "text_key": "measure_values--ALT",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"AST"
],
- "text_key": "measure_values--AST",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"TB"
],
- "text_key": "measure_values--TB",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"measure_values",
"ALP"
],
- "text_key": "measure_values--ALP",
- "check": "'_values' field from setting found in data?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- },
- {
- "key": [
+ [
"value_col"
],
- "text_key": "value_col",
- "check": "specified column is numeric?",
- "value": "STRESN",
- "valid": true,
- "message": "2592 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"normal_col_low"
],
- "text_key": "normal_col_low",
- "check": "specified column is numeric?",
- "value": "STNRLO",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"normal_col_high"
],
- "text_key": "normal_col_high",
- "check": "specified column is numeric?",
- "value": "STNRHI",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"studyday_col"
],
- "text_key": "studyday_col",
- "check": "specified column is numeric?",
- "value": "DY",
- "valid": true,
- "message": "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic."
- },
- {
- "key": [
+ [
"visitn_col"
- ],
- "text_key": "visitn_col",
- "check": "specified column is numeric?",
- "value": "--No Value Given--",
- "valid": true,
- "message": ""
- }
- ],
+ ]
+ ],
+ "text_key": [
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "id_col",
+ "value_col",
+ "measure_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col",
+ "measure_values--ALT",
+ "measure_values--AST",
+ "measure_values--TB",
+ "measure_values--ALP",
+ "value_col",
+ "normal_col_low",
+ "normal_col_high",
+ "studyday_col",
+ "visitn_col"
+ ],
+ "type": [
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "required",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "column",
+ "field",
+ "field",
+ "field",
+ "field",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric",
+ "numeric"
+ ],
+ "description": [
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "value for specified key found in settings?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "column parameter from setting setting found in data?",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "field value from setting found in data",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?",
+ "specified column is numeric?"
+ ],
+ "value": [
+ "--No Value Given--",
+ "STRESN",
+ "TEST",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "Aminotransferase, alanine (ALT)",
+ "Aminotransferase, aspartate (AST)",
+ "Total Bilirubin",
+ "Alkaline phosphatase (ALP)",
+ "--No Value Given--",
+ "STRESN",
+ "TEST",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "--No Value Given--",
+ "Aminotransferase, alanine (ALT)",
+ "Aminotransferase, aspartate (AST)",
+ "Total Bilirubin",
+ "Alkaline phosphatase (ALP)",
+ "STRESN",
+ "STNRLO",
+ "STNRHI",
+ "DY",
+ "--No Value Given--"
+ ],
+ "valid": [
+ false,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true
+ ],
+ "message": [
+ "id_col not specified in settings.",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "2592 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ "15 of 24669 values were not numeric. Records with non-numeric values may not appear in the graphic.",
+ ""
+ ]
+ },
"valid": false,
- "status": "1 of 26 checks failed."
+ "status": "1 of 31 checks failed."
},
"settingsUI-status_df": {
"text_key": [
@@ -280,12 +317,16 @@
"normal_col_low",
"normal_col_high",
"studyday_col",
- "visit_col",
- "visitn_col",
"measure_values--ALT",
"measure_values--AST",
"measure_values--TB",
- "measure_values--ALP"
+ "measure_values--ALP",
+ "visit_col",
+ "visitn_col",
+ "filters",
+ "group_cols",
+ "baseline--value_col",
+ "analysisFlag--value_col"
],
"message_long": [
"",
@@ -299,6 +340,10 @@
"",
"",
"",
+ "",
+ "",
+ "",
+ "",
""
],
"message_short": [
@@ -313,6 +358,10 @@
"OK",
"OK",
"OK",
+ "OK",
+ "OK",
+ "OK",
+ "OK",
"OK"
],
"num_fail": [
@@ -327,6 +376,10 @@
0,
0,
0,
+ 0,
+ 0,
+ 0,
+ 0,
0
]
}
diff --git a/inst/eDISH_app/tests/partialSDTM-expected/005.png b/inst/eDISH_app/tests/partialSDTM-expected/005.png
index ad6a8178..23874c10 100644
Binary files a/inst/eDISH_app/tests/partialSDTM-expected/005.png and b/inst/eDISH_app/tests/partialSDTM-expected/005.png differ
diff --git a/inst/eDISH_app/ui.R b/inst/eDISH_app/ui.R
index 1ee35dc5..a6e2eea2 100644
--- a/inst/eDISH_app/ui.R
+++ b/inst/eDISH_app/ui.R
@@ -1,6 +1,3 @@
-library(shiny)
-library(shinyjs)
-
tagList(
useShinyjs(),
tags$style(HTML("
diff --git a/man/SafetyGraphics.Rd b/man/SafetyGraphics.Rd
new file mode 100644
index 00000000..402e0b04
--- /dev/null
+++ b/man/SafetyGraphics.Rd
@@ -0,0 +1,16 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/safetyGraphics.R
+\docType{package}
+\name{SafetyGraphics}
+\alias{SafetyGraphics}
+\alias{SafetyGraphics-package}
+\title{\code{safetyGraphics} package}
+\description{
+Create Interactive Graphics Related to Clinical Trial Safety
+}
+\details{
+Learn more on
+\href{https://CRAN.R-project.org/package=safetyGraphics}{CRAN}
+or \href{https://github.com/ASA-DIA-InteractiveSafetyGraphics/safetyGraphics}{GitHub}
+}
+\keyword{internal}
diff --git a/man/checkColumnSetting.Rd b/man/checkColumn.Rd
similarity index 79%
rename from man/checkColumnSetting.Rd
rename to man/checkColumn.Rd
index a94b6126..cc5eac43 100644
--- a/man/checkColumnSetting.Rd
+++ b/man/checkColumn.Rd
@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/checkColumnSetting.R
-\name{checkColumnSetting}
-\alias{checkColumnSetting}
+% Please edit documentation in R/checkColumn.R
+\name{checkColumn}
+\alias{checkColumn}
\title{Check that a setting parameter has a matching data column}
\usage{
-checkColumnSetting(key, settings, data)
+checkColumn(key, settings, data)
}
\arguments{
\item{key}{a list (like those provided by \code{getSettingKeys())} defining the position of parameter in the settings object.}
@@ -30,18 +30,19 @@ testSettings$filters[[2]]<-list(value_col=NULL,label="No Column")
testSettings$filters[[3]]<-list(value_col="NotAColumn",label="Invalid Column")
#pass ($valid == TRUE)
-safetyGraphics:::checkColumnSetting(key=list("id_col"),
+safetyGraphics:::checkColumn(key=list("id_col"),
settings=testSettings, adlbc)
#pass
-safetyGraphics:::checkColumnSetting(key=list("filters",1,"value_col"),
+safetyGraphics:::checkColumn(key=list("filters",1,"value_col"),
settings=testSettings, adlbc)
#NULL column pass
-safetyGraphics:::checkColumnSetting(key=list("filters",2,"value_col"),
+safetyGraphics:::checkColumn(key=list("filters",2,"value_col"),
settings=testSettings, adlbc)
#invalid column fails
-safetyGraphics:::checkColumnSetting(key=list("filters",3,"value_col"),
+safetyGraphics:::checkColumn(key=list("filters",3,"value_col"),
settings=testSettings, adlbc)
}
+\keyword{internal}
diff --git a/man/checkField.Rd b/man/checkField.Rd
new file mode 100644
index 00000000..253849d8
--- /dev/null
+++ b/man/checkField.Rd
@@ -0,0 +1,31 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/checkFieldSettings.R
+\name{checkField}
+\alias{checkField}
+\title{Check that a setting parameter has a matching data field}
+\usage{
+checkField(fieldKey, settings, data)
+}
+\arguments{
+\item{fieldKey}{a list (like those provided by \code{getSettingKeys())} defining the position of parameter in the settings object.}
+
+\item{settings}{The settings list used to generate a chart like \code{eDISH()}}
+
+\item{data}{A data frame to check for the specified field}
+}
+\value{
+A list containing the results of the check following the format specified in \code{validateSettings()[["checkList"]]}
+}
+\description{
+Checks that a single parameter from the settings list matches a field value in a specified data set
+}
+\details{
+This function compares settings with field values as part of the \code{validateSettings()} function. More specifically, the function checks whether the \code{fieldKey} in a \code{settings} object matches a column/field combination in \code{"data"}. The function makes 2 major assumptions about the structure of the settings object. First, it assumes that the first value in fieldKey is "settingName_values" and there is a corresponding "settingName_col" setting that defines the column to search for field-level data. Second, it expects that the value specified by key/settings is a list, and that each value in the list is a field of the variable above.
+}
+\examples{
+testSettings<-generateSettings(standard="AdAM")
+fields<-list("measure_values","TB")
+safetyGraphics:::checkField(fieldKey=fields,settings=testSettings, data=adlbc)
+
+}
+\keyword{internal}
diff --git a/man/checkFieldSettings.Rd b/man/checkFieldSettings.Rd
index a19243ef..e8c48684 100644
--- a/man/checkFieldSettings.Rd
+++ b/man/checkFieldSettings.Rd
@@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/checkFieldSettings.R
+% Please edit documentation in R/checkField.R
\name{checkFieldSettings}
\alias{checkFieldSettings}
\title{Check that a setting parameter has a matching data field}
@@ -24,9 +24,8 @@ This function compares settings with field values as part of the \code{validateS
}
\examples{
testSettings<-generateSettings(standard="AdAM")
-
-#list of 4 checks. all pass ($valid ==TRUE)
-safetyGraphics:::checkFieldSettings(fieldKey=list("measure_values"),
- settings=testSettings, adlbc)
+fields<-list("measure_values","TB")
+safetyGraphics:::checkFieldSettings(fieldKey=fields,settings=testSettings, data=adlbc)
}
+\keyword{internal}
diff --git a/man/checkNumericColumns.Rd b/man/checkNumeric.Rd
similarity index 59%
rename from man/checkNumericColumns.Rd
rename to man/checkNumeric.Rd
index b70eaf1b..ce7aded3 100644
--- a/man/checkNumericColumns.Rd
+++ b/man/checkNumeric.Rd
@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/checkNumericColumns.R
-\name{checkNumericColumns}
-\alias{checkNumericColumns}
+% Please edit documentation in R/checkNumeric.R
+\name{checkNumeric}
+\alias{checkNumeric}
\title{Check that settings for mapping numeric data are associated with numeric columns}
\usage{
-checkNumericColumns(key, settings, data)
+checkNumeric(key, settings, data)
}
\arguments{
\item{key}{a list (like those provided by \code{getSettingKeys())} defining the position of parameter in the settings object.}
@@ -21,13 +21,11 @@ Check that settings for mapping numeric data are associated with numeric columns
}
\examples{
testSettings<-generateSettings(standard="AdAM")
-#pass ($valid == TRUE)
-safetyGraphics:::checkSettingProvided(key=list("id_col"),settings=testSettings)
-
-#fails since filters aren't specified by default
-safetyGraphics:::checkSettingProvided(key=list("filters"),settings=testSettings)
+#pass ($valid == FALSE)
+safetyGraphics:::checkNumeric(key=list("id_col"),settings=testSettings, data=adlbc)
-#fails since groups aren't specified by default
-safetyGraphics:::checkSettingProvided(key=list("groups",1,"value_col"),settings=testSettings)
+#pass ($valid == TRUE)
+safetyGraphics:::checkNumeric(key=list("value_col"),settings=testSettings, data=adlbc)
}
+\keyword{internal}
diff --git a/man/checkSettingProvided.Rd b/man/checkRequired.Rd
similarity index 73%
rename from man/checkSettingProvided.Rd
rename to man/checkRequired.Rd
index 58af6a07..89e3470e 100644
--- a/man/checkSettingProvided.Rd
+++ b/man/checkRequired.Rd
@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/checkSettingProvided.R
-\name{checkSettingProvided}
-\alias{checkSettingProvided}
+% Please edit documentation in R/checkRequired.R
+\name{checkRequired}
+\alias{checkRequired}
\title{Check that the user has provided a valid for a given settings parameter}
\usage{
-checkSettingProvided(key, settings)
+checkRequired(key, settings)
}
\arguments{
\item{key}{a list (like those provided by \code{getSettingKeys())} defining the position of parameter in the settings object.}
@@ -21,15 +21,15 @@ Checks that a single required parameter from the settings list is provided by th
testSettings<-generateSettings(standard="AdAM")
#pass ($valid == TRUE)
-safetyGraphics:::checkSettingProvided(key=list("id_col"),
+safetyGraphics:::checkRequired(key=list("id_col"),
settings=testSettings)
#fails since filters aren't specified by default
-safetyGraphics:::checkSettingProvided(key=list("filters"),
+safetyGraphics:::checkRequired(key=list("filters"),
settings=testSettings)
#fails since groups aren't specified by default
-safetyGraphics:::checkSettingProvided(key=list("groups",1,"value_col"),
+safetyGraphics:::checkRequired(key=list("groups",1,"value_col"),
settings=testSettings)
-
}
+\keyword{internal}
diff --git a/man/compare_cols.Rd b/man/compare_cols.Rd
deleted file mode 100644
index 47c50785..00000000
--- a/man/compare_cols.Rd
+++ /dev/null
@@ -1,29 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/compare_cols.R
-\name{compare_cols}
-\alias{compare_cols}
-\title{Compares contents of 2 vectors}
-\usage{
-compare_cols(data_cols, standard_cols)
-}
-\arguments{
-\item{data_cols}{A character vector with column names in the data frame}
-
-\item{standard_cols}{A character vector with column names in the data standard}
-}
-\value{
-A list summarizing the comparison between \code{data_cols} and \code{standard_cols}. List has character vectors for "matched_columns", "extra_columns" and "missing_columns" parameters, and a boolean "match" parameter indicating that there are no missing columns.
-}
-\description{
-Function to compare contents of 2 vectors - used to summarize of which data columns are found in a given standard. Used in \code{detectStandard()} and \code{validateSettings()}
-}
-\examples{
-#match == FALSE
-safetyGraphics:::compare_cols(data_cols=c("a","b","c"),
- standard_cols=c("d","e","f"))
-
-# match == TRUE
-safetyGraphics:::compare_cols(names(adlbc),
- safetyGraphics:::getRequiredColumns(standard="ADaM"))
-
-}
diff --git a/man/detectStandard.Rd b/man/detectStandard.Rd
index 7eacb633..8536045e 100644
--- a/man/detectStandard.Rd
+++ b/man/detectStandard.Rd
@@ -4,28 +4,30 @@
\alias{detectStandard}
\title{Detect the data standard used for a data set}
\usage{
-detectStandard(data, domain = "labs")
+detectStandard(data, includeFields = TRUE, domain = "labs")
}
\arguments{
\item{data}{A data frame in which to detect the data standard}
+\item{includeFields}{specifies whether to check the data set for field level data in addition to columns. Default: \code{TRUE}.}
+
\item{domain}{The data domain for the data set provided. Default: \code{"labs"}.}
}
\value{
-A list containing the matching \code{"standard"} ("ADaM", "SDTM" or "None") and a list of \code{"details"} describing each standard considered. #'
+A list containing the matching \code{"standard"} ("ADaM", "SDTM" or "None") and a list of \code{"details"} describing each standard considered.
}
\description{
This function attempts to detect the data CDISC clinical standard used in a given R data frame.
}
\details{
-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() standards for clinical trial data. Currently, only "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() standards for clinical trial data. Currently, "labs" is the only domain supported.
}
\examples{
detectStandard(adlbc)[["standard"]] #AdAM
detectStandard(iris)[["standard"]] #none
\dontrun{
- detectStandard(adlbc,domain="AE") #throws error. AE domain not supported in this release.
+ detectStandard(adlbc,domain="AE") #throws error. AE domain not supported in this release.
}
}
diff --git a/man/eDISH.Rd b/man/eDISH.Rd
index 3d762dc1..ca3cd726 100644
--- a/man/eDISH.Rd
+++ b/man/eDISH.Rd
@@ -35,23 +35,25 @@ eDISH(data, id_col = "USUBJID", value_col = "STRESN",
\item{studyday_col}{Visit day variable name. Default: \code{"DY"}.}
-\item{baseline}{An optional list defining which column \code{"value_col"} and values (one or more) \code{values} represent the baseline visit(s) of the study.}
+\item{baseline}{An optional list defining which column (\code{value_col}) and \code{values} (one or more) represent the baseline visit(s) of the study.}
\item{filters}{An optional list of specifications for filters. Each filter is a nested, named list (containing the filter value column: "value_col" and associated label: "label") within the larger list. Default: \code{NULL}.}
\item{group_cols}{An optional list of specifications for grouping columns. Each group column is a nested, named list (containing the group variable column: "value_col" and associated label: "label") within the larger list. Default: \code{NULL}.}
-\item{analysisFlag}{An optional list defining which column \code{value_col} and values \code{values} should be used to records for use in eDish and mDish analyses. Default: \code{NULL}.}
+\item{analysisFlag}{An optional list defining which column (\code{value_col}) and \code{values} should be used in eDish and mDish analyses. Default: \code{NULL}.}
\item{measure_values}{A list defining the data values from \code{measure_col} for the lab measures
-used in eDish evaluations. Default: \code{list(ALT = 'Aminotransferase, alanine (ALT)',
-AST = 'Aminotransferase, aspartate (AST)', TB = 'Total Bilirubin', ALP = 'Alkaline phosphatase (ALP)')}.}
+used in eDish evaluations. Default: \preformatted{list(ALT = 'Aminotransferase, alanine (ALT)',
+ AST = 'Aminotransferase, aspartate (AST)',
+ TB = 'Total Bilirubin',
+ ALP = 'Alkaline phosphatase (ALP)')}}
\item{x_options}{Specifies variable options for the x-axis using the key values from \code{measure_values} (e.g. "ALT").
When multiple options are specified, a control allowing the user to interactively change the x variable is shown. Default: \code{c("ALT", "AST", "ALP")}.}
\item{y_options}{Specifies variable options for the y-axis using the key values from \code{measure_values} (e.g. "TB").
-When multiple options are specified, a control allowing the user to interactively change the y variable is shown. Default: \code{c("TB", "ALP")}.}
+When multiple options are specified, a control allowing the user to interactively change the y variable is shown. Default: \code{"TB"}.}
\item{visit_window}{Default visit window used to highlight eDish points where x and y measures occurred within the specified number of days.
Editable by user after render. Default: \code{30}.}
@@ -72,7 +74,10 @@ default warning text will be displayed ("Caution: This interactive graphic is no
recommendations based on this tool should be confirmed using your organizations
standard operating procedures.").}
-\item{settings}{Optional list of settings arguments to be converted to JSON using \code{jsonlite::toJSON(settings, auto_unbox = TRUE, dataframe = "rows", null = "null")}. If provided, all other function parameters are ignored. Default: \code{NULL}.}
+\item{settings}{Optional list of settings arguments to be converted to JSON using: \preformatted{
+jsonlite::toJSON(settings, auto_unbox = TRUE,
+ dataframe = "rows", null = "null")}
+If provided, all other function parameters are ignored. Default: \code{NULL}.}
}
\description{
This function creates an interactive graphic for the Evaluation of Drug-Induced Serious Hepatotoxicity (eDISH)
diff --git a/man/evaluateStandard.Rd b/man/evaluateStandard.Rd
new file mode 100644
index 00000000..ac1a38ab
--- /dev/null
+++ b/man/evaluateStandard.Rd
@@ -0,0 +1,29 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/evaluateStandard.R
+\name{evaluateStandard}
+\alias{evaluateStandard}
+\title{Evaluate a data set against a data standard}
+\usage{
+evaluateStandard(data, standard, includeFields = TRUE, domain = "labs")
+}
+\arguments{
+\item{data}{data.frame to evaluate}
+
+\item{standard}{standard to evaluate}
+
+\item{includeFields}{should field level data be evaluated?}
+
+\item{domain}{data domain. "labs" only for now.}
+}
+\value{
+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. "valid_checks" and "invalid_checks" provide counts of the specified checks.
+}
+\description{
+Determines whether the required data elements in a data standard are found in a given data frame
+}
+\examples{
+safetyGraphics:::evaluateStandard(data=adlbc, standard="adam") # Match is TRUE
+safetyGraphics:::evaluateStandard(data=adlbc, standard="sdtm") # Match is FALSE
+
+}
+\keyword{internal}
diff --git a/man/generateSettings.Rd b/man/generateSettings.Rd
index 4b5b46d9..f4bb5e9c 100644
--- a/man/generateSettings.Rd
+++ b/man/generateSettings.Rd
@@ -5,16 +5,16 @@
\title{Generate a settings object based on a data standard}
\usage{
generateSettings(standard = "None", chart = "eDish", partial = FALSE,
- partial_cols = NULL)
+ partial_keys = NULL)
}
\arguments{
\item{standard}{The data standard for which to create settings. Valid options are "SDTM", "AdAM" or "None". Default: \code{"SDTM"}}
\item{chart}{The chart for which standards should be generated ("eDish" only for now) . Default: \code{"eDish"}.}
-\item{partial}{Boolean for whether or not the standard is a partial standard. Default: \code{"NULL"}.}
+\item{partial}{Boolean for whether or not the standard is a partial standard. Default: \code{FALSE}.}
-\item{partial_cols}{Optional character vector of the matched cols if partial is TRUE. It will not be used if partial is FALSE Default: \code{"NULL"}.}
+\item{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}.}
}
\value{
A list containing the appropriate settings for the selected chart
@@ -29,8 +29,9 @@ The function is designed to work with the SDTM and AdAM CDISC(%filter(text_key=="measure_col")%>%select(valid)%>%unlist)
+})
+
+
+test_that("field level data is ignored when useFields=false",{
+ noFields<-evaluateStandard(data=adlbc, standard="adam", includeFields=FALSE)
+ expect_equal(noFields[["match"]],"Full")
+ expect_equal(noFields[["valid_count"]],6)
+})
+
+test_that("invalid options throw errors",{
+ expect_error(evaluateStandard(data=list(a=1,b=2), standard="sdtm"))
+ expect_error(evaluateStandard(data="notadataframe", standard="sdtm"))
+ expect_error(evaluateStandard(data=adlbc, standard=123))
+ expect_error(evaluateStandard(data=adlbc, standard="notarealstandard"))
+ expect_error(evaluateStandard(data=adlbc, standard="adam", includeFields="yesPlease"))
+})
\ No newline at end of file
diff --git a/tests/testthat/test_generateSettings.R b/tests/testthat/test_generateSettings.R
index 5ebf128d..78dbc96b 100644
--- a/tests/testthat/test_generateSettings.R
+++ b/tests/testthat/test_generateSettings.R
@@ -26,51 +26,64 @@ test_that("a warning is thrown if chart isn't eDish",{
})
test_that("data mappings are null when setting=none, character otherwise",{
- column_setting_names<-c("id_col", "value_col", "measure_col", "normal_col_low", "normal_col_high", "studyday_col", "visit_col", "visitn_col")
+ data_setting_keys<-c("id_col", "value_col", "measure_col", "normal_col_low", "normal_col_high", "studyday_col","measure_values--ALT","measure_values--ALP","measure_values--TB","measure_values--AST")
none_settings <- generateSettings(standard="None")
- for(name in column_setting_names){
- expect_null(none_settings[[name]])
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ expect_null(getSettingValue(settings=none_settings,key=key))
+ }
+
+ other_settings <- generateSettings(standard="a different standard")
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ expect_null(getSettingValue(settings=other_settings,key=key))
}
sdtm_settings <- generateSettings(standard="SDTM")
- for(name in column_setting_names){
- expect_is(sdtm_settings[[name]],"character")
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ expect_is(getSettingValue(settings=sdtm_settings,key=key),"character")
}
+
sdtm_settings2 <- generateSettings(standard="SdTm")
- for(name in column_setting_names){
- expect_is(sdtm_settings2[[name]],"character")
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ expect_is(getSettingValue(settings=sdtm_settings2,key=key),"character")
}
+
adam_settings <- generateSettings(standard="ADaM")
- for(name in column_setting_names){
- expect_is(adam_settings[[name]],"character")
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ expect_is(getSettingValue(settings=adam_settings,key=key),"character")
}
adam_settings2 <- generateSettings(standard="ADAM")
- for(name in column_setting_names){
- expect_is(adam_settings2[[name]],"character")
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ expect_is(getSettingValue(settings=adam_settings2,key=key),"character")
}
+
# Test Partial Spec Match
- partial_adam_settings <- generateSettings(standard="SDTM", partial=TRUE, partial_cols = c("USUBJID","TEST"))
- for(name in column_setting_names){
-
- if (name %in% c("id_col","measure_col")) {
- expect_is(partial_adam_settings[[name]],"character")
+ partial_adam_settings <- generateSettings(standard="adam", partial=TRUE, partial_keys = c("id_col","measure_col","measure_values--ALT"))
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ if (text_key %in% c("id_col","measure_col","measure_values--ALT")) {
+ expect_is(getSettingValue(settings=partial_adam_settings,key=key),"character")
} else {
- expect_null(partial_adam_settings[[name]])
+ expect_null(getSettingValue(settings=partial_adam_settings,key=key))
}
}
#Testing that partial cols are only used when partial=TRUE
- full_adam_partial_cols <- generateSettings(standard="ADaM", partial_cols = c("USUBJID","TEST"))
- for(name in column_setting_names){
- expect_is(full_adam_partial_cols[[name]],"character")
+ full_adam_partial_cols <- generateSettings(standard="ADaM", partial_keys = c("id_col","measure_col","measure_values--ALT"))
+ for(text_key in data_setting_keys){
+ key<-textKeysToList(text_key)[[1]]
+ expect_is(getSettingValue(settings=full_adam_partial_cols,key=key),"character")
}
#Testing failure when partial is true with no specified columns
expect_error(partial_settings_no_cols <- generateSettings(standard="ADaM", partial=TRUE))
-
-
})
diff --git a/tests/testthat/test_getRequiredSettings.R b/tests/testthat/test_getRequiredSettings.R
index 1bca5f5a..b5d8ef11 100644
--- a/tests/testthat/test_getRequiredSettings.R
+++ b/tests/testthat/test_getRequiredSettings.R
@@ -2,19 +2,23 @@ context("Tests for the getRequiredSettings() function")
library(safetyGraphics)
library(testthat)
-defaultRequiredCols <- list(
+defaultRequiredSettings <- list(
list("id_col"),
list("value_col"),
list("measure_col"),
list("normal_col_low"),
list("normal_col_high"),
- list("studyday_col")
+ list("studyday_col"),
+ list("measure_values","ALT"),
+ list("measure_values","AST"),
+ list("measure_values","TB"),
+ list("measure_values","ALP")
)
customMetadata<- data.frame(
- chart_linechart = c(TRUE, FALSE),
- chart_barchart = c(FALSE,TRUE),
+ chart_linechart = c(TRUE, FALSE),
+ chart_barchart = c(FALSE,TRUE),
text_key = c("line_col","value_col--label"),
label=c("label1","label2"),
description=c("desc1","desc2"),
@@ -22,7 +26,6 @@ customMetadata<- data.frame(
setting_required=TRUE,
column_mapping=TRUE,
column_type="character",
- column_required=TRUE,
field_mapping=FALSE
)
@@ -30,7 +33,7 @@ customMetadata<- data.frame(
test_that("default function call works as expected",{
a<- safetyGraphics::getRequiredSettings()
expect_is(a,"list")
- expect_equal(a,defaultRequiredCols)
+ expect_equal(a,defaultRequiredSettings)
})
test_that("options work as expected",{
@@ -47,4 +50,4 @@ test_that("nested keys are supported",{
test_that("invalid options return null",{
expect_null(safetyGraphics::getRequiredSettings(chart="notachart"))
-})
\ No newline at end of file
+})
diff --git a/tests/testthat/test_getSettingsMetadata.R b/tests/testthat/test_getSettingsMetadata.R
index 4cad3e7a..5da5c819 100644
--- a/tests/testthat/test_getSettingsMetadata.R
+++ b/tests/testthat/test_getSettingsMetadata.R
@@ -7,20 +7,19 @@ library(magrittr)
rawMetadata <- safetyGraphics::settingsMetadata
customMetadata<- data.frame(
- chart_linechart = c(TRUE, FALSE),
- chart_barchart = c(FALSE,TRUE),
+ chart_linechart = c(TRUE, FALSE),
+ chart_barchart = c(FALSE,TRUE),
text_key = c("line_col","value_col"),
label=c("label1","label2"),
description=c("desc1","desc2"),
setting_type="character",
column_mapping=TRUE,
column_type="character",
- column_required=TRUE,
field_mapping=FALSE
)
mergedMetadata = suppressWarnings(bind_rows(
- rawMetadata%>%mutate(chart_linechart= FALSE)%>%mutate(chart_barchart= FALSE),
+ rawMetadata%>%mutate(chart_linechart= FALSE)%>%mutate(chart_barchart= FALSE),
customMetadata%>%mutate(chart_edish= FALSE)
))
@@ -34,44 +33,44 @@ test_that("Pulling from a custom metadata file works as expected",{
custom<-safetyGraphics:::getSettingsMetadata(metadata=customMetadata)
expect_is(custom,"data.frame")
expect_equal(dim(custom), dim(customMetadata))
-
+
merged<-safetyGraphics:::getSettingsMetadata(metadata=customMetadata)
expect_is(custom,"data.frame")
expect_equal(dim(custom), dim(customMetadata))
})
test_that("charts parameter works as expected",{
-
+
#return a dataframe for valid input
expect_is(safetyGraphics:::getSettingsMetadata(charts=c("edish")),"data.frame")
expect_is(safetyGraphics:::getSettingsMetadata(charts="edish"),"data.frame")
-
+
#error if charts isn't a character
expect_error(safetyGraphics:::getSettingsMetadata(charts=123))
expect_error(safetyGraphics:::getSettingsMetadata(charts=list("edish")))
-
+
#return null if no valid charts are passed
expect_true(is.null(safetyGraphics:::getSettingsMetadata(charts=c(""))))
expect_true(is.null(safetyGraphics:::getSettingsMetadata(charts="abc")))
expect_true(is.null(safetyGraphics:::getSettingsMetadata(charts=c("notachart"))))
expect_true(is.null(safetyGraphics:::getSettingsMetadata(charts=c("notachart","stillnotachart"))))
-
+
#no partial matches supported
- expect_true(is.null(safetyGraphics:::getSettingsMetadata(charts=c("edi"))))
-
+ expect_true(is.null(safetyGraphics:::getSettingsMetadata(charts=c("edi"))))
+
#return a dataframe if at least one valid chart type is passed
expect_is(safetyGraphics:::getSettingsMetadata(charts=c("notachart","edish")),"data.frame")
-
+
#capitalization doesn't matter
expect_is(safetyGraphics:::getSettingsMetadata(charts=c("EdIsH")),"data.frame")
-
+
#get the right number of records with various combinations
lineonly <- safetyGraphics:::getSettingsMetadata(charts=c("linechart"),metadata=mergedMetadata)
expect_equal(dim(lineonly)[1],1)
-
+
linesandbars <- safetyGraphics:::getSettingsMetadata(charts=c("linechart","barchart"),metadata=mergedMetadata)
expect_equal(dim(linesandbars)[1],2)
-
+
allcharts <- safetyGraphics:::getSettingsMetadata(charts=c("linechart","barchart","edish"),metadata=mergedMetadata)
expect_equal(dim(allcharts)[1],dim(mergedMetadata)[1])
})
@@ -79,26 +78,26 @@ test_that("charts parameter works as expected",{
test_that("text_keys parameter works as expected",{
#return a dataframe for valid input
expect_is(safetyGraphics:::getSettingsMetadata(text_keys=c("id_col")),"data.frame")
-
+
#error if text_keys isn't a character
expect_error(safetyGraphics:::getSettingsMetadata(text_keys=123))
expect_error(safetyGraphics:::getSettingsMetadata(text_keys=list("id_col")))
-
+
#return null if no valid text_keys are passed
expect_true(is.null(safetyGraphics:::getSettingsMetadata(text_keys=c(""))))
expect_true(is.null(safetyGraphics:::getSettingsMetadata(text_keys="abc")))
expect_true(is.null(safetyGraphics:::getSettingsMetadata(text_keys=c("notakey"))))
expect_true(is.null(safetyGraphics:::getSettingsMetadata(text_keys=c("notakey","stillnotakey"))))
-
+
#no partial matches supported
- expect_true(is.null(safetyGraphics:::getSettingsMetadata(text_keys=c("id_"))))
-
+ expect_true(is.null(safetyGraphics:::getSettingsMetadata(text_keys=c("id_"))))
+
#return a dataframe if at least one valid chart type is passed
expect_is(safetyGraphics:::getSettingsMetadata(text_keys=c("notachart","id_col")),"data.frame")
-
+
#capitalization doesn't matter
expect_is(safetyGraphics:::getSettingsMetadata(text_keys=c("Id_COl")),"data.frame")
-
+
#get the right number of records with various combinations
expect_equal(dim(safetyGraphics:::getSettingsMetadata(text_keys=c("id_col"),metadata=mergedMetadata))[1],1)
expect_equal(dim(safetyGraphics:::getSettingsMetadata(text_keys=c("value_col"),metadata=mergedMetadata))[1],2)
@@ -107,15 +106,15 @@ test_that("text_keys parameter works as expected",{
})
test_that("cols parameter works as expected",{
-
+
#returns a data frame if multiple columns are requested
expect_is(safetyGraphics:::getSettingsMetadata(cols=c("label","text_key")),"data.frame")
-
+
#returns a vector if a single column is specified
one_col <- safetyGraphics:::getSettingsMetadata(cols=c("label"))
expect_is(one_col,"character")
expect_equal(length(one_col),dim(rawMetadata)[1])
-
+
#returns an atomic value if a single value is specified
one_val <- safetyGraphics:::getSettingsMetadata(cols=c("label"), text_keys="line_col", metadata= mergedMetadata)
expect_is(one_val,"character")
@@ -123,17 +122,17 @@ test_that("cols parameter works as expected",{
expect_equal(one_val,"label1")
expect_true(safetyGraphics:::getSettingsMetadata(cols=c("column_mapping"), text_keys="line_col", metadata= mergedMetadata))
expect_false(safetyGraphics:::getSettingsMetadata(cols=c("field_mapping"), text_keys="line_col", metadata= mergedMetadata))
-
+
#returns null if no valid columns are requested
expect_true(is.null(safetyGraphics:::getSettingsMetadata(cols=c("asda123"))))
})
test_that("filter_expr parameters works as expected",{
expect_equal(
- safetyGraphics:::getSettingsMetadata(filter_expr=text_key=="id_col"),
+ safetyGraphics:::getSettingsMetadata(filter_expr=text_key=="id_col"),
safetyGraphics:::getSettingsMetadata(text_key="id_col")
)
expect_equal(safetyGraphics:::getSettingsMetadata(filter_expr=text_key=="id_col",cols="description"),"Unique subject identifier variable name.")
expect_length(safetyGraphics:::getSettingsMetadata(filter_expr=column_type=="numeric",cols="text_key",chart="edish"),5)
- expect_length(safetyGraphics:::getSettingsMetadata(filter_expr=setting_required,cols="text_key",chart="edish"),6)
- })
\ No newline at end of file
+ expect_length(safetyGraphics:::getSettingsMetadata(filter_expr=setting_required,cols="text_key",chart="edish"),10)
+ })
diff --git a/tests/testthat/test_hasColumn.R b/tests/testthat/test_hasColumn.R
new file mode 100644
index 00000000..5145492b
--- /dev/null
+++ b/tests/testthat/test_hasColumn.R
@@ -0,0 +1,21 @@
+context("Tests for the hasColumn() function")
+library(safetyGraphics)
+
+test_that("columns are found when expected",{
+ # simple test case works
+ expect_true(hasColumn(columnName="PARAM",data=adlbc))
+ expect_true(hasColumn(columnName="SUBJID",data=adlbc))
+
+ #doesn't care about case
+ expect_true(hasColumn(columnName="param",data=adlbc))
+ expect_true(hasColumn(columnName="SuBjId",data=adlbc))
+
+ # returns false when fieldValue isn't there or there is a type mismatch
+ expect_false(hasColumn(columnName="PARAMETER",data=adlbc))
+ expect_false(hasColumn(columnName="SUBJID2",data=adlbc))
+
+ # fails with invalid parameters
+ expect_error(hasColumn(columnName=123,data=adlbc))
+ expect_error(hasColumn(columnName=c("PARAM","SUBJID"),data=adlbc))
+ expect_error(hasColumn(columnName="PARAM",data=list(adlbc)))
+})
diff --git a/tests/testthat/test_hasField.R b/tests/testthat/test_hasField.R
new file mode 100644
index 00000000..a1e9197e
--- /dev/null
+++ b/tests/testthat/test_hasField.R
@@ -0,0 +1,26 @@
+context("Tests for the cField() function")
+library(safetyGraphics)
+
+test_that("fields are found when expected",{
+ # simple test case works
+ expect_true(hasField(fieldValue="Bilirubin (umol/L)",columnName="PARAM",data=adlbc))
+
+ # flexible regarding type
+ expect_true(hasField(fieldValue=1015,columnName="SUBJID",data=adlbc))
+ expect_true(hasField(fieldValue="1015",columnName="SUBJID",data=adlbc))
+ expect_true(hasField(fieldValue=list(1015),columnName="SUBJID",data=adlbc))
+ expect_true(hasField(fieldValue=list(1015),columnName="SUBJID",data=adlbc))
+
+ #but not regarding length
+ expect_error(hasField(fieldValue=list(1015,1023),columnName="SUBJID",data=adlbc))
+ expect_error(hasField(fieldValue=c("a","b"),columnName="PARAM",data=adlbc))
+
+
+ # returns false when fieldValue isn't there or there is a type mismatch
+ expect_false(hasField(fieldValue="Not_a_real_value",columnName="PARAM",data=adlbc))
+ expect_false(hasField(fieldValue=12,columnName="PARAM",data=adlbc))
+
+ # fails with invalid parameters
+ expect_error(hasField(fieldValue="Bilirubin (umol/L)",columnName=c("PARAM","ID"),data=adlbc))
+ expect_error(hasField(columnName="PARAM",data=list(adlbc))) #fieldValue missing
+})
diff --git a/tests/testthat/test_setSettingsValue.R b/tests/testthat/test_setSettingsValue.R
new file mode 100644
index 00000000..756a7ae4
--- /dev/null
+++ b/tests/testthat/test_setSettingsValue.R
@@ -0,0 +1,70 @@
+context("Tests for the setSettingValue() function")
+library(safetyGraphics)
+
+testSettings1<-list(a=list(x="sue",y="sam"), b="hi mom", c=123, unnamed=list("Apples","Oranges"))
+
+test_that("function throws an error if the settings object isn't a list",{
+ expect_error(setSettingsValue(key="testKey",value="abc", settings=c("NotAList")))
+ expect_silent(setSettingsValue(key="testKey", value="DEF", settings=list(testkey="ABC")))
+})
+
+test_that("can set values to/from various types",{
+ expect_equal(setSettingsValue("a", 456, testSettings1)[["a"]], 456)
+ expect_equal(setSettingsValue(list("a"), 456,testSettings1)[["a"]], 456)
+ expect_equal(setSettingsValue(list("a"), "sometext",testSettings1)[["a"]], "sometext")
+ expect_equal(setSettingsValue(list("a"), FALSE,testSettings1)[["a"]], FALSE)
+ expect_equal(setSettingsValue(list("b"), "hi dad",testSettings1)[["b"]], "hi dad")
+ expect_equal(setSettingsValue(list("b"), 123,testSettings1)[["b"]], 123)
+ expect_equal(setSettingsValue(list("b"), list(e=1,f=FALSE),testSettings1)[["b"]], list(e=1,f=FALSE))
+ expect_equal(setSettingsValue(list("c"), FALSE,testSettings1)[["c"]], FALSE)
+})
+
+test_that("can set value that didn't previously exist",{
+ expect_equal(setSettingsValue("d", "I'm new here.", testSettings1)[["d"]], "I'm new here.")
+ expect_equal(setSettingsValue(list("d"), "I'm new here.", testSettings1)[["d"]], "I'm new here.")
+})
+
+test_that("can set nested values",{
+ expect_equal(setSettingsValue(list("a","x"), 456, testSettings1)[["a"]][["x"]], 456)
+})
+
+test_that("can set nested values that didn't previously exist",{
+ expect_equal(setSettingsValue(list("a","z"), 456, testSettings1)[["a"]][["z"]], 456)
+})
+
+test_that("but can't set nested values when a parent is missing or isn't a list",{
+ expect_error(setSettingsValue(list("d","test"), 456, testSettings1)[["d"]][["test"]]) # d doesn't exist, so this doesn't work. user could set d to list() and then set test to 456 ...
+ expect_error(setSettingsValue(list("b","z"), 456, testSettings1)) # can't replace a scalar (b="hi mom") with a list (b=list(z=456))
+})
+
+test_that("can set nested values in an unnamed list",{
+ expect_equal(setSettingsValue(list("unnamed",1), 456, testSettings1)[["unnamed"]][[1]], 456) # [[1]] is overwritten
+ expect_equal(setSettingsValue(list("unnamed",1), 456, testSettings1)[["unnamed"]][[2]], "Oranges") #original value in [[2]] is unchanged
+})
+
+test_that("can set nested values in an unnamed list that didn't previously exist",{
+ expect_true(setSettingsValue(list("unnamed",3), TRUE, testSettings1)[["unnamed"]][[3]]) #[[3]] added
+
+ expect_true(setSettingsValue(list("unnamed",5), TRUE, testSettings1)[["unnamed"]][[5]]) #this works, [[4]] and [[5]] are Null
+ expect_null(setSettingsValue(list("unnamed",5), TRUE, testSettings1)[["unnamed"]][[4]]) #this works, [[4]] and [[5]] are Null
+ expect_null(setSettingsValue(list("unnamed",5), TRUE, testSettings1)[["unnamed"]][[4]]) #this works, [[4]] and [[5]] are Null
+})
+
+
+test_that("sanity checks using a real setting object",{
+ testSDTM <- generateSettings(standard="SDTM")
+ testSDTM <-setSettingsValue(list("id_col"), "customID", testSDTM)
+ testSDTM <-setSettingsValue(list("measure_values","ALP"), "Alpine", testSDTM)
+ testSDTM <-setSettingsValue(list("filters"), list(), testSDTM)
+ testSDTM <-setSettingsValue(list("filters",1), "RACE", testSDTM)
+ testSDTM <-setSettingsValue(list("customSetting"), "customized!", testSDTM)
+
+
+ expect_equal(testSDTM[["id_col"]],"customID")
+ expect_equal(testSDTM[["measure_values"]][["ALP"]],"Alpine")
+ expect_equal(testSDTM[["filters"]][[1]],"RACE")
+ expect_equal(testSDTM[["customSetting"]],"customized!")
+})
+
+
+
\ No newline at end of file
diff --git a/tests/testthat/test_trimData.R b/tests/testthat/test_trimData.R
new file mode 100644
index 00000000..9acef804
--- /dev/null
+++ b/tests/testthat/test_trimData.R
@@ -0,0 +1,33 @@
+context("Tests for the trimData() function")
+library(safetyGraphics)
+
+settings <-generateSettings(standard="AdAM")
+
+baseline_settings <- settings
+baseline_settings[['baseline']][['value_col']] <- 'ADY'
+baseline_settings[['baseline']][['values']] <- list("-7","15")
+
+analysisFlag_settings <- settings
+analysisFlag_settings[['analysisFlag']][['value_col']] <- 'TRTA'
+analysisFlag_settings[['analysisFlag']][['values']] <- list("Placebo","Xanomeline High Dose")
+
+both_settings <- baseline_settings
+both_settings[['analysisFlag']][['value_col']] <- 'TRTA'
+both_settings[['analysisFlag']][['values']] <- list("Placebo","Xanomeline High Dose")
+
+test_that("columns are removed",{
+ # simple test case works
+ expect_length(trimData(adlbc, settings), 6)
+ expect_length(trimData(adlbc, baseline_settings), 6)
+ expect_length(trimData(adlbc, analysisFlag_settings), 7)
+ expect_length(trimData(adlbc, both_settings), 7)
+})
+
+test_that("rows are removed",{
+ # simple test case works
+ expect_equal(nrow(trimData(adlbc, settings)), 10288) # none removed
+ expect_equal(nrow(trimData(adlbc, baseline_settings)), 714)
+ expect_equal(nrow(trimData(adlbc, analysisFlag_settings)), 7148)
+ expect_equal(nrow(trimData(adlbc, both_settings)), 7378)
+})
+
diff --git a/tests/testthat/test_validateSettings.R b/tests/testthat/test_validateSettings.R
index 619ebdfd..4f795d1f 100644
--- a/tests/testthat/test_validateSettings.R
+++ b/tests/testthat/test_validateSettings.R
@@ -2,6 +2,7 @@ context("Tests for the validateSetting() function")
library(safetyGraphics)
library(purrr)
library(dplyr)
+library(tibble)
validSettings<-generateSettings(standard="adam")
passed<-validateSettings(data=adlbc,settings=validSettings)
@@ -16,14 +17,12 @@ test_that("our basic example is valid (until we break it)",{
})
test_that("function returns a list with the expected structure",{
- expect_named(passed,c("checkList","valid","status"))
- expect_named(failed,c("checkList","valid","status"))
- expect_type(passed$checkList,"list")
+ expect_named(passed,c("checks","valid","status"))
+ expect_named(failed,c("checks","valid","status"))
+ expect_true(is_tibble(passed$checks))
expect_type(passed$valid,"logical")
expect_type(passed$status,"character")
- for(item in passed[["checkList"]]){
- expect_named(item,c("key","text_key","check","value","valid","message"))
- }
+ expect_equal(colnames(passed$checks),c("key","text_key","type","description","value","valid","message"))
})
test_that("our examples have the correct number of failed checks",{
@@ -31,12 +30,12 @@ test_that("our examples have the correct number of failed checks",{
invalidSettings2$measure_col<-"not_a_measure_id"
failed2<-validateSettings(data=adlbc,settings=invalidSettings2)
- expect_equal(passed$checkList%>%map_dbl(~!.x[["valid"]])%>%sum,0)
- expect_equal(failed$checkList%>%map_dbl(~!.x[["valid"]])%>%sum,1)
- expect_equal(failed2$checkList%>%map_dbl(~!.x[["valid"]])%>%sum,6) #2 columns and 4 fields
+ expect_equal(passed$checks%>%filter(!valid)%>%nrow,0)
+ expect_equal(failed$checks%>%filter(!valid)%>%nrow,1)
+ expect_equal(failed2$checks%>%filter(!valid)%>%nrow,6) #2 columns and 4 fields
- expect_true(all(passed$checkList%>%keep(~.x[["text_key"]]=="id_col")%>%map_lgl(~.x[["valid"]])))
- expect_false(all(failed$checkList%>%keep(~.x[["text_key"]]=="id_col")%>%map_lgl(~.x[["valid"]])))
+ expect_true(passed$checks%>%filter(text_key=="id_col")%>%select(valid)%>%unlist%>%all)
+ expect_false(failed$checks%>%filter(text_key=="id_col")%>%select(valid)%>%unlist%>%all)
})
test_that("field checks fail when expected",{
@@ -45,16 +44,18 @@ test_that("field checks fail when expected",{
fieldFailed<-validateSettings(data=adlbc,settings=invalidFieldSettings)
expect_false(fieldFailed[["valid"]])
- failedChecks = fieldFailed[["checkList"]]%>%keep(~!.x[["valid"]])
- expect_length(failedChecks, 1)
- expect_equal(failedChecks[[1]][['check']],"'_values' field from setting found in data?")
- expect_equal(failedChecks[[1]][['text_key']],"measure_values--ALP")
-
- invalidFieldSettings$visit_values <- list(test="not a visit",test2="still not a visit")
- fieldFailed2<-validateSettings(data=adlbc,settings=invalidFieldSettings)
- failedChecks2 = fieldFailed2[["checkList"]]%>%keep(~!.x[["valid"]])
- expect_false(fieldFailed[["valid"]])
- expect_length(failedChecks2, 3)
+ failedChecks <- fieldFailed$checks%>%filter(!valid)
+ expect_equal(nrow(failedChecks), 1)
+ expect_equal(failedChecks[1,"description"]%>%as.character,"field value from setting found in data")
+ expect_equal(failedChecks[1,'text_key']%>%as.character,"measure_values--ALP")
+
+ # TODO: support vectorized fields/columns #170
+ # a vector of values are each checked independently.
+ # invalidFieldSettings$baseline[["values"]] <- c("not a filter",test2="still not a filter")
+ # fieldFailed2<-validateSettings(data=adlbc,settings=invalidFieldSettings)
+ # failedChecks2 = fieldFailed2[["checkList"]]%>%keep(~!.x[["valid"]])
+ # expect_false(fieldFailed[["valid"]])
+ # expect_length(failedChecks2, 3)
})
test_that("required setting checks fail when expected",{
@@ -63,10 +64,10 @@ test_that("required setting checks fail when expected",{
requiredFailed<-validateSettings(data=adlbc,settings=invalidRequiredSettings)
expect_false(requiredFailed[["valid"]])
- failedChecks <- requiredFailed[["checkList"]]%>%keep(~!.x[["valid"]])
- expect_length(failedChecks, 1)
- expect_equal(failedChecks[[1]][['check']],"value for specified key found in settings?")
- expect_equal(failedChecks[[1]][['text_key']],"id_col")
+ failedChecks <- requiredFailed$checks%>%filter(!valid)
+ expect_equal(nrow(failedChecks), 1)
+ expect_equal(failedChecks[1,'description']%>%as.character,"value for specified key found in settings?")
+ expect_equal(failedChecks[1,'text_key']%>%as.character,"id_col")
})
test_that("numeric column checks fail when no numeric values are found",{
@@ -75,10 +76,10 @@ test_that("numeric column checks fail when no numeric values are found",{
numericFailed<-validateSettings(data=adlbc,settings=invalidNumericSettings)
expect_false(numericFailed[["valid"]])
- failedChecks <- numericFailed[["checkList"]]%>%keep(~!.x[["valid"]])
- expect_length(failedChecks, 1)
- expect_equal(failedChecks[[1]][['check']],"specified column is numeric?")
- expect_equal(failedChecks[[1]][['text_key']],"value_col")
+ failedChecks <- numericFailed$checks%>%filter(!valid)
+ expect_equal(nrow(failedChecks), 1)
+ expect_equal(failedChecks[1,'description']%>%as.character,"specified column is numeric?")
+ expect_equal(failedChecks[1,'text_key']%>%as.character,"value_col")
})
test_that("numeric column checks still fails when more than half of the values are not numeric ",{
@@ -86,10 +87,10 @@ test_that("numeric column checks still fails when more than half of the values a
validNumericSettings[["value_col"]]<-"someNumbers"
adlbc_edit<-adlbc
adlbc_edit$someNumbers <- c("10","11",rep("sometext", dim(adlbc_edit)[1]-2))
- numericPassed<-validateSettings(data=adlbc_edit,settings=validNumericSettings)
- expect_false(numericPassed[["valid"]])
- partialNumericCheck <- numericPassed[["checkList"]]%>%keep(~.x$check=="specified column is numeric?" & .x$text_key=="value_col")
- expect_equal(partialNumericCheck[[1]][["message"]],"10286 of 10288 values were not numeric. Records with non-numeric values may not appear in the graphic.")
+ numericFailedAgain<-validateSettings(data=adlbc_edit,settings=validNumericSettings)
+ expect_false(numericFailedAgain[["valid"]])
+ partialNumericCheck <- numericFailedAgain$checks %>% filter(description=="specified column is numeric?" & text_key=="value_col")
+ expect_equal(partialNumericCheck[1,"message"]%>%as.character,"10286 of 10288 values were not numeric. Records with non-numeric values may not appear in the graphic.")
})
@@ -100,7 +101,7 @@ test_that("numeric column checks pass when more than half of the values are nume
adlbc_edit$someStrings <- c("b","a",rep("10", dim(adlbc_edit)[1]-2))
numericPassed<-validateSettings(data=adlbc_edit,settings=validNumericSettings)
expect_true(numericPassed[["valid"]])
- partialNumericCheck <- numericPassed[["checkList"]]%>%keep(~.x$check=="specified column is numeric?" & .x$text_key=="value_col")
- expect_equal(partialNumericCheck[[1]][["message"]],"2 of 10288 values were not numeric. Records with non-numeric values may not appear in the graphic.")
+ partialNumericCheck <- numericPassed$checks%>%filter(description=="specified column is numeric?" & text_key=="value_col")
+ expect_equal(partialNumericCheck[1,"message"]%>%as.character,"2 of 10288 values were not numeric. Records with non-numeric values may not appear in the graphic.")
})