Skip to contents

gsm.safety provides R bindings for the safety.viz JavaScript chart library: nine interactive clinical safety displays as htmlwidgets — one for every renderer the library ships — plus bundled example data and report workflows for Good Statistical Monitoring. It mirrors the gsm.kri / gsm.viz architecture.

Widgets

Widget safety.viz module Data Report workflow
Widget_Histogram() histogram adbds safety_histogram.yaml
Widget_ShiftPlot() shiftPlot adbds safety_shift_plot.yaml
Widget_DeltaDelta() deltaDelta adbds safety_delta_delta.yaml
Widget_ResultsOverTime() resultsOverTime adbds safety_results_over_time.yaml
Widget_OutlierExplorer() outlierExplorer adbds safety_outlier_explorer.yaml
Widget_AeTimelines() aeTimelines adae ae_timelines.yaml
Widget_AeExplorer() aeExplorer adae ae_explorer.yaml
Widget_HepExplorer() hepExplorer adbds hep_explorer.yaml
Widget_QtExplorer() qtExplorer adeg qt_explorer.yaml

Each widget validates its data and settings against the module’s vendored JSON data contract (inst/schema/) before rendering, so column-mapping mistakes fail fast in R.

Usage

library(gsm.safety)

# Bundled pharmaverseadam-derived demo data (same data as the safety.viz site demos)
dfResults <- ExampleData("adbds") # long-format labs and vitals
dfAE <- ExampleData("adae") # adverse events
dfEG <- ExampleData("adeg") # ECG: QTcF, QTcB, heart rate

# Render a widget in the viewer
Widget_Histogram(dfResults, lSettings = list(group_by = "ARM"))

# Or save any widget as a self-contained HTML report
SaveWidgetReport(
  Widget_Histogram(dfResults),
  strOutputDir = tempdir(),
  strOutputFile = "histogram"
)

Settings are merged onto each module’s defaults client-side, so only overrides are needed; the defaults already match the example data column names.

Report workflows

Report workflows under inst/workflow/3_reports/ render each widget end-to-end via gsm.core::RunWorkflow(). Matching runner scripts live in inst/examples/:

Rscript inst/examples/histogram.R [output_dir]

Development

devtools::test()
devtools::check()

The gallery thumbnails in man/figures/widgets/ are vendored byte-identical from the safety.viz release assets — the canonical headless-Chromium captures that repo publishes for its own gallery. Refresh them whenever the vendored bundle is bumped:

tools/vendor-widget-thumbnails.sh [path-to-safety.viz-checkout]

License

Apache License 2.0.