Skip to content
Merged

v2.1 #668

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9d8c3c9
Update for passing build
elimillera Sep 20, 2021
2dcf258
Remove golem deps
elimillera Sep 30, 2021
e3b0edb
remove whitespace in chart name. fix #636
jwildfire Oct 6, 2021
fdd24e2
fix whitespace regex
jwildfire Oct 6, 2021
efed0dd
fix whitespace regex again
jwildfire Oct 7, 2021
4965122
update run_now to runNow
elimillera Oct 8, 2021
06ec87b
Merge branch 'dev' into eli/connect_deploy
Oct 8, 2021
1cf459e
update version
jwildfire Oct 13, 2021
dc72dbc
Allow non-standard data in autoMapping. fix #642
jwildfire Oct 19, 2021
04a82bc
formatting fix
jwildfire Oct 20, 2021
002724d
Merge pull request #643 from SafetyGraphics/fix-642
Oct 22, 2021
a7468f0
initial commit for makeMeta function
jwildfire Nov 4, 2021
94da5ff
typo clean up
jwildfire Nov 4, 2021
1bf63a7
use system.file() to load css. #651
jwildfire Nov 9, 2021
92f919a
update docs
jwildfire Nov 9, 2021
f730ff3
move app.r to /inst
jwildfire Nov 18, 2021
ca676e7
Merge pull request #626 from SafetyGraphics/eli/connect_deploy
jwildfire Nov 18, 2021
f51e82c
don't source files by default. fix #652
jwildfire Nov 19, 2021
334affb
start refactor for chart level metadata
jwildfire Nov 22, 2021
1e29d32
more makeMeta updates
jwildfire Dec 4, 2021
42e7c4c
shell for unit tests
jwildfire Dec 5, 2021
c992a6c
test for charts with existing metadata
jwildfire Dec 5, 2021
70fd7d0
test for charts with existing metadata
jwildfire Dec 5, 2021
643483c
add tests for domain metadata import
jwildfire Dec 7, 2021
1b057ec
test for chart-level metadata
jwildfire Dec 10, 2021
9a75d3f
Merge pull request #654 from SafetyGraphics/fix-652
jwildfire Jan 4, 2022
d6fc9ac
refactor makeMeta to work across all charts. #637
jwildfire Feb 25, 2022
8dd7adf
add support for chart and more tests for makeMeta. #637
jwildfire Feb 25, 2022
9e5b050
fix test and check issues caused by meta migration
jwildfire Feb 25, 2022
e1c4038
update test apps
jwildfire Feb 28, 2022
29cae98
return placeholder object for evaluation of data when no defaults ar…
jwildfire Feb 28, 2022
eac1cf0
merge dev
jwildfire Feb 28, 2022
7c1e52c
Update R/makeMeta.R
jwildfire Mar 19, 2022
aeff1b7
Update DESCRIPTION
jwildfire Mar 19, 2022
691a3bb
Update tests/testthat/module_examples/chartsTab/app.R
jwildfire Mar 19, 2022
b477a00
update docs
jwildfire Mar 19, 2022
d98b864
update docs
jwildfire Mar 19, 2022
743aa5f
Merge pull request #650 from SafetyGraphics/fix-637
jwildfire Mar 23, 2022
5d4fa75
update rclipboard calls. fix #663
jwildfire Mar 24, 2022
3456587
sync vignettes with wiki. rebuild pkgdown.
jwildfire Mar 24, 2022
5d1ae34
update vignette links
jwildfire Mar 24, 2022
0c9590d
Merge pull request #664 from SafetyGraphics/fix-663
jwildfire Mar 24, 2022
0736adc
re-run with latest version of pkgdown
jwildfire Mar 24, 2022
123d425
Merge pull request #665 from SafetyGraphics/update-vignettes
jwildfire Mar 28, 2022
15b074c
prep for v2.1 release
jwildfire Apr 2, 2022
d6660d3
add util-pipe
jwildfire Apr 2, 2022
a2dc98c
remove link in vignette. rebuild pkgdown
jwildfire Apr 2, 2022
ab14c92
remove docs (full rebuild coming)
jwildfire Apr 8, 2022
1d5008f
rebuild pkgdown
jwildfire Apr 8, 2022
6f8201c
Merge pull request #667 from SafetyGraphics/main
jwildfire Apr 8, 2022
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
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
^CRAN-RELEASE$
^customSettings$
^\.github$
^app\.R$
^rsconnect$
^LICENSE\.md$



5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: safetyGraphics
Title: Interactive Graphics for Monitoring Clinical Trial Safety
Version: 2.0.0
Version: 2.1.0
Authors@R: c(
person("Jeremy", "Wildfire", email = "jwildfire@gmail.com", role = c("cre","aut")),
person("Becca", "Krouse", role="aut"),
Expand Down Expand Up @@ -39,11 +39,12 @@ Imports:
rclipboard (>= 0.1.3),
rlang (>= 0.4.11),
safetyData (>= 1.0.0),
safetyCharts (>= 0.2),
safetyCharts (>= 0.3),
shiny (>= 1.6.0),
shinyjs (>= 2.0.0),
sortable (>= 0.4.4),
stringr (>= 1.4.0),
tidyr (>= 1.2.0),
yaml (>= 2.2.1)
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(app_startup)
export(chartsNav)
export(chartsTab)
Expand All @@ -21,6 +22,7 @@ export(makeChartExport)
export(makeChartParams)
export(makeChartSummary)
export(makeMapping)
export(makeMeta)
export(mappingColumn)
export(mappingColumnUI)
export(mappingDomain)
Expand Down Expand Up @@ -48,10 +50,12 @@ import(datamods)
import(dplyr)
import(purrr)
import(rclipboard)
import(safetyCharts)
import(safetyData)
import(shiny)
import(yaml)
importFrom(DT,renderDT)
importFrom(magrittr,"%>%")
importFrom(purrr,keep)
importFrom(purrr,map)
importFrom(purrr,map2)
Expand All @@ -72,9 +76,12 @@ importFrom(shinyjs,useShinyjs)
importFrom(sortable,add_rank_list)
importFrom(sortable,bucket_list)
importFrom(stringr,str_detect)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_split)
importFrom(stringr,str_to_title)
importFrom(stringr,str_to_upper)
importFrom(tidyr,replace_na)
importFrom(tidyr,starts_with)
importFrom(utils,hasName)
importFrom(utils,zip)
importFrom(yaml,as.yaml)
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# safetyGraphics v2.1.0

This release focuses on updates the safetyGraphics metadata framework:

- The default metadata table has been migrated to safetyCharts and modularized. In short,`safetyGraphics::meta` is now saved as `safetyCharts::meta_aes`, `safetyCharts::meta_labs` and `safetyCharts::meta_dm`.
- A new `makeMeta` function has been created and integrated in to the default workflow for the Shiny app. `makeMeta` provides a much more flexible framework for creating and storing metadata. See `?makeMeta` and the Cookbook and Chart Configuration vignettes for more details.

# safetyGraphics v2.0.0

Version 2 of {safetyGraphics} is a major update that adds the following features:
Expand All @@ -9,7 +16,7 @@ Version 2 of {safetyGraphics} is a major update that adds the following features
- New "Config" tab summarizing app configuration
- Created new `safetyGraphicsInit()` app with a simple UI that can initialize the app with custom data/charts

For more details, see the fully updated vingettes.
For more details, see the fully updated vignettes.

# safetyGraphics v1.1.0

Expand Down
3 changes: 3 additions & 0 deletions R/_disable_autoload.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Disabling shiny autoload

# See ?shiny::loadSupport for more information
16 changes: 7 additions & 9 deletions R/app_startup.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Prepare inputs for safetyGraphics app - run before app is initialized.
#'
#' @param domainData named list of data.frames to be loaded in to the app. Sample AdAM data from the safetyData package used by default
#' @param meta data frame containing the metadata for use in the app. See the preloaded file (\code{?safetyGraphics::meta}) for more data specifications and details. Defaults to \code{safetyGraphics::meta}.
#' @param meta data frame containing the metadata for use in the app. If no metadata is provided (default value is NULL), metatdata is generated by `makeMeta()`.
#' @param charts list of charts in the format produced by safetyGraphics::makeChartConfig()
#' @param mapping list specifying the initial mapping values for each data mapping for each domain (e.g. list(aes= list(id_col='USUBJID', seq_col='AESEQ')).
#' @param autoMapping boolean indicating whether the app should attempt to automatically detect data standards and generate mappings for the data provided. Values specified in the `mapping` parameter overwrite automatically generated mappings when both are found. Defaults to true.
Expand All @@ -22,7 +22,7 @@
#'
#' @export
app_startup<-function(domainData=NULL, meta=NULL, charts=NULL, mapping=NULL, autoMapping=NULL, filterDomain=NULL, chartSettingsPaths=NULL){
# Process charts metadata
# If charts are not provided, load them from chartSettingsPath or the safetyCharts package
if(is.null(charts)){
if(is.null(chartSettingsPaths)){
charts <- makeChartConfig()
Expand All @@ -31,13 +31,8 @@ app_startup<-function(domainData=NULL, meta=NULL, charts=NULL, mapping=NULL, aut
}
}

# Attempt to bind chart functions if none are provided
charts <- charts %>% map(function(chart){
if(!hasName(chart,"functions")){
chart <- prepareChart(chart)
}
return(chart)
})
# Prepare charts - fill in defaults, build metadata, bind functions
charts <- charts %>% map(prepareChart)

# Drop charts where order is negative
orderDrops <- charts[purrr::map_lgl(charts, function(chart) chart$order < 0)]
Expand Down Expand Up @@ -74,6 +69,9 @@ app_startup<-function(domainData=NULL, meta=NULL, charts=NULL, mapping=NULL, aut
}
}

# generate a full list of metadata if none is provided
if(is.null(meta)) meta <- makeMeta(charts)

# generate mappings and data standards
mappingObj <- makeMapping(domainData, meta, autoMapping, mapping)

Expand Down
8 changes: 4 additions & 4 deletions R/detectStandard.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
#' This function compares the columns in the provided \code{"data"} with the required columns for a given data standard/domain combination. The function is designed to work with the SDTM and ADaM CDISC(<https://www.cdisc.org/>) standards for clinical trial data by default. Additional standards can be added by modifying the \code{"meta"} data set included as part of this package.
#'
#' @param data A data frame in which to detect the data standard - required.
#' @param meta the metadata containing the data standards. - default = safetyGraphics::meta
#' @param meta the metadata containing the data standards.
#' @param domain the domain to evaluate - should match a value of \code{meta$domain}. Uses the first value in \code{meta$domain} if no value is provided.
#'
#' @return A data frame describing the detected standard for each \code{"text_key"} in the provided metadata. Columns are \code{"domain"}, \code{"text_key"}, \code{"column"} and \code{"standard"}.
#' @examples
#' detectStandard(data=safetyData::adam_adae) #aes domain evaluated by default
#' detectStandard(data=safetyData::adam_adlbc,domain="labs" )
#' detectStandard(data=safetyData::adam_adae, meta=safetyCharts::meta_aes)
#' detectStandard(data=safetyData::adam_adlbc,meta=safetyCharts::meta_labs, domain="labs" )
#'
#' @importFrom stringr str_detect
#'
#' @export

detectStandard <- function(data, domain=NULL, meta=safetyGraphics::meta){
detectStandard <- function(data, domain=NULL, meta=NULL){
if(is.null(domain)){
domain<-unique(meta$domain)[1]
}
Expand Down
49 changes: 30 additions & 19 deletions R/evaluateStandard.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
#' # Match is TRUE
#' evaluateStandard(
#' data=safetyData::adam_adlbc,
#' meta=meta,
#' meta=safetyCharts::meta_labs,
#' domain="labs",
#' standard="adam"
#' )
#'
#' # Match is FALSE
#' evaluateStandard(
#' data=safetyData::adam_adlbc,
#' meta=meta,
#' meta=safetyCharts::meta_labs,
#' domain="labs",
#' standard="sdtm"
#' )
Expand Down Expand Up @@ -74,32 +74,43 @@ evaluateStandard <- function(data, meta, domain, standard){
)%>%
select(.data$text_key, .data$current, .data$valid)

stopifnot(nrow(compare_summary[["mapping"]])>0)

# count valid/invalid data elements
compare_summary[["total_count"]] <- compare_summary[["mapping"]] %>% nrow()
compare_summary[["valid_count"]] <- compare_summary[["mapping"]] %>% filter(.data$valid) %>% nrow()
compare_summary[["invalid_count"]] <- compare_summary[["mapping"]] %>% filter(!.data$valid) %>% nrow()
compare_summary[["match_percent"]] <- compare_summary[["valid_count"]] / compare_summary[["total_count"]]

standard_formatted <- standard
standard_formatted <- standard
if(standard=="adam"){
standard_formatted = "ADaM"
}else if(standard=="sdtm"){
standard_formatted="SDTM"
}

if (compare_summary[["invalid_count"]]==0) {
compare_summary[["match"]] <- "full"
compare_summary[["label"]] <- standard_formatted
} else if(compare_summary[["valid_count"]]>0) {
compare_summary[["match"]] <- "partial"
compare_summary[["label"]] <- paste0("Partial ",standard_formatted)
compare_summary[["details"]]<-paste0("(", compare_summary[["valid_count"]], "/" ,compare_summary[["total_count"]], " cols/fields matched)")
} else {
if(nrow(compare_summary[["mapping"]])>0){
# count valid/invalid data elements
compare_summary[["total_count"]] <- compare_summary[["mapping"]] %>% nrow()
compare_summary[["valid_count"]] <- compare_summary[["mapping"]] %>% filter(.data$valid) %>% nrow()
compare_summary[["invalid_count"]] <- compare_summary[["mapping"]] %>% filter(!.data$valid) %>% nrow()
compare_summary[["match_percent"]] <- compare_summary[["valid_count"]] / compare_summary[["total_count"]]

if (compare_summary[["invalid_count"]]==0) {
compare_summary[["match"]] <- "full"
compare_summary[["label"]] <- standard_formatted
} else if(compare_summary[["valid_count"]]>0) {
compare_summary[["match"]] <- "partial"
compare_summary[["label"]] <- paste0("Partial ",standard_formatted)
compare_summary[["details"]]<-paste0("(", compare_summary[["valid_count"]], "/" ,compare_summary[["total_count"]], " cols/fields matched)")
} else {
compare_summary[["match"]] <- "none"
compare_summary[["label"]] <- "No Match"
}
}else{
# No values provided for standard in this domain
compare_summary[["total_count"]] <- 0
compare_summary[["valid_count"]] <- NA
compare_summary[["invalid_count"]] <- NA
compare_summary[["match_percent"]] <- 0
compare_summary[["match"]] <- "none"
compare_summary[["label"]] <- "No Match"
}




return(compare_summary)
}
21 changes: 9 additions & 12 deletions R/makeChartConfig.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,21 @@
#' }
#' @export

makeChartConfig <- function(dirs, packages="safetyCharts", packageLocation="config", sourceFiles=TRUE){
makeChartConfig <- function(dirs, packages="safetyCharts", packageLocation="config", sourceFiles=FALSE){
if(missing(dirs)) dirs<-NULL

# add local package installation to dirs if specified in packages
if(!is.null(packages)){
for(package in packages){
packageFound<-FALSE
for(lib in .libPaths()){

packageDir<-paste(lib,package,packageLocation, sep="/")
if(file.exists(packageDir)) {
loaded <- do.call(require,list(package))
if(!loaded) do.call(library,list(package)) #Attach the library to the search list if it is installed
message("- Found the {",package,"} package and added ", packageDir," to list of chart locations.")
packageFound<-TRUE
dirs<-c(dirs, packageDir)
break
}
packageDir <- system.file(packageLocation, package = package)
if(file.exists(packageDir)) {
loaded <- do.call(require,list(package))
if(!loaded) do.call(library,list(package)) #Attach the library to the search list if it is installed
message("- Found the {",package,"} package and added ", packageDir," to list of chart locations.")
packageFound<-TRUE
dirs<-c(dirs, packageDir)
break
}
if(!packageFound){
message("{",package, "} package not found or '",packageLocation,"' folder does not exist, please install package and confirm that specified folder is found.")
Expand Down
10 changes: 8 additions & 2 deletions R/makeMapping.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Create data mapping based on data standards and user input
#'
#' @param domainData named list of data.frames to be loaded in to the app. Sample AdAM data from the safetyData package used by default
#' @param meta data frame containing the metadata for use in the app. See the preloaded file (\code{?safetyGraphics::meta}) for more data specifications and details. Defaults to \code{safetyGraphics::meta}.
#' @param meta data frame containing the metadata for use in the app.
#' @param customMapping optional list specifying initial mapping values within each data mapping (e.g. list(aes= list(id_col='USUBJID', seq_col='AESEQ')).
#' @param autoMapping boolean indicating whether the app should use `safetyGraphics::detectStandard()` to detect data standards and automatically generate mappings for the data provided. Values specified in the `customMapping` parameter overwrite auto-generated mappings when both are found. Defaults to true.
#'
Expand All @@ -21,7 +21,13 @@ makeMapping <- function(domainData, meta, autoMapping, customMapping ){
})
names(standards)<-names(domainData)

auto_mapping_list <- standards %>% map(~.x$mapping)
auto_mapping_list <- standards %>% map(function(standard){
if(standard$standard=="none"){
return(data.frame(domain=character(), text_key=character(), current=character(), valid=logical()))
}else{
return(standard$mapping)
}
})
auto_mapping_df<-bind_rows(auto_mapping_list, .id = "domain") %>% select(-.data$valid)
}else{
# otherwise initialize NULL standards/mapping
Expand Down
Loading