plot_survival: Survival Curve(s)

View source: R/plot_survival.R

plot_survivalR Documentation

Survival Curve(s)

Description

This function plots one or several survival curves for a given time-to-event model.

Usage

plot_survival(
  fit,
  fun = NULL,
  CI = FALSE,
  censor = TRUE,
  pal_curves = "npg",
  title = ifelse(is.null(fit$strata), "Survival Curve", "Survival Curves"),
  leg.txt = NULL,
  legend = "right",
  ...
)

Arguments

fit

An object of class survfit.

fun

An arbitrary function defining a transformation of the survival curve(s). Common transformations can be specified with a character argument, e.g. "event" for cumulative events, "cumhaz" for the cumulative hazard function, or "pct" for survival probability as a percentage.

CI

Plot confidence intervals?

censor

Include tick-marks to indicate censored subjects?

pal_curves

String specifying the color palette to use when plotting multiple vectors. Options include "ggplot", all qualitative color schemes available in RColorBrewer, and the complete collection of ggsci palettes. Alternatively, a character vector of colors with length equal to the number of strata in fit.

title

Optional plot title.

leg.txt

Optional legend title.

legend

Legend position. Must be one of "bottom", "left", "top", "right", "bottomright", "bottomleft", "topleft", or "topright".

...

Additional arguments to be passed to ggsurvplot.

Details

Survival curves visualize the fit of a time-to-event model, e.g. a Kaplan-Meier estimator or a Cox proportional hazards regression. They are an essential tool in survival analysis, providing a simple and intuitive visual summary of the relative risk associated with different conditions.

plot_survival is a lightweight wrapper for the ggsurvplot function from the survminer package, which offers an impressive array of customization options for plotting survival curves. plot_survival alters the default output of ggsurvplot to align it with that of other figures generated by bioplotr, but you can override those settings and/or take advantage of extra ggsurvplot functionalities by passing additional arguments to plot_survival.

References

Andersen, P. & Gill, R. (1982). Cox's regression model for counting processes, a large sample study. Annals of Statistics, 10, 1100-1120.

Cox, D.R. (1972). Regression Models and Life-Tables. J. R. Stat. Soc., Series B, 34(2): 187-220.

Kaplan, E.L. & Meier, P. (1958). Nonparametric estimation from incomplete observations. J. Amer. Stat. Assn., 53(282): 457-481.

Examples

library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
plot_survival(fit)


dswatson/bioplotr documentation built on March 3, 2023, 9:43 p.m.