Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.0 #155

Merged
merged 73 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
3ce3c4c
very rough cm prototype
jwildfire Oct 12, 2021
6b59c9a
scaffolding paneledOutlierExplorer
MayaGans Apr 15, 2022
a85cd8d
use init as input
MayaGans Apr 15, 2022
a0eed9b
adding static settings, will turn into variables once this works
MayaGans Apr 15, 2022
5b21d05
abstracting settings
MayaGans Apr 15, 2022
95d4fbc
adding settings as arguments
MayaGans Apr 15, 2022
3a67655
Merge pull request #108 from SafetyGraphics/main
jwildfire Apr 16, 2022
a4512a0
refactor to use wrapper for
jwildfire Apr 16, 2022
7cc90ae
refactor to use wrapper for
jwildfire Apr 16, 2022
9634380
Merge pull request #109 from SafetyGraphics/paneledOutlierExplorer
jwildfire Apr 19, 2022
dc69443
enable rendering of aeexplorer without treatment_col
pburnsdata Jul 18, 2022
626be47
add documentation of dependencies
pburnsdata Jul 18, 2022
a811c6a
create single flag at the beginning to avoid hiding trt when user-spe…
pburnsdata Jul 18, 2022
f20b4d1
keep placeholder type char for js sake
pburnsdata Jul 18, 2022
aa3c7da
clean up my spelling
pburnsdata Jul 18, 2022
ecd22af
handle both NULL and "". Comes from safetygraphics as empty string bu…
pburnsdata Jul 18, 2022
bb58531
fix #116
samussiah Jul 18, 2022
40f87f3
Merge branch 'no-trt-aeexplorer' into fix-116
samussiah Jul 18, 2022
6d5195c
Merge pull request #117 from SafetyGraphics/fix-116
samussiah Jul 18, 2022
6dcac07
Merge pull request #115 from SafetyGraphics/no-trt-aeexplorer
samussiah Jul 18, 2022
39e4c7f
broke something
samussiah Feb 23, 2023
02e03fd
fix #125
samussiah Feb 24, 2023
f304100
document
samussiah Feb 24, 2023
d752579
update documentation
samussiah Feb 24, 2023
7cd0287
Merge branch 'dev' into sg-comms
samussiah Feb 24, 2023
d84c04f
Merge pull request #126 from SafetyGraphics/sg-comms
jwildfire Mar 9, 2023
ca1db1c
merge dev
jwildfire Mar 15, 2023
45536d6
adding add metadata. refactor conmeds explorer chart
jwildfire Mar 17, 2023
1c90b23
fix #111
samussiah Mar 28, 2023
cf73c61
add medical history
jwildfire Mar 30, 2023
47cd0ba
remove optional columns
jwildfire Mar 30, 2023
9f99670
Merge pull request #132 from SafetyGraphics/fix-111
jwildfire Mar 30, 2023
f3f336a
Merge branch 'dev' into conmeds
jwildfire Mar 30, 2023
39e5086
add required columns
jwildfire Mar 30, 2023
b5a8786
fix typo + remove cm timeline
jwildfire Mar 30, 2023
820b2c6
add vitals. fix #124
jwildfire Apr 19, 2023
175193f
get cmTimelines working
samussiah Apr 19, 2023
576cb20
add exposure domain. fix #136
jwildfire Apr 19, 2023
4bc9f3c
tweak init functions
samussiah Apr 19, 2023
ba1f455
Merge pull request #91 from SafetyGraphics/conmeds
samussiah Apr 19, 2023
6bd9aff
tweak domain and chart metadata
samussiah Apr 19, 2023
a18aaeb
Merge branch 'fix-124' of https://github.com/SafetyGraphics/safetyCha…
samussiah Apr 19, 2023
51680ae
update ex metadata
samussiah Apr 19, 2023
0a658cb
merge dev
samussiah Apr 19, 2023
0e54945
regenerate .rda files
samussiah Apr 19, 2023
3e4b20e
Merge pull request #139 from SafetyGraphics/fix-124
samussiah Apr 19, 2023
809393e
add param for baseline
jwildfire May 12, 2023
bd885e3
new stack_events function + tests
jwildfire May 26, 2023
1997fa6
add all_of()
jwildfire Jun 16, 2023
cb2bb82
Merge pull request #144 from SafetyGraphics/stack_events
jwildfire Jun 16, 2023
2edc3ac
remove whitespace
samussiah Jun 23, 2023
e7ce612
Upper-case column names
samussiah Jun 23, 2023
3ed7ef8
Update data-raw/meta_hepExplorer.csv
samussiah Jun 23, 2023
368e69e
Merge pull request #143 from SafetyGraphics/add-basline-labs-meta
samussiah Jun 23, 2023
3849059
add stack_events to namespace
samussiah Jun 23, 2023
95e39ec
Merge pull request #146 from SafetyGraphics/update-namespace
jwildfire Jun 23, 2023
50c861f
fix namespace warnings
samussiah Jun 23, 2023
51cfeec
fix unit tests
samussiah Jun 26, 2023
223e811
clean up YAMLs and fix outlier explorer
samussiah Jun 27, 2023
da577da
fix #148
samussiah Jun 27, 2023
f7c9edc
add fix for tibble
nandriychuk Jul 17, 2023
7f7dd32
Merge branch 'fix-namespace' into fix-tibble
samussiah Jul 21, 2023
0358d36
Merge pull request #149 from SafetyGraphics/fix-tibble
samussiah Jul 21, 2023
b7c9404
fix mod_demogRTF.R
samussiah Jul 28, 2023
8ad189f
Merge branch 'fix-namespace' of https://github.com/SafetyGraphics/saf…
samussiah Jul 28, 2023
ec560bf
update r-lib/actions/setup-r to v2
samussiah Jul 28, 2023
876e53e
update imports in description
samussiah Jul 28, 2023
4fc45c1
update namespace and add default arguments to `stack_events`
samussiah Jul 28, 2023
11ca0d4
update description... again
samussiah Jul 28, 2023
4340e69
fix `check()` warning
samussiah Jul 28, 2023
9dc10ad
Merge pull request #147 from SafetyGraphics/fix-namespace
nandriychuk Aug 23, 2023
42c5b01
Update DESCRIPTION
samussiah Sep 20, 2024
65190c6
Merge pull request #156 from SafetyGraphics/samussiah-patch-1
nandriychuk Sep 20, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck"))
Expand Down
8 changes: 6 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: safetyCharts
Title: Charts for Monitoring Clinical Trial Safety
Version: 0.3.0
Version: 0.4.0
Authors@R:
person(
given = "Jeremy",
Expand All @@ -15,16 +15,18 @@ BugReports: https://github.com/SafetyGraphics/safetyCharts/issues
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Imports:
dplyr,
DT,
forcats,
ggplot2,
htmltools,
htmlwidgets,
huxtable,
jsonlite,
magrittr,
pharmaRTF,
plotly,
purrr,
Expand All @@ -33,6 +35,8 @@ Imports:
shiny,
stringr,
Tendril,
tibble,
tidyr,
Tplyr
Suggests:
testthat,
Expand Down
30 changes: 28 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(QT_OutlierExplorer_server)
export(QT_OutlierExplorer_ui)
export(QT_Outlier_Explorer)
export(aeExplorer)
export(demogRTF_server)
export(demogRTF_table)
export(demogRTF_ui)
export(hepExplorer)
export(init_aeExplorer)
export(init_aeTimelines)
export(init_cmExplorer)
export(init_mhExplorer)
export(init_paneledOutlierExplorer)
export(init_safetyOutlierExplorer)
export(init_safetyResultsOverTime)
export(init_safetyShiftPlot)
export(lab_distribution_server)
export(lab_distribution_ui)
export(paneledOutlierExplorer)
export(render_widget)
export(safetyOutlierExplorer_server)
export(safetyOutlierExplorer_ui)
export(safety_outlier_explorer)
export(safety_results_over_time)
export(stack_events)
export(standardize_events)
export(tendril_chart)
import(Tendril)
import(Tplyr)
import(dplyr)
import(ggplot2)
import(htmlwidgets)
import(rlang)
import(shiny)
importFrom(DT,DTOutput)
importFrom(DT,renderDT)
importFrom(RColorBrewer,brewer.pal)
importFrom(Tendril,Tendril)
importFrom(dplyr,left_join)
importFrom(dplyr,select)
importFrom(forcats,fct_drop)
importFrom(forcats,fct_reorder)
importFrom(htmltools,br)
importFrom(htmltools,div)
importFrom(htmlwidgets,createWidget)
importFrom(htmlwidgets,sizingPolicy)
importFrom(huxtable,as_hux)
importFrom(huxtable,set_align)
importFrom(huxtable,set_bold)
Expand All @@ -37,19 +54,28 @@ importFrom(huxtable,set_escape_contents)
importFrom(huxtable,set_valign)
importFrom(huxtable,set_width)
importFrom(jsonlite,toJSON)
importFrom(magrittr,"%>%")
importFrom(pharmaRTF,add_footnotes)
importFrom(pharmaRTF,add_titles)
importFrom(pharmaRTF,hf_line)
importFrom(pharmaRTF,rtf_doc)
importFrom(pharmaRTF,set_column_header_buffer)
importFrom(pharmaRTF,set_font_size)
importFrom(pharmaRTF,set_ignore_cell_padding)
importFrom(pharmaRTF,write_rtf)
importFrom(plotly,animation_slider)
importFrom(plotly,layout)
importFrom(plotly,plot_ly)
importFrom(plotly,plotlyOutput)
importFrom(plotly,renderPlotly)
importFrom(purrr,imap)
importFrom(purrr,list_modify)
importFrom(purrr,map)
importFrom(rlang,.data)
importFrom(rlang,set_names)
importFrom(rlang,sym)
importFrom(stats,setNames)
importFrom(stringr,str_detect)
importFrom(tibble,as_tibble)
importFrom(tidyr,unite)
importFrom(utils,hasName)
11 changes: 5 additions & 6 deletions R/QT_Outlier_Explorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
#'
#' @return returns a chart object
#'
#' @import dplyr
#' @importFrom plotly plot_ly animation_slider layout
#' @import rlang
#' @importFrom rlang .data
#' @import dplyr
#'
#' @export




QT_Outlier_Explorer <- function(data, settings)
{
QT_Outlier_Explorer <- function(
data,
settings
) {

# horizontal reference line
hline <- function(y = 0, color = "blue") {
Expand Down
97 changes: 97 additions & 0 deletions R/aeExplorer.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#' Make standalone aeExplorer html widget
#'
#' Convience mapping of render_widget for aeExplorer.
#'
#' The [data](https://github.com/RhoInc/aeexplorer/wiki/Data-Guidelines) and
#' [mapping](https://github.com/RhoInc/aeexplorer/wiki/Configuration) should match the specs
#' described in the [aeExplorer](https://github.com/RhoInc/aeexplorer/wiki/Configuration)
#' JavaScript library. Items passed in ... are added to mapping, and then the list is converted to
#' JSON via `jsonlite::toJSON(mapping, auto_unbox=TRUE, NULL="NULL")`.
#'
#' The default mapping shown below is designed to work with data in the CDISC ADaM format (like
#' `safetydata::adam_adlbc`).
#'
#' ```
#' mapping <- list(
#' dm = list(
#' id_col = 'USUBJID',
#' treatment_col = 'ARM'
#' ),
#' aes = list(
#' id_col = 'USUBJID',
#' bodsys_col = 'AEBODSYS',
#' term_col = 'AEDECOD'
#' )
#' )
#' ```
#'
#' Parameters that are not included in the default mapping can be accessed via ....
#'
#' For more options see the [full specs](https://github.com/RhoInc/aeexplorer/wiki/Configuration) in
#' the JavaScript library.
#'
#' @examples
#' \dontrun{
#' # Render widget with defaults.
#' aeExplorer()
#'
#' # Render widget without stratification.
#' aeExplorer(
#' mapping = list(
#' dm = list(
#' id_col = 'USUBJID'
#' ),
#' aes = list(
#' id_col = 'USUBJID',
#' bodsys_col = 'AEBODSYS',
#' term_col = 'AEDECOD'
#' )
#' )
#' )
#' }
#'
#' @param data `list` Named list of data frames that includes participant-level subject data (`dm`)
#' and event-level adverse event data (`aes`).
#' @param mapping `list` Named list with current data mappings. See details for default mapping.
#' @param ... additional options to be added to mapping. Will overwrite mapping.
#'
#' @importFrom purrr list_modify
#'
#' @export

aeExplorer <- function(
data = list(
dm = safetyData::sdtm_dm,
aes = safetyData::sdtm_ae
),
mapping = NULL,
...
) {
# Default mapping - TODO: retrieve mapping from a dedicated file or object (in safetyGraphics?).
if (is.null(mapping)) {
mapping <- list(
dm = list(
id_col = 'USUBJID',
treatment_col = 'ARM'
),
aes = list(
id_col = 'USUBJID',
bodsys_col = 'AEBODSYS',
term_col = 'AEDECOD'
)
)
}

# Add ... to mapping.
if (length(list(...)) > 0) {
mapping <- purrr::list_modify(mapping, !!!list(...))
}

initialized <- init_aeExplorer(
data = data,
settings = mapping
)

# Render widget as standalone HTML page.
render_widget("aeExplorer", initialized$data, initialized$settings)
}
21 changes: 12 additions & 9 deletions R/hepExplorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Convience mapping of render_widget for hepExplorer.
#'
#' @details The [data](https://github.com/SafetyGraphics/hep-explorer/wiki/Data-Guidelines) and [mapping](https://github.com/SafetyGraphics/hep-explorer/wiki/Configuration) should match the specs described in the [hepExplorer](https://github.com/SafetyGraphics/hep-explorer/wiki/Configuration) javascript library. Items passed in ... are added to mapping, and then the list is converted to json via `jsonlite::toJSON(mapping, auto_unbox=TRUE, null="null")`.
#' The [data](https://github.com/SafetyGraphics/hep-explorer/wiki/Data-Guidelines) and [mapping](https://github.com/SafetyGraphics/hep-explorer/wiki/Configuration) should match the specs described in the [hepExplorer](https://github.com/SafetyGraphics/hep-explorer/wiki/Configuration) javascript library. Items passed in ... are added to mapping, and then the list is converted to json via `jsonlite::toJSON(mapping, auto_unbox=TRUE, null="null")`.
#'
#' The default mapping shown below is designed to work with data in the CDISC ADaM format (like `safetydata::adam_adlbc`).
#'
Expand Down Expand Up @@ -48,7 +48,7 @@
#'
#' # Use custom mapping for SDTM data
#' hepExplorer(
#' df=safetyData::sdtm_lb,
#' data=safetyData::sdtm_lb,
#' measure_col = "LBTEST",
#' measure_values = list(
#' ALT = "Alanine Aminotransferase",
Expand All @@ -66,17 +66,20 @@
#' )
#' }
#'
#' @param df data frame containing lab data used to render for hepExplorer. Default is safetyData::adam_adlbc.
#' @param mapping named list with the current data mappings. See details for default mapping.
#' @param data `data.frame` Data frame containing lab data used to render `hepExplorer`. Default: `safetyData::adam_adlbc`
#' @param mapping `list` named list with the current data mappings. See details for default mapping.
#' @param ... additional options to be added to mapping. Will overwrite mapping.
#'
#' @importFrom purrr list_modify
#'
#' @export

hepExplorer <- function(df=safetyData::adam_adlbc, mapping=NULL, ...){

#default mapping
hepExplorer <- function(
data = safetyData::adam_adlbc,
mapping = NULL,
...
) {
# default mapping
if(is.null(mapping)){
mapping <- list(
measure_col = "PARAM",
Expand All @@ -102,5 +105,5 @@ hepExplorer <- function(df=safetyData::adam_adlbc, mapping=NULL, ...){
}

# render widget as standalone html page
render_widget("hepExplorer" ,df, mapping)
}
render_widget("hepExplorer" ,data, mapping)
}
42 changes: 37 additions & 5 deletions R/init_aeExplorer.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
#' Initialize Settings for Adverse Event Explorer widget
#'
#' @param data labs data structured as one record per person per visit per measurement. See details for column requirements.
#' @param settings named list of settings
#' @param data `list` Named list of data frames that includes participant-level subject data (`dm`)
#' and event-level adverse event data (`aes`).
#' @param settings `list` Named list of settings.
#'
#' @return returns list with data and settings
#'
#' @import dplyr
#'
#' @export


init_aeExplorer <- function(data, settings) {

# creates flag if treatment_col is missing to trigger actions to avoid downstream JS errors and enable visualization of blinded(no treatment_col) data
missing_trt_flag <- (
is.null(settings[["dm"]][["treatment_col"]]) || # Check NULL first and evaluate logic left to right
trimws(settings[["dm"]][["treatment_col"]])==""
)

#if no treatment_col provided, create dummy treatment_col for group setting so that ae explorer JS doesn't bomb
if (missing_trt_flag) {
data$dm <- data$dm %>% dplyr::mutate(group_placeholder="All")
settings[["dm"]][["treatment_col"]] <- "group_placeholder"
}

# Merge treatment with adverse events.
dm_sub <- data$dm %>% select(settings[["dm"]][["id_col"]], settings[["dm"]][["treatment_col"]])
anly <- dm_sub %>% left_join(data$aes) # left join to keep all rows in dm (even if there were no AEs)
dm_sub <- data$dm %>%
dplyr::select(
settings[["dm"]][["id_col"]],
settings[["dm"]][["treatment_col"]]
)

# left join to keep all rows in dm (even if there were no AEs)
anly <- dm_sub %>%
dplyr::left_join(
data$aes,
settings[['dm']][['id_col']]
)

ae_settings <- list()

Expand All @@ -37,5 +62,12 @@ init_aeExplorer <- function(data, settings) {
values = c("", NA, NULL)
)
)

#if no treatment_col provided, remove total column and group selection dropdown
if (missing_trt_flag){
ae_settings$defaults[["groupCols"]] = FALSE
ae_settings$defaults[["useVariableControls"]] = FALSE
}

return(list(data = anly, settings = ae_settings))
}
2 changes: 1 addition & 1 deletion R/init_aeTimelines.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Initialize Settings for AE Timeline widget
#'
#' @param data labs data structured as one record per person per visit per measurement. See details for column requirements.
#' @param data adverse events data structured as one record per event. See details for column requirements.
#' @param settings named list of settings
#'
#' @return returns list with data and settings
Expand Down
Loading
Loading