arframe TFL Gallery
  1. Figures
  2. Waterfall Plot
  • Getting Started
    • Installation

  • Tables
    • Study Conduct
    • Enrollment by Country and Site

    • Study Population
    • Demographics Summary
    • Medical History
    • Prior Medication
    • Disposition Summary
    • Analysis Populations

    • Extent of Exposure
    • Concomitant Medications
    • Extent of Exposure

    • Safety
    • Adverse Events by System Organ Class and Preferred Term
    • AEs Related to Study Drug
    • Common Adverse Events
    • Adverse Events by Grade / Intensity
    • Overall Safety Summary
    • Adverse Events with Event Counts
    • Exposure-Adjusted Adverse Events
    • Adverse Events by Subgroup
    • Serious Adverse Events by SOC and PT
    • AEs Leading to Study Drug Discontinuation
    • Death Summary
    • Vital Signs
    • Laboratory Results - Chemistry
    • Laboratory Shift Table
    • Laboratory Worst Toxicity Grade
    • Laboratory Marked Abnormalities
    • Electrocardiogram Summary

    • Efficacy
    • Time to Event Summary
    • Best Overall Response

  • Listings
    • Adverse Event Listing
    • Demographic Characteristics Listing
    • Medical History Listing
    • Vital Signs Listing
    • Laboratory Test Results Listing
    • Concomitant Medications Listing

  • Figures
    • Kaplan-Meier Plot
    • Swimmer Plot
    • Waterfall Plot

On this page

  • Setup
  • Plot Construction
  • arframe Pipeline
  • Rendered Figure
  1. Figures
  2. Waterfall Plot

Waterfall Plot

Best Percentage Change from Baseline in Target Lesion

Setup

See Prerequisites for installation instructions.

library(arframe)
library(ggplot2)
library(pharmaverseadam)
library(dplyr, warn.conflicts = FALSE)

arm_levels <- c("Placebo", "Xanomeline Low Dose", "Xanomeline High Dose")
arm_colors <- c("#1b9e77", "#d95f02", "#7570b3")

# Best % change from baseline per subject (sum of target lesion diameters)
waterfall_data <- pharmaverseadam::adtr_onco |>
  filter(PARAMCD == "SDIAM", !is.na(PCHG), ARM != "Screen Failure") |>
  slice_min(PCHG, by = USUBJID, with_ties = FALSE) |>
  mutate(ARM = factor(ARM, levels = arm_levels)) |>
  arrange(PCHG) |>
  mutate(SUBJ_ORDER = row_number())

Plot Construction

waterfall_plot <- ggplot(
  waterfall_data,
  aes(x = reorder(USUBJID, PCHG), y = PCHG, fill = ARM)
) +
  geom_col(width = 0.7) +
  geom_hline(yintercept = -30, linetype = "dashed", color = "red", linewidth = 0.5) +
  geom_hline(yintercept = 20, linetype = "dashed", color = "blue", linewidth = 0.5) +
  scale_fill_manual(values = setNames(arm_colors, arm_levels)) +
  labs(x = "Subject", y = "Best % Change from Baseline", fill = "Treatment") +
  theme_minimal(base_size = 11) +
  theme(
    axis.text.x = element_text(angle = 90, hjust = 1, size = 7),
    legend.position = "bottom",
    panel.grid.major.x = element_blank()
  ) +
  annotate("text", x = 1, y = -32, label = "PR threshold (-30%)",
           hjust = 0, size = 3, color = "red") +
  annotate("text", x = 1, y = 22, label = "PD threshold (20%)",
           hjust = 0, size = 3, color = "blue")

arframe Pipeline

waterfall_plot |>
  fr_figure(width = 7, height = 5) |>
  fr_titles(
    "Figure 14.2.3",
    "Waterfall Plot for Best Percentage Change of Target Lesion from Baseline",
    "Efficacy Population"
  ) |>
  fr_footnotes(
    "Each bar represents one subject's best percentage change from baseline in sum of target lesion diameters.",
    "Dashed red line = PR threshold (-30%); dashed blue line = PD threshold (+20%).",
    "RECIST 1.1 criteria."
  )

Rendered Figure

Figure 14.2.3
Waterfall Plot for Best Percentage Change of Target Lesion from Baseline
Efficacy Population
figure
Each bar represents one subject's best percentage change from baseline in sum of target lesion diameters.
Dashed red line = PR threshold (-30%); dashed blue line = PD threshold (+20%).
RECIST 1.1 criteria.
/opt/quarto/share/rmd/rmd.R 01APR2026 09:50:37
Source Code
---
title: "Waterfall Plot"
subtitle: "Best Percentage Change from Baseline in Target Lesion"
execute:
  echo: true
  eval: true
---


```{r}
#| label: prereqs
#| include: false
library(arframe)
fr_theme(hlines = "header", font_family = "Courier New")
```

## Setup

See [Prerequisites](../install.qmd) for installation instructions.

```{r}
#| label: setup
library(arframe)
library(ggplot2)
library(pharmaverseadam)
library(dplyr, warn.conflicts = FALSE)

arm_levels <- c("Placebo", "Xanomeline Low Dose", "Xanomeline High Dose")
arm_colors <- c("#1b9e77", "#d95f02", "#7570b3")

# Best % change from baseline per subject (sum of target lesion diameters)
waterfall_data <- pharmaverseadam::adtr_onco |>
  filter(PARAMCD == "SDIAM", !is.na(PCHG), ARM != "Screen Failure") |>
  slice_min(PCHG, by = USUBJID, with_ties = FALSE) |>
  mutate(ARM = factor(ARM, levels = arm_levels)) |>
  arrange(PCHG) |>
  mutate(SUBJ_ORDER = row_number())
```


## Plot Construction

```{r}
#| label: build-plot

waterfall_plot <- ggplot(
  waterfall_data,
  aes(x = reorder(USUBJID, PCHG), y = PCHG, fill = ARM)
) +
  geom_col(width = 0.7) +
  geom_hline(yintercept = -30, linetype = "dashed", color = "red", linewidth = 0.5) +
  geom_hline(yintercept = 20, linetype = "dashed", color = "blue", linewidth = 0.5) +
  scale_fill_manual(values = setNames(arm_colors, arm_levels)) +
  labs(x = "Subject", y = "Best % Change from Baseline", fill = "Treatment") +
  theme_minimal(base_size = 11) +
  theme(
    axis.text.x = element_text(angle = 90, hjust = 1, size = 7),
    legend.position = "bottom",
    panel.grid.major.x = element_blank()
  ) +
  annotate("text", x = 1, y = -32, label = "PR threshold (-30%)",
           hjust = 0, size = 3, color = "red") +
  annotate("text", x = 1, y = 22, label = "PD threshold (20%)",
           hjust = 0, size = 3, color = "blue")
```


## arframe Pipeline

```{r}
#| label: pipeline
#| eval: false
waterfall_plot |>
  fr_figure(width = 7, height = 5) |>
  fr_titles(
    "Figure 14.2.3",
    "Waterfall Plot for Best Percentage Change of Target Lesion from Baseline",
    "Efficacy Population"
  ) |>
  fr_footnotes(
    "Each bar represents one subject's best percentage change from baseline in sum of target lesion diameters.",
    "Dashed red line = PR threshold (-30%); dashed blue line = PD threshold (+20%).",
    "RECIST 1.1 criteria."
  )
```


## Rendered Figure

```{r}
#| label: rendered-figure
#| echo: false
#| ref.label: pipeline
```

Open-source TFL reference collection

 

CDISC Pilot Study (CDISCPILOT01) • pharmaverseadam datasets