sig_surv_plot: Generate Kaplan-Meier Survival Plot for Signature

View source: R/sig_surv_plot.R

sig_surv_plotR Documentation

Generate Kaplan-Meier Survival Plot for Signature

Description

Creates Kaplan-Meier survival plots for a given signature or gene, with automatic cutoff determination. Generates three types of plots: optimal cutoff (best cutoff), tertile-based (3 groups), and median split (2 groups).

Usage

sig_surv_plot(
  input_pdata,
  signature,
  project = "KM",
  ID = "ID",
  time = "time",
  status = "status",
  time_type = "month",
  break_month = "auto",
  cols = NULL,
  palette = "jama",
  show_col = TRUE,
  mini_sig = "score",
  fig.type = "png",
  save_path = NULL,
  index = 1
)

Arguments

input_pdata

Data frame with survival data and signature scores.

signature

Character string. Column name of the target signature.

project

Character string. Project name for output. Default is '"KM"'.

ID

Character string. Column name for sample IDs. Default is '"ID"'.

time

Character string. Column name for survival time. Default is '"time"'.

status

Character string. Column name for survival status. Default is '"status"'.

time_type

Character string. Time unit ('"month"' or '"day"'). Default is '"month"'.

break_month

Numeric or '"auto"'. Time axis breaks. Default is '"auto"'.

cols

Character vector. Optional custom colors.

palette

Character string. Color palette if 'cols' not provided. Default is '"jama"'.

show_col

Logical indicating whether to show colors. Default is 'TRUE'.

mini_sig

Character string. Label for low score group. Default is '"score"'.

fig.type

Character string. File format. Default is '"png"'.

save_path

Character string or 'NULL'. Directory for saving plots. If 'NULL', plots are not saved. Default is 'NULL'.

index

Integer. Index for multiple plots. Default is '1'.

Value

A list containing:

data

Processed input data with group assignments

plots

Combined survival plots

Author(s)

Dongqiang Zeng

Examples

# Create small example data
set.seed(123)
test_data <- data.frame(
  time = runif(100, 0, 100),
  OS_status = sample(c(0, 1), 100, replace = TRUE),
  TMEscore_plus = rnorm(100),
  ID = paste0("S", 1:100)
)
sig_surv_plot(
  input_pdata = test_data,
  signature = "TMEscore_plus",
  time = "time",
  status = "OS_status"
)

IOBR documentation built on May 30, 2026, 5:07 p.m.