ggsurvplot_combine R语言 一张图内画多条生存曲线

library(survival)
library(survminer)
#age 分组画生存曲线
fit <- survfit(Surv(time, status) ~ age, data = lung)
summary(fit)
res.cut <- surv_cutpoint(lung, time = "time", event = "status",
                         variables = "age")
summary(res.cut)
res.cat <- surv_categorize(res.cut)
fit_age <- survfit(Surv(time, status) ~age, data = res.cat)
ggsurvplot(fit_age,
           pval = TRUE, 
           #conf.int = TRUE,
           risk.table = TRUE, # Add risk table
           risk.table.col = "strata", # Change risk table color by groups
           surv.median.line = "hv", # Specify median survival
           ggtheme = theme_bw(), # Change ggplot2 theme
           legend.labs = 
             c("old", "young"),    # change legend labels.
           palette = c("#FF6103", "#3D9140")
)

ggsurvplot_combine R语言 一张图内画多条生存曲线

#wt.loss 分组画生存曲线
fit <- survfit(Surv(time, status) ~  wt.loss, data = lung)
summary(fit)
res.cut <- surv_cutpoint(lung, time = "time", event = "status",
                         variables = "wt.loss")
summary(res.cut)
res.cat <- surv_categorize(res.cut)
fit_wt <- survfit(Surv(time, status) ~ wt.loss, data = res.cat)
ggsurvplot(fit_wt,
           pval = TRUE, 
           #conf.int = TRUE,
           risk.table = TRUE, # Add risk table
           risk.table.col = "strata", # Change risk table color by groups
           surv.median.line = "hv", # Specify median survival
           ggtheme = theme_bw(), # Change ggplot2 theme
           legend.labs = 
             c("old", "young"),    # change legend labels.
           palette = c("blue", "pink")
)

ggsurvplot_combine R语言 一张图内画多条生存曲线

# sex
fit_sex = survfit(Surv(time, status) ~ sex, data =  lung)
ggsurvplot(fit_sex,
           pval = TRUE, 
           #conf.int = TRUE,
           risk.table = TRUE, # Add risk table
           risk.table.col = "strata", # Change risk table color by groups
           surv.median.line = "hv", # Specify median survival
           ggtheme = theme_bw(), # Change ggplot2 theme
           legend.labs = 
             c("old", "young"),    # change legend labels.
           palette = c("skyblue", "orange")
           )

ggsurvplot_combine R语言 一张图内画多条生存曲线

# 用ggsurvplot_combine画在一起
fitlist<-list(fit_age,fit_wt,fit_sex)
ggsurvplot_combine(fitlist,data = lung, ggtheme = theme_bw(),
                   palette=c("#FF6103", "#3D9140","blue", "pink","skyblue", "orange")) 

ggsurvplot_combine R语言 一张图内画多条生存曲线

上一篇:回溯法 解 1363 形成三的最大倍数


下一篇:YUM常用命令