在同一图中合并多个(> 2)生存曲线(空模型)

发布于 2025-01-11 01:15:34 字数 2363 浏览 0 评论 0原文

我正在尝试使用 survminer 包中的函数 ggsurvplot_combine 将多个 survfit 对象组合在同一个绘图上。当我列出 2 个 survfit 对象的列表时,它完美地工作了。但是,当我以不同的方式组合 3 个 survfit 对象时,我收到错误:

级别错误 - (tmp value = as.character(levels)):因子级别 3 重复

我读过类似的帖子关于组合生存图(https://cran.r-project.org/web/packages/survminer/survminer.pdfhttps://github.com/kassambara/survminer/issues/195R 在同一图中绘制多条生存曲线, https://rpkgs.datanovia.com/survminer/reference/ggsurvplot_combine.html)并针对此特定错误,使用“unique”提供了解决方案。然而,我什至不明白这个错误是由哪个因素变量引起的。我无权分享我的数据或数字,因此我将尝试复制它:

  1. 数据:
  • 时间:直到事件或后续
  • 端点结束之间的后续行动:1=事件,0=无事件或审查
  1. 空模型:
  • KM1 <- survfit(Surv(data$time1,data$endpoint1)~1,
    type="kaplan-meier", conf.type="log", data=data)
  • KM2 <- survfit(Surv(data$time2,data$endpoint2)~1, type="kaplan-meier",
    conf.type="log", data=data)
  • KM3 <- survfit(Surv(data$time3,data$endpoint3)~1, type="kaplan-meier",
    conf.type="log", data=data)
  1. 列出空模型:
  • list_that_works <- list(KM1,KM3)
  • list_that_fails <- list(KM1,KM2,KM3) 列表似乎只包含两个参数:list(PFS=, OS=)
  1. 将 >2 个空模型合并到一个图中:

ggsurvplot_combine(list_that_works, data=data, conf. int = TRUE,fun =“事件”,combine = TRUE) 这给出了我正在寻找的图,但有 2 条累积发生率曲线

ggsurvplot_combine(list_that_fails,data = data,conf.int = TRUE,fun =“event”,combine = TRUE) 这会给出错误“级别错误 - (tmp value = as.character(levels)): 因子级别 3 重复”。

当我尝试使用 using 组合 3 个图时 ggsurvplot(c(KM1,KM2,KM3), data=data, conf.int=TRUE, fun="event",combine=TRUE)给出错误:

错误:mutate() '列 'survsummary' 出现问题 survsummary = purrr::map2(grouped.d$fit, grouped.d$name, .surv_summary, data=data'.x $ 运算符对于原子向量无效。

非常感谢任何帮助! 另外,另一种结合 surv 适合的方式也非常受欢迎! 我最好的选择是它与仅包含两个参数的“列表”函数有关:list(PFS=, OS=)

I am trying to combine multiple survfit objects on the same plot, using function ggsurvplot_combine from package survminer. When I made a list of 2 survfit objects, it perfectly works. But when I combine 3 survfit objects in different ways, I receive the error:

error in levels - ( tmp value = as.character(levels)): factor level 3 is duplicated

I've read similar posts on combining survivl plots (https://cran.r-project.org/web/packages/survminer/survminer.pdf, https://github.com/kassambara/survminer/issues/195, R plotting multiple survival curves in the same plot, https://rpkgs.datanovia.com/survminer/reference/ggsurvplot_combine.html) and on this specific error, for which solutions are been provided with using 'unique'. However, I do not even understand for which factor variable this error accounts. I do not have the right to share my data or figures, so I'll try to replicate it:

  1. Data:
  • time: follow-up between untill event or end of follow-up
  • endpoints: 1= event, 0=no event or censor
  1. Null models:
  • KM1 <- survfit(Surv(data$time1,data$endpoint1)~1,
    type="kaplan-meier", conf.type="log", data=data)
  • KM2 <- survfit(Surv(data$time2,data$endpoint2)~1, type="kaplan-meier",
    conf.type="log", data=data)
  • KM3 <- survfit(Surv(data$time3,data$endpoint3)~1, type="kaplan-meier",
    conf.type="log", data=data)
  1. List null models:
  • list_that_works <- list(KM1,KM3)
  • list_that_fails <- list(KM1,KM2,KM3)
    It seems as if the list contains of just two arguments: list(PFS=, OS=)
  1. Combine >2 null models in one plot:

ggsurvplot_combine(list_that_works, data=data, conf.int=TRUE, fun="event", combine=TRUE)
This gives the plot I'm looking for, but with 2 cumulative incidence curves.

ggsurvplot_combine(list_that_fails, data=data, conf.int=TRUE, fun="event", combine=TRUE)
This gives error 'error in levels - ( tmp value = as.character(levels)): factor level 3 is duplicated'.

When I try combining 3 plots with using
ggsurvplot(c(KM1,KM2,KM3), data=data, conf.int=TRUE, fun="event", combine=TRUE), it gives the error:

Error: Problem with mutate() 'column 'survsummary'
survsummary = purrr::map2(grouped.d$fit, grouped.d$name, .surv_summary, data=data'. x $ operator is invlid for atomic vectors.

Any help is highly appreciated!
Also another way to combine surv fits is very welcome!
My best bet is that it has something to do with the 'list' function that only contains of two arguments: list(PFS=, OS=)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦初启 2025-01-18 01:15:34

我修好了!我不会删除帖子,而是分享我的解决方案,它可能对其他人有帮助:

我制作了公式列表而不是空模型,所以:

formulas <- list(
KM1 = Surv(time1, endpoint1)~1, 
KM2 = Surv(time2, endpoint2)~1, 
KM3 = Surv(time3, endpoint3)~1)

我一次制作了 3 个公式的空模型:

fit <- surv_fit(formulas, data=data)
    

然后我用这个生存拟合做了一个情节:

ggsurvplot_combine(fit, data=data)
    

I fixed it! Instead of removing the post, I'll share my solution, it may be of help for others:

I made a list of the formulas instead of the null models, so:

formulas <- list(
KM1 = Surv(time1, endpoint1)~1, 
KM2 = Surv(time2, endpoint2)~1, 
KM3 = Surv(time3, endpoint3)~1)

I made a null model of the 3 formulas at once:

fit <- surv_fit(formulas, data=data)
    

Then I made a plot with this survival fit:

ggsurvplot_combine(fit, data=data)
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文