SafetyGraphics / safetyCharts

Charts for monitoring clinical trial safety designed for use with {safetyGraphics}
Other
8 stars 7 forks source link

add framework for rendering widgets #101

Closed jwildfire closed 2 years ago

jwildfire commented 2 years ago

Overview

Inspired by a few requests for customizations to hepExplorer that aren't covered in safetyGraphics. This adds a render_widget() helper function for rendering widgets directly, which is basically just a reusable function created from safetyGraphics chart export code for widgets (generated from safetyGraphics::makeChartExport). hepExplorer is a wrapper that adds some basic defaults and the ability to pass custom settings via ...

@bzkrouse @xni7 Take a look and see what you think! Can discuss whether it's worth building this out further or leaving it as a simple behind-the-scenes utility next time we chat.

Test Code

hepExplorer() #render widget with defaults 
hepExplorer(group_cols=c("SEX","AGEGR1")) # Adding age group

library(yaml)
mapping_yaml<-"id_col: USUBJID
value_col: AVAL
measure_col: PARAM
measure_values:
  ALT: Alanine Aminotransferase (U/L)
  AST: Aspartate Aminotransferase (U/L)
  TB: Bilirubin (umol/L)
  ALP: Alkaline Phosphatase (U/L)
normal_col_low: A1LO
normal_col_high: A1HI
studyday_col: ADY
visit_col: VISIT
visitn_col: VISITNUM
unit_col: ''
baseline_flag_col: ''
baseline_flag_values: ''
analysis_flag_col: ''
analysis_flag_values: ''
"
mapping <- read_yaml(text=mapping_yaml)
render_widget(widgetName="safetyHistogram", data=safetyData::adam_adlbc, mapping=mapping) 
render_widget(widgetName="safetyResultsOverTime", data=safetyData::adam_adlbc, mapping=mapping) 
jwildfire commented 2 years ago

Thanks for the review @xni7. I do like the idea of extending this a bit further, and maybe migrating/reusing a bit more of the chart rendering in safetyGraphics here in safetyCharts. Going to go ahead and release this first bit with v0.3 and then we can discuss extensions for future releases.

Filed #102 so we don't lose track of the shiny binding idea.