Generates a comprehensive forest plot showing:
ITT (Intent-to-Treat) population estimate
Reference subgroups (e.g., by biomarker levels)
Post-hoc identified subgroups with bias-corrected estimates
Cross-validation agreement metrics as annotations
plot_subgroup_results_forestplot(
fs_results,
df_analysis,
subgroup_list = NULL,
outcome.name,
event.name,
treat.name,
E.name = "Experimental",
C.name = "Control",
est.scale = "hr",
xlog = TRUE,
title_text = NULL,
arrow_text = c("Favors Experimental", "Favors Control"),
footnote_text = c("Eg 80% of training found SG: 70% of B (+) also B in CV testing"),
xlim = c(0.25, 1.5),
ticks_at = c(0.25, 0.7, 1, 1.5),
show_cv_metrics = TRUE,
cv_source = c("auto", "kfold", "oob", "both"),
posthoc_colors = c("powderblue", "beige"),
reference_colors = c("yellow", "powderblue"),
ci_column_spaces = 20,
conf.level = 0.95,
theme = NULL
)A list containing:
The forestploter grob object (can be rendered with plot())
The data frame used for the forest plot
Character vector of row types for styling reference
Cross-validation metrics text (if available)
List. A list containing ForestSearch analysis results with elements:
fs.est: ForestSearch estimation object from forestsearch
fs_bc: Bootstrap bias-corrected results from
forestsearch_bootstrap_dofuture
fs_kfold: K-fold cross-validation results from
forestsearch_Kfold or forestsearch_tenfold (optional)
fs_OOB: Out-of-bag cross-validation results (optional, alternative to fs_kfold)
Data frame. The analysis dataset with outcome, event, and treatment variables.
List. Named list of subgroup definitions to include in the plot. Each element should be a list with:
subset_expr: Character string for subsetting (e.g., "BM> 1")
name: Display name for the subgroup
type: Either "reference" for pre-specified or "posthoc" for identified
Character. Name of the survival time variable.
Character. Name of the event indicator variable.
Character. Name of the treatment variable.
Character. Label for experimental arm (default: "Experimental").
Character. Label for control arm (default: "Control").
Character. Estimate scale: "hr" or "1/hr" (default: "hr").
Logical. If TRUE (default), the x-axis is plotted on a logarithmic scale. This is standard for hazard ratio forest plots where equal distances represent equal relative effects.
Character. Plot title (default: NULL).
Character vector of length 2. Arrow labels for forest plot (default: c("Favors Experimental", "Favors Control")).
Character vector. Footnote text for the plot explaining CV metrics (default provides CV interpretation guidance; set to NULL to omit).
Numeric vector of length 2. X-axis limits (default: c(0.25, 1.5)).
Numeric vector. X-axis tick positions (default: c(0.25, 0.70, 1.0, 1.5)).
Logical. Whether to show cross-validation metrics (default: TRUE if fs_kfold or fs_OOB available).
Character. Source for CV metrics: "auto" (default, uses both if available, otherwise whichever is present), "kfold" (use fs_kfold only), "oob" (use fs_OOB only), or "both" (explicitly use both fs_kfold and fs_OOB, with K-fold first then OOB).
Character vector. Colors for post-hoc subgroup rows (default: c("powderblue", "beige")).
Character vector. Colors for reference subgroup rows (default: c("yellow", "powderblue")).
Integer. Number of spaces for the CI plot column width. More spaces = wider CI column (default: 20).
Numeric. Confidence level for intervals (default: 0.95 for 95% CI). Used to calculate the z-multiplier as qnorm(1 - (1 - conf.level)/2).
An fs_forest_theme object from create_forest_theme().
Use this to control plot sizing (fonts, row height, CI appearance,
CV annotation font size). Default: NULL (uses default theme).
Creates a publication-ready forest plot displaying identified subgroups with hazard ratios, bias-corrected estimates, and cross-validation metrics. This wrapper integrates ForestSearch results with the forestploter package.
ForestSearch identifies subgroups based on hazard ratio thresholds:
sg.harm: Contains the definition of the "harm" or "questionable"
subgroup (H)
treat.recommend == 0: Patient is IN the harm subgroup (H)
treat.recommend == 1: Patient is in the COMPLEMENT subgroup
(Hc, typically benefit)
For est.scale = "hr" (searching for harm):
H (treat.recommend=0): Subgroup defined by sg.harm with elevated HR (harm/questionable)
Hc (treat.recommend=1): Complement of sg.harm (potential benefit)
For est.scale = "1/hr" (searching for benefit):
Roles are reversed: H becomes the benefit group
forestsearch for running the subgroup analysis
forestsearch_bootstrap_dofuture for bootstrap bias correction
forestsearch_Kfold for cross-validation
create_forest_theme for customizing plot appearance
render_forestplot for rendering the plot