Package {impower133}


Type: Package
Title: Reproduce IMpower133 Clinical Trial Results
Version: 1.0.0
Description: Provides functions to simulate baseline characteristics, reconstruct overall survival data from published Kaplan-Meier curves, and generate publication-ready tables and forest plots reproducing the IMpower133 clinical trial results (Horn et al., 2018, <doi:10.1056/NEJMoa1809064>). The IPD reconstruction method is based on Liu et al.(2021, <doi:10.1186/s12874-021-01308-8>).
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: dplyr, survival, survminer, gt, forestplot, IPDfromKM, ggplot2, stats, utils, grid
SystemRequirements: GNU make
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
URL: https://github.com/fanfande131/impower133
BugReports: https://github.com/fanfande131/impower133/issues
NeedsCompilation: no
Packaged: 2026-06-05 18:10:45 UTC; 总行是只煤球
Author: Lu Huang [aut, cre], Wenkai Nie [aut], Qingyang Jiang [aut], Qinxin Chen [aut]
Maintainer: Lu Huang <2998785392@qq.com>
Repository: CRAN
Date/Publication: 2026-06-11 12:20:07 UTC

Analyze survival data and print key statistics

Description

Analyze survival data and print key statistics

Usage

analyze_survival(ipd_data, type = c("OS", "PFS"), times = 12)

Arguments

ipd_data

Reconstructed data frame or CSV path

type

"OS" or "PFS"

times

Landmark time point in months, default 12

Value

A list of key statistics (invisibly)


Generate Table 1: Baseline characteristics

Description

Create a publication-ready baseline characteristics table using the gt package, formatted to match the original IMpower133 publication style.

Usage

make_table1(data)

Arguments

data

Data frame from simulate_impower133()

Value

A gt table object


Generate Table 2: Response rate and disease progression

Description

Create a publication-ready table summarizing objective response rate, duration of response, and disease progression outcomes using the gt package.

Usage

make_table2(data)

Arguments

data

Data frame from simulate_impower133()

Value

A gt table object


Generate Table 3: Adverse events

Description

Create a publication-ready adverse events table summarizing treatment-related adverse events by grade in the as-treated population, using the gt package.

Usage

make_table3(data)

Arguments

data

Data frame from simulate_impower133()

Value

A gt table object


Plot Figure 2C: Subgroup forest plot

Description

Calculate hazard ratios for each subgroup based on simulated baseline data merged with reconstructed OS data, and generate a forest plot in the original IMpower133 publication style.

Usage

plot_figure2c(data, output_path = "figure2c.png")

Arguments

data

Data frame from simulate_impower133() with os_path specified

output_path

Path to output image file, default "figure2c.png"

Value

No return value, saves image to output_path


Plot survival K-M curve

Description

Plot survival K-M curve

Usage

plot_survival(
  ipd_data,
  type = c("OS", "PFS"),
  output_path = tempfile(fileext = ".png"),
  width = 10,
  height = 6
)

Arguments

ipd_data

Reconstructed data frame or CSV path

type

"OS" or "PFS"

output_path

Path to output image file

width, height

Image dimensions in inches

Value

No return value, called for side effects (saves a plot to file).


Reconstruct individual patient data from K-M curves

Description

Use IPDfromKM to extract coordinates from published Kaplan-Meier curves and reconstruct individual patient data (IPD).

Usage

reconstruct_survival(
  img_path,
  trisk,
  nrisk_control,
  nrisk_treatment,
  x1 = 0,
  x2 = 21,
  y1 = 0,
  y2 = 1,
  output_csv = tempfile(fileext = ".csv"),
  type = c("OS", "PFS")
)

Arguments

img_path

Path to K-M curve image

trisk

Vector of risk time points

nrisk_control

Number at risk for control group

nrisk_treatment

Number at risk for treatment group

x1, x2

X-axis range (actual values)

y1, y2

Y-axis range (actual values)

output_csv

Path to output CSV file

type

"OS" or "PFS"

Value

A data frame with columns time, status, arm (invisibly)


Objects exported from other packages

Description

These objects are imported from other packages. Follow the links below to see their documentation.

dplyr

%>%


Triangular distribution random number generator

Description

Generate random numbers following a triangular distribution, useful for simulating continuous variables whose median is not at the center of the range.

Usage

rtriang(n, min_val, mode_val, max_val)

Arguments

n

Sample size

min_val

Minimum value

mode_val

Mode (peak location)

max_val

Maximum value

Value

A numeric vector of length n

Examples

rtriang(100, 28, 64, 90)

Simulate IMpower133 complete ITT population

Description

Simulate 403 virtual patients' baseline characteristics, efficacy outcomes, and safety data based on published summary statistics from Tables 1-3.

Usage

simulate_impower133(
  seed = 21,
  os_path = NULL,
  pfs_path = NULL,
  method = c("risk_score", "random"),
  output_path = tempfile(fileext = ".csv")
)

Arguments

seed

Random seed, default 21

os_path

Path to reconstructed OS data CSV (optional)

pfs_path

Path to reconstructed PFS data CSV (optional)

method

Matching method: "random" or "risk_score" (default)

output_path

Path to save output CSV

Value

A data.frame with 403 rows and all variables (invisibly)

Examples


df <- simulate_impower133()
head(df)