KM生存分析
如何取最佳cutoff
KM生存分析中通常取中位值作为cutoff,但也并不一定是这样
必要时可以选择最佳的cutoff值,如何实现? ### survival package
library(survival)
library(survminer)
surv_cutpoint函数
data:包含生存数据和连续变量的的数据框
time, event:column names containing time and event data, respectively. Event values sould be 0 or 1.
# 0. Load some data
data(myeloma)
head(myeloma)
1. Determine the optimal cutpoint of variables
res.cut<-surv_cutpoint(myeloma,time="time",event="event",variables=c("DEPDC1","WHSC1","CRIM1"))
2. Plot cutpoint for DEPDC1
plot(res.cut,"DEPDC1",palette="npg")
3. Categorize variables
res.cat <- surv_categorize(res.cut)
head(res.cat)
4. Fit survival curves and visualize
library("survival")
fit <- survfit(Surv(time, event) ~DEPDC1, data = res.cat)
ggsurvplot(fit, data = res.cat, risk.table = TRUE, conf.int = TRUE)