Skip to contents

Display interactive forest plot

Usage

ae_forestly(
  outdata,
  display_soc_toggle = TRUE,
  display_diff_toggle = NULL,
  filter = c("prop", "n"),
  filter_label = NULL,
  filter_range = NULL,
  ae_label = NULL,
  max_page = NULL,
  download_button = FALSE,
  width = NULL
)

Arguments

outdata

An outdata object created by format_ae_forestly().

display_soc_toggle

Whether to include the SOC column in the table. If TRUE, it is offered in the "Show/Hide columns" menu (hidden by default); if FALSE, it is left out of the table entirely. Including it makes the saved HTML file slightly larger, which only matters for very large data sets.

display_diff_toggle

Deprecated and ignored. The numeric risk-difference columns are always in the table and, unless "diff" is in the display argument of format_ae_forestly(), offered in the "Show/Hide columns" menu (hidden by default).

filter

The variable the incidence slider (the "Incidence (%) in One or More Treatment Groups" chip in the control bar) filters on: "prop" for incidence (%) or "n" for the number of AEs. Use NULL to hide the slider.

filter_label

A character value of the label for the slider chip.

filter_range

A numeric vector of length 2 for the range of the slider.

ae_label

A character value of the label for criteria. If NULL (default), the range is automatically calculated from the data. If only one value is provided, it will be used as the maximum and minimum will be 0.

max_page

A numeric value of max page number shown in the table.

download_button

A logical value to display download button.

width

Table container width, a number (interpreted as pixels) or any CSS width value. If NULL (default), the container fills its parent; a value fixes the container width. A wider table scrolls inside rather than widening the page, and the container can be resized by dragging its corner.

Value

An AE forest plot saved as a shiny.tag.list object.

Searching and filtering

The interactive table has a search box for each column (and, in the expandable detail listing, a table-wide search box). In addition to a plain substring match, the search terms understand two extra styles.

Negation with !. Prefix a term with an exclamation mark to exclude matching rows instead of keeping them:

  • Rash — keep rows whose value contains "Rash".

  • !Rash — keep rows whose value does not contain "Rash".

Expressions. If the term mentions the letter x (which stands for the value of the cell being searched), it is evaluated as a small expression and the row is kept when the expression is true. x behaves like the value in that column, so numeric columns can be compared with numbers and text columns with quoted text. Common patterns:

Type this in the search boxKeeps rows where
x > 5the value is greater than 5
x >= 5the value is 5 or more
x < 65the value is less than 65
x >= 18 && x <= 65the value is between 18 and 65 (inclusive)
x == 0the value equals 0
x === "Rash"the value is exactly "Rash"
x !== "Rash"the value is anything except exactly "Rash"
x.includes("itch")the text contains "itch"
!x.includes("itch")the text does not contain "itch"
x.startsWith("Application")the text starts with "Application"
x.endsWith("itis")the text ends with "itis"
x === "M" || x === "F"the value is either "M" or "F"

Notes for the expression style:

  • Wrap text values in quotes ("Rash"); numbers need no quotes (5).

  • Use && for "and", || for "or", and ! in front of a condition for "not".

  • Comparisons use doubled symbols: === (equal), !== (not equal), together with >, >=, <, <=.

  • Matching is case-sensitive in the expression style, so x === "m" will not match "M". Use the plain substring style (which ignores case) when case does not matter.

  • A term that mentions x but is not a valid expression is treated as an ordinary substring search, so everyday searches keep working.

Examples

adsl <- forestly_adsl
adae <- forestly_adae
adsl$TRTA <- factor(
  adsl$TRT01A,
  levels = c("Xanomeline Low Dose", "Placebo"),
  labels = c("Low Dose", "Placebo")
)
adae$TRTA <- factor(
  adae$TRTA,
  levels = c("Xanomeline Low Dose", "Placebo"),
  labels = c("Low Dose", "Placebo")
)

analysis_plan <- metalite::plan(
  analysis = "ae_forestly",
  population = "apat",
  observation = "wk12",
  parameter = "any"
)
meta <- metalite::meta_adam(population = adsl, observation = adae) |>
  metalite::define_plan(plan = analysis_plan) |>
  metalite::define_population(
    name = "apat",
    var = c("USUBJID", "SAFFL", "TRTA", "SITEID", "SEX", "RACE", "AGE"),
    group = "TRTA",
    subset = SAFFL == "Y",
    label = "All Participants as Treated"
  ) |>
  metalite::define_observation(
    name = "wk12",
    var = c(
      "USUBJID", "SAFFL", "TRTA", "SITEID", "SEX", "RACE", "AGE",
      "ASTDY", "AEDECOD", "AEBODSYS", "AESER", "AEREL", "AEACN",
      "AEOUT", "ADURN", "ADURU"
    ),
    group = "TRTA",
    subset = SAFFL == "Y",
    label = "Weeks 0 to 12"
  ) |>
  metalite::define_parameter(
    name = "any",
    term1 = "",
    term2 = "",
    var = "AEDECOD",
    soc = "AEBODSYS",
    label = "All AEs"
  ) |>
  metalite::define_analysis(
    name = "ae_forestly",
    label = "Interactive forest plot"
  ) |>
  metalite::meta_build()

if (interactive()) {
  meta |>
    prepare_ae_forestly(parameter = "any") |>
    format_ae_forestly() |>
    ae_forestly()
}