Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion R/settingsMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
52 changes: 26 additions & 26 deletions data-raw/settingsMetadata.csv
Original file line number Diff line number Diff line change
@@ -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,,,
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,,,
Binary file modified data/settingsMetadata.rda
Binary file not shown.
1 change: 0 additions & 1 deletion inst/eDISH_app/global.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# temporarily load deps
library(safetyGraphics)
library(shiny)
library(shinyjs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions inst/eDISH_app/ui.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
library(shiny)
library(shinyjs)

tagList(
useShinyjs(),
tags$style(HTML("
Expand Down
1 change: 0 additions & 1 deletion man/settingsMetadata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions tests/testthat/test_getRequiredSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ 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"),
setting_type="character",
setting_required=TRUE,
column_mapping=TRUE,
column_type="character",
column_required=TRUE,
field_mapping=FALSE
)

Expand All @@ -51,4 +50,4 @@ test_that("nested keys are supported",{

test_that("invalid options return null",{
expect_null(safetyGraphics::getRequiredSettings(chart="notachart"))
})
})
55 changes: 27 additions & 28 deletions tests/testthat/test_getSettingsMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
))

Expand All @@ -34,71 +33,71 @@ 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])
})

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)
Expand All @@ -107,33 +106,33 @@ 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")
expect_equal(length(one_val),1)
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)
})
})