Skip to contents

Overview

Interactive box plots refers to the graphical representations that allow users to explore and analyze data through an interactive interface. They provide a way to visualize the distribution, central tendency, and variability of a dataset using a box-and-whisker plot, while also providing additional interactivity for deeper exploration.

Some common interactive features of the box plots include:

  • Hovering: When the user hovers the mouse cursor over a specific part of the plot, additional information related to that specific data point or summary statistic is displayed. This includes the descriptive statistics (N, Mean, Median, Q1, Q3, Min and Max), Subject ID and Change from Baseline

  • Filtering: It is possible to apply filters to the data, enabling users to select specific Parameter from a domain (Labs, Vitals, ECG)

Mental model

Creating the box plot using this package involves the below steps:

  • Create a metadata object using the metalite package
  • Call prepare_boxly() function to prepare the metadata as required by the user
  • Call boxly() function to create the interactive plot

Example 1: Interactive Box Plot Using Labs Data

Step 1: Create a metadata object using the metalite package

analysis_plan <- metalite::plan(
  analysis = "boxly",
  population = "apat",
  observation = "wk12",
  parameter = "SODIUM;K;CL"
)

meta <- metalite::meta_adam(
  population = boxly_adsl,
  observation = boxly_adlb
) |>
  metalite::define_plan(analysis_plan) |>
  metalite::define_population(
    name = "apat",
    group = "TRTA",
    subset = SAFFL == "Y",
    label = "Safety Population"
  ) |>
  metalite::define_observation(
    name = "wk12",
    group = "TRTA",
    var = "PARAM",
    subset = AVISITN <= 12 & !is.na(CHG),
    label = "Weeks 0 to 12"
  ) |>
  metalite::define_parameter(
    name = "SODIUM",
    label = "Sodium (mmol/L)",
    subset = PARAMCD == "SODIUM"
  ) |>
  metalite::define_parameter(
    name = "K",
    label = "Potassium (mmol/L)",
    subset = PARAMCD == "K"
  ) |>
  metalite::define_parameter(
    name = "CL",
    label = "Chloride (mmol/L)",
    subset = PARAMCD == "CL"
  ) |>
  metalite::define_analysis(
    name = "boxly",
    label = "Interactive Box Plot",
    x = "AVISITN",
    y = "CHG"
  ) |>
  metalite::meta_build()

Step2: Call prepare_boxly() function to prepare the metadata as required by the user

outdata <- prepare_boxly(meta)
outdata
#> List of 14
#>  $ meta             :List of 7
#>  $ population       : chr "apat"
#>  $ observation      : chr "wk12"
#>  $ parameter        : chr "SODIUM;K;CL"
#>  $ n                :'data.frame':   45 obs. of  5 variables:
#>  $ order            : NULL
#>  $ group            : NULL
#>  $ reference_group  : NULL
#>  $ x_var            : chr "AVISITN"
#>  $ y_var            : chr "CHG"
#>  $ group_var        : chr "TRTA"
#>  $ param_var        : chr "PARAM"
#>  $ hover_var_outlier: chr [1:2] "USUBJID" "CHG"
#>  $ plotds           :'data.frame':   3049 obs. of  15 variables:

Step 3: Call boxly() function to create the interactive plot

boxly(outdata)
Number of Participants

Example 2: Interactive Box Plot Using Vital Signs Data

analysis_plan <- metalite::plan(
  analysis = "boxly",
  population = "apat",
  observation = "wk12",
  parameter = "DIABP;PULSE;SYSBP"
)

meta <- metalite::meta_adam(
  population = boxly_adsl,
  observation = boxly_advs
) |>
  metalite::define_plan(analysis_plan) |>
  metalite::define_population(
    name = "apat",
    group = "TRTA",
    subset = SAFFL == "Y",
    label = "Safety Population"
  ) |>
  metalite::define_observation(
    name = "wk12",
    group = "TRTA",
    var = "PARAM",
    subset = AVISITN <= 12 & !is.na(CHG),
    label = "Weeks 0 to 12"
  ) |>
  metalite::define_parameter(
    name = "DIABP",
    label = "Diastolic Blood Pressure (mmHg)",
    subset = PARAMCD == "DIABP"
  ) |>
  metalite::define_parameter(
    name = "PULSE",
    label = "Pulse Rate (BEATS/MIN)",
    subset = PARAMCD == "PULSE"
  ) |>
  metalite::define_parameter(
    name = "SYSBP",
    label = "Systolic Blood Pressure (mmHg)",
    subset = PARAMCD == "SYSBP"
  ) |>
  metalite::define_analysis(
    name = "boxly",
    label = "Interactive Box Plot",
    x = "AVISITN",
    y = "CHG"
  ) |>
  metalite::meta_build()

meta |>
  prepare_boxly() |>
  boxly()
Number of Participants

Example 3: Interactive Box Plot Using ECG Data

analysis_plan <- metalite::plan(
  analysis = "boxly",
  population = "apat",
  observation = "wk12",
  parameter = "ARATE;PR;QRS"
)

meta <- metalite::meta_adam(
  population = boxly_adsl,
  observation = boxly_adeg
) |>
  metalite::define_plan(analysis_plan) |>
  metalite::define_population(
    name = "apat",
    group = "TRTA",
    subset = SAFFL == "Y",
    label = "Safety Population"
  ) |>
  metalite::define_observation(
    name = "wk12",
    group = "TRTA",
    var = "PARAM",
    subset = AVISITN <= 12 & !is.na(CHG),
    label = "Weeks 0 to 12"
  ) |>
  metalite::define_parameter(
    name = "ARATE",
    label = "Atrial Rate (beats/min)",
    subset = PARAMCD == "ARATE"
  ) |>
  metalite::define_parameter(
    name = "PR",
    label = "PR Interval (msec)",
    subset = PARAMCD == "PR"
  ) |>
  metalite::define_parameter(
    name = "QRS",
    label = "QRS Interval (msec)",
    subset = PARAMCD == "QRS"
  ) |>
  metalite::define_analysis(
    name = "boxly",
    label = "Interactive Box Plot",
    x = "AVISITN",
    y = "CHG"
  ) |>
  metalite::meta_build()

meta |>
  prepare_boxly() |>
  boxly()
Number of Participants