使用 R 中的 survminer 包 (ggsurvplot) 更改截尾事件的形状

Changing the shape of Censored Events using the survminer package (ggsurvplot) in R

我正在使用 survminer 包在 R 中创建 Kaplan-Meier-Curve,效果很好:

plotUICC=survfit(Surv(as.numeric(myData$eventtime),event=myData$eventtype)~myData$UICC, data = myData)

ggsurvplot(plotUICC,data=myData, risk.table = FALSE,pval = TRUE,conf.int = FALSE,legend.labs = c("UICC I", "UICC II"),legend = c(0.25, 0.26),legend.title = "",xlab = "Time in Months"))

Kaplan Meier Curve created with the Cod above

我想将“+”更改为审查事件并使用简单的“|”反而。不幸的是,help(ggsurvplot) 和 google 都无法帮助我。


这些是加载的包:

    other attached packages:
[1] ggthemes_3.4.0  survminer_0.3.1 ggpubr_0.1.2    ggplot2_2.2.1   survival_2.40-1
[6] readxl_0.1.1    gridExtra_2.2.1

一个最小的工作示例如下:

library(survminer)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
p1 <- ggsurvplot(fit, data = lung)

理想情况下,人们想要改变审查员的形状,例如像这样:

p2 <- ggsurvplot(fit, data = lung, censor.shape=124)

我发现无法使用原始的 survminer 包执行此操作。在 survminer 的 fork 中,我实现了这种行为,因此产生了以下情节:

censor.shape 的可接受值可在此处找到: http://sape.inf.usi.ch/quick-reference/ggplot2/shape

我还没有彻底测试过这个,但这个扩展对我来说已经非常有用了。 “+”审查员困扰了我一段时间...

编辑:此建议现已合并,ggsurvplot 的 development version 现在接受 censor.shape 和 censor.size 参数:

ggsurvplot(fit, data = lung, censor.shape="|", censor.size = 4)