ae-explorer API reference
Generated from the module's JSDoc and JSON-Schema data contract โ npm run docs:api fails on undocumented surface.
Overview
Every safety.viz renderer is one factory call. aeExplorer(element, settings) empties the container, renders the shared control shell, and returns a chart instance; pass data to setData (or init) and the module validates it against its data contract, structures it, and draws. Settings are merged onto the module's defaults, so callers supply only overrides โ column mappings follow ADaM naming out of the box. The same lifecycle (init, setData, setSettings, render, showDetails, backToSummary, buildValidationCsv, resize, destroy) is shared by every module and consumed unchanged by the gsm.safety R bindings. See Architecture for how the pieces fit together.
Factory
aeExplorer([element], [settings])
Create an adverse-event explorer inside a container element. The control shell renders immediately; pass one-record-per-adverse-event data (plus placeholder rows for participants with no adverse events) to setData (or init) on the returned instance to validate the data and draw the summary table (AE-API-001).
| Param | Type | Default | Description |
|---|---|---|---|
element (optional) | string | HTMLElement | 'body' | Container node, or a CSS selector for it. |
settings (optional) | AEExplorerSettings | {} | Setting overrides, merged onto DEFAULT_SETTINGS and normalized. |
Returns: AEExplorer โ The live explorer instance.
Methods
init(data)
Load data and render: an alias for setData that keeps the original renderer's create-then-init call shape working (AE-DATA-003, AE-API-001).
| Param | Type | Default | Description |
|---|---|---|---|
data | Array.<Object> | โ | Adverse-event records matching the ae-explorer data contract. |
Returns: AEExplorer โ The instance, for chaining.
setData(data)
Replace the bound data and re-render. The data is validated against the settings mapping (throwing, and rendering the message into the target element, when required columns are missing); placeholder rows for participants with no adverse events are flagged so they count toward the population denominators (AE-DATA-001); and the filter controls are rebuilt from the new data's values.
| Param | Type | Default | Description |
|---|---|---|---|
data | Array.<Object> | โ | Adverse-event records matching the ae-explorer data contract. |
Returns: AEExplorer โ The instance, for chaining.
setSettings(settings)
Merge setting overrides onto the current settings, re-normalize them (same rules as the factory), re-seed the control state, rebuild the controls, and re-render.
| Param | Type | Default | Description |
|---|---|---|---|
settings | AEExplorerSettings | โ | Setting overrides to merge. |
Returns: AEExplorer โ The instance, for chaining.
render()
Redraw the summary table from the current data, settings, and control state: closes any open details view, recomputes the roll-up, and rebuilds the table with the prevalence and search visibility applied. Called automatically by the controls and the data/settings setters; call it directly only after mutating state by hand.
Returns: void โ
showDetails(target)
Open the details view for a category (AE-USER-016): the record-level listing of the events under the clicked System Organ Class or Preferred Term as currently filtered, with the active filters reported and a Return to the Summary View button.
| Param | Type | Default | Description |
|---|---|---|---|
target | Object | โ | The clicked category. |
Returns: void โ
backToSummary()
Return from the details view to the summary table (AE-USER-017).
Returns: void โ
buildValidationCsv()
The validation download's payload: the summarized data as currently filtered and summarized, and its major-minor-basis file name (AE-USER-020, AE-REG-027).
Returns: Object โ The file name and CSV text.
resize()
Table layout reflows with the page, so resizing is a no-op kept for the shared lifecycle shape (the R htmlwidget bindings call it).
Returns: void โ
destroy()
Tear the explorer down: empty the target element. The instance cannot be reused afterwards โ create a new one via the factory instead.
Returns: void โ
Settings
| Setting | Type | Default | Description |
|---|---|---|---|
id_col | string | 'USUBJID' | Participant identifier column; required in the data. Distinct participants drive the group denominators and participant-mode numerators. |
major_col | string | 'AEBODSYS' | Major category column โ the MedDRA System Organ Class; required in the data. One expandable table section per level, and the default placeholder-flag column (AE-CFG-003). |
minor_col | string | 'AEDECOD' | Minor category column โ the MedDRA Preferred Term; required in the data. One nested row per level under its System Organ Class. |
group_col | string | 'ARM' | Treatment group column; required in the data. One rate column per level, up to max_groups. |
groups | Array.<string> | null | null | Group levels to show as columns (AE-CFG-005). Null derives every level found in group_col, sorted; configured levels missing from the data are dropped with a console warning. A single group hides the Total and Difference columns (AE-USER-019). |
colors | Array.<string> | โ | Group colors assigned by column order (AE-CFG-006); the Total column always renders gray, and the default palette carries no yellow (AE-REG-040). |
filters | Array.<(string|Object)> | null | null | Filter controls (AE-USER-018): column names or { value_col, label, type, start } specs. Type 'event' narrows the events counted; type 'participant' narrows the analysis population and its denominators (AE-REG-006). Defaults to the four ADAE event filters โ seriousness, severity, relationship, outcome; filters whose column is absent or single-valued are dropped with a console warning. |
details | Array.<(string|Object)> | null | null | Columns for the details drill-down listing (AE-REG-024); null shows every input column. |
variable_options | Object | null | null | Valid alternative columns for the primary mappings (AE-CFG-004): keys id, major, minor, group, each an array of column names. Two or more options for a mapping draw a re-mapping control; the current mapping is always offered even when not listed (AE-REG-044). |
placeholder_flag | Object | โ | How placeholder rows for AE-free participants are identified (AE-DATA-001): value_col (null follows major_col) and the values marking a placeholder (blank and 'NA' by default). |
max_prevalence | number | 0 | Initial minimum-prevalence filter value in percent (AE-USER-001). |
max_groups | number | 6 | Most group columns the table will draw; more levels than this throws. |
total_col | boolean | true | Draw the all-groups Total column; suppressed automatically when only one group shows (AE-REG-037). |
group_cols | boolean | true | Draw the per-group rate columns; disabling leaves a Total-only table and suppresses the Difference column (AE-REG-037). |
diff_col | boolean | true | Draw the Difference Between Groups column (AE-USER-013); needs two or more shown groups. |
pref_terms | boolean | false | Start with every Preferred Term row expanded instead of collapsed. |
summarize_by | string | 'participant' | Summary basis (AE-USER-006): 'participant' or 'event' (AE-REG-033, AE-REG-035); unknown values fall back to the default. |
validation | boolean | false | Adds a summarized-data CSV download named major-minor-summarize_by (AE-CFG-009, AE-USER-020). |
plot_settings | Object | โ | Inline row-plot geometry (AE-CFG-008): height, width, and point radius in pixels, with margin / diff_margin {left, right} insets for the rate and difference axes (AE-REG-046). |
page_size | number | 10 | Rows per page in the details drill-down listing. |
Data contract
safety.viz ae-explorer data contract
Adverse-event data: one record per adverse event, plus one placeholder row per participant with no adverse events so the population denominator is right (AE-DATA-001). Placeholder rows are identified by the placeholder_flag setting โ blank or 'NA' in the System Organ Class column by default โ and count toward participant denominators while never appearing as events. Column names default to the ADaM ADAE standard and are remappable through the settings (AE-CFG-003); a chart initializes with no settings at all when the data carries the default columns (AE-DATA-003).
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
data | array | yes | โ | d3.csv()-style records; every row carries the participant, System Organ Class, Preferred Term, and treatment-group columns named in settings. |
settings | object | yes | โ | Column mappings and rendering options; merged onto the module's DEFAULT_SETTINGS, so only overrides need to be supplied (AE-CFG-001). |
settings.id_col | string | yes | USUBJID | Participant identifier column; required in data. Distinct participants drive the group denominators and participant-mode numerators. |
settings.major_col | string | yes | AEBODSYS | Major category column โ the MedDRA System Organ Class; required in data. One expandable table section per level, and the default placeholder-flag column. |
settings.minor_col | string | yes | AEDECOD | Minor category column โ the MedDRA Preferred Term; required in data. One nested row per level under its System Organ Class. |
settings.group_col | string | yes | ARM | Treatment group column; required in data. One rate column per level (up to max_groups). |
settings.groups | array,null | no | โ | Group levels to show as columns (AE-CFG-005). Null derives every level found in group_col, sorted; configured levels missing from the data are dropped with a console warning. A single group hides the Total and Difference columns (AE-USER-019). |
settings.colors | array | no | โ | Group colors assigned by column order (AE-CFG-006); the Total column always renders gray. The default palette carries no yellow. |
settings.filters | array,null | no | โ | Filter controls (AE-USER-018): column names or { value_col, label, type, start } specs. Type 'event' narrows the events counted; type 'participant' narrows the analysis population and its denominators. Defaults to the four ADAE event filters โ seriousness, severity, relationship, outcome; filters whose column is absent or single-valued are dropped with a console warning. |
settings.details | array,null | no | โ | Columns for the details drill-down listing (AE-REG-024): null shows every input column. |
settings.variable_options | object,null | no | โ | Valid alternative columns for the primary mappings (AE-CFG-004): keys id, major, minor, group, each an array of column names. Two or more options for a mapping draw a re-mapping control; the current mapping is always offered even when not listed (AE-REG-044). |
settings.variable_options.id | array | no | โ | |
settings.variable_options.major | array | no | โ | |
settings.variable_options.minor | array | no | โ | |
settings.variable_options.group | array | no | โ | |
settings.placeholder_flag | object | no | โ | How placeholder rows for AE-free participants are identified (AE-DATA-001): value_col (null defaults to major_col) and the values that mark a placeholder. |
settings.placeholder_flag.value_col | string,null | no | โ | |
settings.placeholder_flag.values | array | no | ,NA | |
settings.max_prevalence | number | no | 0 | Initial minimum-prevalence filter value in percent (AE-USER-001): rows where every group rate is below the threshold are hidden. |
settings.max_groups | number | no | 6 | Most group columns the table will draw; more levels than this throws. |
settings.total_col | boolean | no | true | Draw the all-groups Total column (AE-REG-037). Suppressed automatically when only one group shows. |
settings.group_cols | boolean | no | true | Draw the per-group rate columns. Disabling leaves a Total-only table and suppresses the Difference column (AE-REG-037). |
settings.diff_col | boolean | no | true | Draw the Difference Between Groups column (AE-USER-013). Needs two or more shown groups. |
settings.pref_terms | boolean | no | false | Start with every Preferred Term row expanded instead of collapsed. |
settings.summarize_by | string | no | participant | Summary basis (AE-USER-006): participants with at least one event over the group's distinct participants, or event counts over the group's event total (AE-REG-033, AE-REG-035). |
settings.validation | boolean | no | false | Adds a summarized-data CSV download named major-minor-summarize_by (AE-CFG-009, AE-USER-020). |
settings.plot_settings | object | no | โ | Inline row-plot geometry (AE-CFG-008): height, width, and point radius in pixels, with margin / diff_margin {left, right} insets for the rate and difference plots (AE-REG-046). |
settings.plot_settings.height | number | no | 15 | |
settings.plot_settings.width | number | no | 200 | |
settings.plot_settings.radius | number | no | 7 | |
settings.plot_settings.margin | object | no | [object Object] | |
settings.plot_settings.diff_margin | object | no | [object Object] | |
settings.page_size | number | no | 10 | Rows per page in the details drill-down listing. |