hazrd is an R package for evaluating and visualizing Polygenic Hazard Score (PHS) analyses. It provides a consistent, tidy-first API for computing survival-based discrimination metrics, bootstrapped confidence intervals, and Kaplan-Meier curves.
Installation
Getting started
For a full introduction see the vignette on the hazrd pkgdown website.
Quick example
library(hazrd)
# Compute HR, C-index, OR, and HR_SD in one call
phs_metrics(
test_data,
metrics = c("HR", "C_index", "OR", "HR_SD"),
or_age = 70)
# Bootstrapped confidence intervals
phs_metrics(
test_data,
metrics = c("HR", "C_index"),
bootstrap = TRUE,
n_boot = 999,
seed = 42
)
# Kaplan-Meier plot with overlapping intervals (returns a ggplot object)
phs_km_curve(test_data)
# Overlapping intervals — top 5%, top 20%, bottom 20%
phs_km_curve(test_data, intervals = list(c(0.95, 1), c(0.80, 1), c(0, 0.20)))
# Legacy exclusive bands via breaks
km_data <- phs_km_curve(test_data, intervals = NULL, breaks = c(0.20, 0.40, 0.60, 0.80), output = "data")Planned features
The following are on the roadmap for future releases. Contributions welcome.
-
phs_abs_risk()— absolute (cumulative incidence) risk curves with competing risk support (km,aalen_johansen,fine_graymethods) -
phs_percentile()— compute percentile ranks; optionally relative to a reference population viaref_data -
phs_cut()— assign individuals to percentile strata with human-readable factor labels -
phs_describe()— descriptive statistics (n, events, median follow-up, PHS mean/SD) by stratum -
phs_calibration()— calibration plot and Hosmer-Lemeshow statistic -
theme_phs()/scale_color_phs()— default ggplot2 theme and colour scale for hazrd plots -
Uno’s C-index — IPCW-weighted concordance for heavily censored data (
cindex_method = "uno"inphs_metrics()) -
Parallel bootstrap —
parallel = "multicore"/"snow"viaboot::boot()(argument exists; only"no"is currently active) -
Risk table — numbers-at-risk appended below KM curves (
risk_table = TRUEinphs_km()) -
Alternative HR methods —
continuous_pointandcategorical(hr_methodargument inphs_metrics(); stubs exist)