From b8d43b0f078a0732d721f5276d25c6d0bcfb4f04 Mon Sep 17 00:00:00 2001 From: jwildfire Date: Tue, 12 Feb 2019 17:36:48 -0800 Subject: [PATCH] remove settingsMetadata. fix #154 --- R/settingsMetadata.R | 1 - data-raw/settingsMetadata.csv | 52 ++++++++++---------- data/settingsMetadata.rda | Bin 1968 -> 1952 bytes man/settingsMetadata.Rd | 1 - tests/testthat/test_getRequiredSettings.R | 7 ++- tests/testthat/test_getSettingsMetadata.R | 55 +++++++++++----------- 6 files changed, 56 insertions(+), 60 deletions(-) diff --git a/R/settingsMetadata.R b/R/settingsMetadata.R index 227a6aac..d74a076a 100644 --- a/R/settingsMetadata.R +++ b/R/settingsMetadata.R @@ -12,7 +12,6 @@ #' \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} diff --git a/data-raw/settingsMetadata.csv b/data-raw/settingsMetadata.csv index 08f04869..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,field_column_key,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,TRUE,FALSE,NA,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,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,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,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,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,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,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,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,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,,, \ No newline at end of file +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/settingsMetadata.rda b/data/settingsMetadata.rda index 559f71355a7afd1b910f6ee3550f40862323b09f..c70c9c65635c9e1653236e721fe5a9073d45f8ee 100644 GIT binary patch delta 1913 zcmV-<2Z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b/man/settingsMetadata.Rd @@ -14,7 +14,6 @@ \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} diff --git a/tests/testthat/test_getRequiredSettings.R b/tests/testthat/test_getRequiredSettings.R index 6e4604e8..b5d8ef11 100644 --- a/tests/testthat/test_getRequiredSettings.R +++ b/tests/testthat/test_getRequiredSettings.R @@ -17,8 +17,8 @@ defaultRequiredSettings <- list( 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"), @@ -26,7 +26,6 @@ customMetadata<- data.frame( setting_required=TRUE, column_mapping=TRUE, column_type="character", - column_required=TRUE, field_mapping=FALSE ) @@ -51,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 1b43492e..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"),10) - }) \ No newline at end of file + })