问题描述
我将以下代码用于从本网站(link)获得的竞争风险。 这是我的dataframe。
我想
- 为生成的Kaplan Meier曲线添加95%的置信区间以应对竞争风险 我用谷歌搜索,但无法弄清楚。我知道如何将95%CI添加到常规KM曲线中,但不能与风险相关的KM曲线竞争。
- 使x轴的终点为120个月,而不会危及处于危险状态的患者(我以常规方式这样做,但是错过了处于危险状态的患者数量)。
感谢您的帮助与合作
#=======================================================================
## Late reop
library(survival);library(survminer);library(Hmisc);library(ggplot2)
ci_ulcer <- cuminc(data$OS.reop.months,data$status_dead1_reop2,data$Groups_Extensive1.Conservative0,cencode = 0 ); ci_ulcer[["Tests"]]
##=======================================================================
ciplotdat2 <-
ci_ulcer %>%
list_modify("Tests" = NULL) %>%
map_df(`[`,c("time","est"),.id = "id") %>%
filter(id %in% c("0 2","1 2")) %>%
mutate(Approach = recode(
id,"0 2" = "Conservative","1 2" = "Extensive"))
##=======================================================================
## Add the numbers at risk table
mel_plot <- ggplot(ciplotdat2,aes(x = time,y = est,color = Approach)) +
geom_step(lwd = 1.2) +
ylim(c(0,1)) +
#coord_cartesian(xlim = c(0,120)) +
scale_x_continuous(breaks = seq(0,260,24)) +
geom_step(size = 1.5) + theme_classic() +
theme(plot.title = element_text(size = 14),legend.title = element_blank(),legend.position = "bottom") +
labs(x = "Months",y = "Cumulative incidence",title = "Late reoperation by Approach") +
annotate("text",x = 0,y = 1,hjust = 0,label = paste0(
"p-value = ",ifelse(ci_ulcer$Tests[2,2] < .001,"<.001",round(ci_ulcer$Tests[2,2],3))))
#=============================================================
mel_fit <- survfit(Surv(data$OS.reop.months,ifelse(data$status_dead1_reop2 != 0,1,0)) ~ Groups_Extensive1.Conservative0,data = data)
num <- ggsurvplot(fit = mel_fit,risk.table = T,risk.table.y.text = F,ylab = "Months",break.x.by =24,xscale = "m_y",# will transform labels from months to years
tables.theme = theme_cleantable( ),#?theme_cleantable
#tables.theme = theme_survminer(font.main = 10),risk.table.fontsize = 3,data=data)
cowplot::plot_grid(mel_plot,num$table,nrow = 2,rel_heights = c(4,1),align = "v",axis = "b")
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)