如何用 3 个图制作 Kaplan-Meier 生存曲线

问题描述 投票:0回答:1

enter image description here我对 R studio 非常陌生,目前正在学习如何制作 Kaplan-Meier 生存曲线。 我使用 TCGA-LIHC 队列来可视化按 2 个基因(PTPRC、FOXP3)分类的 3 个亚型(层)的生存曲线。 现在,我可以单独制作生存曲线,但我不知道如何在 R studio 上编写 3 个图,例如为 PTPRC 高 FOXP3 低制作组 subtype1 等等。 我为我的问题添加了示例图像。我希望其他人可以帮助我。

我正在考虑按中值对它们进行分组(高表示高于中值,低表示低于中值),并且 subtype3 将是 PTPRC 低。 分组完成后,也许我可以处理其中的临床数据。

r bioinformatics survival-analysis survival
1个回答
0
投票

图书馆(生存) 库(ggplot2)

加载数据

数据(tcga_lihc)

创建 Kaplan-Meier 生存对象

亚型1 <- survfit(Surv(time, status) ~ PTPRC, data=tcga_lihc) subtype2 <- survfit(Surv(time, status) ~ FOXP3, data=tcga_lihc) subtype3 <- survfit(Surv(time, status) ~ 1, data=tcga_lihc)

绘制生存曲线

ggplot() + geom_step(data=subtype1, aes(x=时间, y=surv, color="PTPRC 高")) + geom_step(data=subtype2, aes(x=时间, y=surv, color="FOXP3 低")) + geom_step(data=subtype3, aes(x=时间, y=surv, color="PTPRC 低")) + scale_color_manual(值= c(“红色”,“蓝色”,“黑色”))+ labs(x="时间(天)", y="生存概率")

© www.soinside.com 2019 - 2024. All rights reserved.