Skip to contents

Overview

The forestly package controls forest plot layouts in a simple and effective approach. To illustrate the idea, we use ADSL (forestly_adsl_3grp) and ADAE (forestly_adae_3grp) datasets in the forestly package that contain three treatment groups.

The first step is to create the required metadata using meta_forestly(). Then we use prepare_ae_forestly() to prepare the input datasets for an interactive forest plot. The outdata contains all the parameters required to generate the interactive forest plot.

metadata <- meta_forestly(
  dataset_adsl = forestly_adsl_3grp,
  dataset_adae = forestly_adae_3grp,
  parameter_term = "any;rel;ser",
  population_subset = SAFFL == "Y",
  observation_subset = SAFFL == "Y"
)

outdata <- metadata |> prepare_ae_forestly()

outdata
#> List of 18
#>  $ meta           :List of 7
#>  $ population     : chr "apat"
#>  $ observation    : chr "safety"
#>  $ parameter      : chr "any;rel;ser"
#>  $ n              :'data.frame': 361 obs. of  4 variables:
#>  $ order          : num [1:361] 1030 1031 1032 1033 1034 ...
#>  $ group          : chr [1:4] "Placebo" "Low Dose" "High Dose" "Total"
#>  $ reference_group: num 1
#>  $ parameter_order: Factor w/ 3 levels "any","rel","ser": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ prop           :'data.frame': 361 obs. of  4 variables:
#>  $ diff           :'data.frame': 361 obs. of  2 variables:
#>  $ n_pop          :'data.frame': 1 obs. of  4 variables:
#>  $ name           : chr [1:361] "Atrial fibrillation" "Atrial flutter" "Atrial hypertrophy" "Atrioventricular block first degree" ...
#>  $ soc_name       : chr [1:361] "CARDIAC DISORDERS" "CARDIAC DISORDERS" "CARDIAC DISORDERS" "CARDIAC DISORDERS" ...
#>  $ ci_lower       :'data.frame': 361 obs. of  2 variables:
#>  $ ci_upper       :'data.frame': 361 obs. of  2 variables:
#>  $ p              :'data.frame': 361 obs. of  2 variables:
#>  $ ae_listing     :'data.frame': 1898 obs. of  15 variables:

The interactive forest plot with default style can be generated.

Maximum page options

By default, it will display the counts that round up to the nearest hundred displayed in the interactive forest plot table. This can be adjusted by using the max_page argument in ae_forestly().

outdata |>
  format_ae_forestly() |>
  ae_forestly(max_page = 280)

Change color

By default, forestly is using teal for treatment group and plum for control group. If user wants to change the color, the color argument in the format_ae_forestly() function can be used. Here is an example for an interactive forest plot using black and grey.

outdata |>
  format_ae_forestly(color = c("black", "grey60", "grey40")) |>
  ae_forestly()

Display different columns

By using the display argument in format_ae_forestly(), we can display the total column.

outdata |>
  format_ae_forestly(display = c("n", "prop", "fig_prop", "fig_diff", "total")) |>
  ae_forestly()

We can also display risk difference columns in a similar approach.

outdata |>
  format_ae_forestly(display = c("n", "prop", "fig_prop", "fig_diff", "diff")) |>
  ae_forestly()

Control column width

We can control column width to customize the layout.

outdata |>
  format_ae_forestly(
    width_fig = 230,
    footer_space = 110
  ) |>
  ae_forestly(width = 1000)

Horizontal scrolling

Set ae_forestly(..., width = NULL) to make the element scrollable horizontally. This is particularly useful when embedding the plot in pages with responsive design, using frameworks such as Bootstrap.

Change variable listed in drill-down table

Users can explore AE listing by clicking \blacktriangleright of each row after we specify column names in ae_listing_display.

listing_var <- c(
  "SEX", "RACE", "AGE",
  "SITEID", "AESEV", "STUDYID",
  "AESER", "AEREL", "ASTDT", "AENDT"
)

metadata |>
  prepare_ae_forestly(
    ae_listing_display = listing_var
  ) |>
  format_ae_forestly() |>
  ae_forestly()

Hide filters

You can use simple CSS rules to hide the incidence rate filter element. For example, in an R Markdown document, use:

```{css, echo=FALSE}
#filter_subject {
  display: none;
}
```