draw_survival_curve: draw survival curve

View source: R/utils.R

draw_survival_curveR Documentation

draw survival curve

Description

Draw a survival curve based on survminer package. This is a wrapper function of ggsurvplot.

Usage

draw_survival_curve(
  exp,
  living_days,
  living_events,
  write_name,
  title_name = "",
  threshold = NA,
  file = FALSE
)

Arguments

exp

expression level for variable.

living_days

The survival time (days) for each individual.

living_events

The survival event for each individual, 0 indicates alive and 1 indicates death. Other choices are TRUE/FALSE (TRUE = death) or 1/2 (2=death). For interval censored data, the status indicator is 0=right censored, 1=event at time, 2=left censored, 3=interval censored.

write_name

The name for pdf file which contains the result figure.

title_name

The title for the result figure.

threshold

Threshold used to indicate the high risk or low risk.

file

If True, function will automatic generate a result pdf, otherwise it will return a ggplot object. Default is FALSE.

Value

This function will generate a pdf file with 300dpi which compare survival curves using the Kaplan-Meier (KM) test.

Author(s)

Xin Yu

Examples

data(demo_survival_data)
library(survival)
demo_set<-create_demo()
draw_survival_curve(demo_set[1,],
    living_days = demo_survival_data[,1],
    living_events =demo_survival_data[,2],
    write_name = "demo_data" )


whirlsyu/EnMCB documentation built on Jan. 25, 2023, 4:33 a.m.