画画生存分析图

作者: 小洁忘了怎么分身 | 来源:发表于2019-03-26 23:26 被阅读337次

    用包自带的数据lung来做

    library("survival")
    library("survminer")
    data("lung")
    head(lung)
    #>   inst time status age sex ph.ecog ph.karno pat.karno meal.cal wt.loss
    #> 1    3  306      2  74   1       1       90       100     1175      NA
    #> 2    3  455      2  68   1       0       90        90     1225      15
    #> 3    3 1010      1  56   1       0       90        90       NA      15
    #> 4    5  210      2  57   1       1       90        60     1150      11
    #> 5    1  883      2  60   1       0      100        90       NA       0
    #> 6   12 1022      1  74   1       1       50        80      513       0
    

    作图前一步都是survfit

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

    最简单的

    ggsurvplot(fit)
    

    显示p值

    ggsurvplot(fit, pval = TRUE)
    

    修改线型

    ggsurvplot(fit, pval = TRUE, linetype = "dashed")
    

    显示置信区间

    ggsurvplot(fit, pval = TRUE,
               conf.int = T,
               conf.int.style="ribbon",
               conf.int.alpha=0.1)
    

    修改颜色

    ggsurvplot(fit, pval = TRUE, 
               conf.int = T,conf.int.style="ribbon",conf.int.alpha=0.1,
               palette =c("blue","red"))
    

    修改图例

    ggsurvplot(fit, pval = TRUE, linetype = "dashed",  
               conf.int = T,conf.int.style="ribbon",conf.int.alpha=0.1,
               palette =c("blue","red"),
               legend.title="",legend=c(0.7,0.9),legend.labs=c("Male","Female"))
    

    再复杂一点

    ggsurvplot(fit, data = lung,pval = TRUE,
               palette = c("#E7B800", "#2E9FDF"),
               legend.title = "Sex",legend.labs = c("Male", "Female"),
               conf.int = TRUE,
               surv.median.line = "hv",
               risk.table = TRUE,tables.height = 0.2,tables.theme = theme_cleantable(),
               ggtheme = theme_bw()
    )
    

    相关文章

      网友评论

        本文标题:画画生存分析图

        本文链接:https://www.haomeiwen.com/subject/ttbovqtx.html