英文:
How to get univariate + multivariate survival analysis with R?
问题
使用survminer
、ggplot2
和survival
包,我想要创建两个Kaplan Meier图:
- 一个用于单变量生存分析,使用
event_followup
表示时间至事件,event
表示事件状态,以及具有四个类别的scoreMVPA
,分别是no AF proc + inactive
、no AF proc + active
、AF proc + inactive
、AF proc + active
。 - 一个用于多变量生存分析,其中
sex
编码为(1表示女性,0表示男性),age
和match_RF_stroke
编码为(1表示是,0表示否)作为协变量。
我想要获取这两个KM图和风险表,只显示这四个类别。我正在使用ggsurvplot
,但我难以得到我的图。
谢谢!
以下是您的数据集示例:
structure(list(sex = c("Male", "Female", "Male", "Male", "Male",
"Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male",
"Male", "Male", "Male", "Male", "Male", "Male", "Male", "Male",
"Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Male", "Male", "Male", "Male", "Female", "Female",
"Male", "Female", "Female", "Male", "Male", "Female", "Female",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female",
"Male", "Male", "Female", "Female", "Male", "Male", "Female",
"Female", "Female", "Male", "Female", "Female", "Male", "Male",
"Female", "Male", "Female", "Male", "Male", "Male", "Male", "Male",
"Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Female", "Female", "Male", "Male", "Male", "Female",
"Male", "Male", "Female", "Male", "Male", "Female", "Male", "Male",
"Male", "Male", "Male", "Female", "Female", "Male", "Male", "Female",
"Female", "Male", "Male", "Female", "Male", "Male", "Female",
"Female", "Female", "Male", "Male", "Male", "Male", "Male", "Male",
"Male", "Female", "Female", "Male", "Male", "Male", "Male", "Male",
"Male", "Female", "Male", "Male", "Female", "Male", "Female",
"Male", "Male", "Male", "Female", "Male", "Male", "Male", "Male",
"Female", "Female", "Male", "Female", "Male", "Male", "Male",
"Male", "Male", "Male", "Female", "Female", "Male", "Male", "Male",
"Male", "Female", "Male", "Female", "Male", "Male", "Female",
"Female", "Male", "Male", "Female", "Male", "Male", "Female",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female",
"Male", "Male", "Female", "Male", "Female", "Male", "Male", "Male",
"Female", "Male", "Male", "Male", "Male", "Female", "Female",
"Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Female", "Male", "Male", "Male", "Male", "Female",
"Male", "Female", "Male", "Male", "Female", "Female", "Male",
"Male", "Female", "Male", "Male", "Female", "Female", "Male",
"Male", "Male", "Male", "Male", "Male", "Female", "Female", "Male",
"Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male",
"Female", "Male", "Male", "Female", "Female", "Male", "
<details>
<summary>英文:</summary>
Using the `survminer`, `ggplot2`, and `survival` packages, I would like to create two Kaplan Meier plots:
- One for **univariate** survival analysis with `event_followup` for the time to event, `event` for the status, and `scoreMVPA` that has four categories `no AF proc + inactive`, `no AF proc + active`, `AF proc + inactive`, `AF proc + active`.
- One for **multivariate** survival analysis with `sex` coded (1 for female and 0 for male), `age`, and `match_RF_stroke` coded (1 for yes, and 0 for no) as covariates.
I would like to get the KM plots + risk table with them that only show the four categories. I am using `ggsurvplot` but I am struggling to get my plot.
Thanks a lot!
Here is a sample of my dataset:
structure(list(sex = c("Male", "Female", "Male", "Male", "Male",
"Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male",
"Male", "Male", "Male", "Male", "Male", "Male", "Male", "Male",
"Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Male", "Male", "Male", "Male", "Female", "Female",
"Male", "Female", "Female", "Male", "Male", "Female", "Female",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female",
"Male", "Male", "Female", "Female", "Male", "Male", "Female",
"Female", "Female", "Male", "Female", "Female", "Male", "Male",
"Female", "Male", "Female", "Male", "Male", "Male", "Male", "Male",
"Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Male",
"Female", "Female", "Female", "Male", "Male", "Male", "Female",
"Male", "Male", "Female", "Male", "Male", "Female", "Male", "Male",
"Male", "Male", "Male", "Female", "Female", "Male", "Male", "Female",
"Female", "Male", "Male", "Female", "Male", "Male", "Female",
"Female", "Female", "Male", "Male", "Male", "Male", "Male", "Male",
"Male", "Female", "Male", "Male", "Female", "Male", "Female",
"Male", "Male", "Male", "Female", "Male", "Male", "Male", "Male",
"Female", "Female", "Male", "Female", "Male", "Male", "Male",
"Male", "Male", "Male", "Female", "Female", "Male", "Male", "Male",
"Male", "Female", "Male", "Female", "Male", "Male", "Female",
"Female", "Male", "Male", "Female", "Male", "Male", "Female",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female",
"Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female",
"Male", "Male", "Female", "Male", "Male", "Female", "Female",
"Male", "Male", "Female", "Female", "Female", "Female"), age = c(41,
58, 63, 65, 62, 66, 68, 48, 68, 59, 63, 67, 64, 66, 52, 52, 69,
64, 61, 67, 65, 67, 61, 62, 58, 54, 53, 66, 67, 67, 64, 65, 64,
69, 63, 51, 67, 65, 68, 64, 65, 58, 62, 65, 67, 63, 60, 52, 69,
69, 54, 53, 55, 68, 61, 46, 67, 67, 57, 55, 61, 65, 61, 66, 48,
47, 69, 55, 58, 69, 64, 53, 65, 64, 62, 68, 64, 65, 60, 58, 54,
43, 51, 69, 60, 69, 70, 64, 59, 65, 61, 69, 67, 63, 69, 58, 55,
61, 63, 64, 65, 69, 62, 69, 61, 65, 60, 53, 41, 56, 61, 65, 65,
68, 65, 51, 69, 52, 61, 54, 44, 63, 55, 62, 62, 68, 54, 63, 41,
69, 67, 50, 65, 60, 59, 67, 66, 61, 67, 47, 63, 66, 65, 64, 57,
52, 65, 65, 60, 44, 48, 67, 43, 63, 46, 59, 63, 66, 67, 62, 62,
59, 70, 64, 65, 63, 62, 62, 42, 60, 62, 61, 64, 61, 60, 68, 64,
56, 66, 61, 69, 62, 58, 59, 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 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0,
1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0,
0, 0), time_diff_MACE_months = c(72, 72, 28.4, 59.4, 72, 72,
72, 72, 68.9, 11.4, 72, 72, 11.7, 7.8, 1.5, 72, 1.7, 16.8, 72,
72, 72, 26.1, 72, 72, 62.3, 72, 72, 72, 38.9, 72, 72, 49.8, 72,
72, 13, 26.4, 72, 72, 72, 72, 72, 18.8, 24, 49.9, 25.1, 72, 16.4,
72, 27, 72, 72, 72, 72, 72, 72, 72, 3.6, 72, 72, 72, 72, 40.8,
72, 1.6, 72, 72, 69, 3.4, 72, 28.1, 72, 72, 52.8, 72, 39.6, 72,
59.9, 72, 72, 72, 72, 72, 72, 6.8, 72, 37.9, 72, 9.3, 18.7, 5.9,
72, 37.1, 72, 72, 5.9, 72, 72, 20.4, 45.6, 68.5, 72, 72, 25.4,
72, 72, 18.5, 72, 72, 72, 10.1, 24, 72, 72, 72, 72, 72, 11.3,
72, 72, 72, 72, 41.6, 72, 72, 72, 66.6, 24.1, 72, 72, 8, 72,
1.2, 72, 72, 72, 2.1, 30.6, 72, 10, 72, 55.5, 20.9, 67, 11.7,
4, 72, 18, 14, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 7.7, 72,
72, 72, 72, 64.3, 56.8, 2.6, 72, 3.9, 72, 72, 72, 72, 72, 72,
72, 37.9, 22.6, 72, 72, 30.4, 72, 72, 72, 72, 34.5, 72, 8, 72,
24.3, 72, 13.5, 9.3, 12, 72, 3, 1.3, 72, 72, 72, 72), match_RF_stroke = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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2L, 2L, 3L, 4L, 2L, 1L, 2L, 3L, 1L, 2L, 2L, 2L, 2L, 1L,
2L, 2L, 2L, 2L, 1L, 3L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L,
2L, 4L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 3L, 1L, 1L,
2L, 2L, 4L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L,
1L, 1L, 3L), levels = c("no AF proc + inactive", "no AF proc + active",
"AF proc + inactive", "AF proc + active"), class = "factor")), row.names = c(NA,
-200L), class = c("tbl_df", "tbl", "data.frame"))
[1]: https://i.stack.imgur.com/lFuZz.jpg
</details>
# 答案1
**得分**: 1
这是解决方案。我已经为您完善了UV代码,并留下了MV供您进行优化。我已将您的数据存储为x。
使用survival库
使用survminer库
将数据存储为data1
UV使用以下代码:
使用Surv函数计算,时间变量为time_diff_MACE_months,事件变量为match_MACE,按scoreMVPA分组,使用data1中的数据
MV使用以下代码:
使用coxph函数进行Cox比例风险回归分析,时间变量为time_diff_MACE_months,事件变量为match_MACE,考虑age、sex和scoreMVPA分层,使用data1中的数据
生成plot3:
使用ggsurvplot函数绘制生存曲线图,UV数据,显示p值,时间间隔为10,不显示置信区间,显示风险表格,y轴风险表格文本颜色为真,x轴范围为0到75,图例标签分别为“no AF proc + inactive”、“no AF proc + active”、“AF proc + inactive”、“AF proc + active”,x轴标签为“Months”,y轴标签为“% who do not incur MACE”,调色板设置,图形主题为“lancet”,p值显示坐标为(0,0.1),图例标题为空字符串
生成plot4:
使用ggadjustedcurves函数绘制调整后的曲线图,MV数据,使用data1中的数据
UV图
[![plot3][2]][2]
MV图
[![plot4][1]][1]
<details>
<summary>英文:</summary>
This is the solution to your problem. I've fleshed out the UV code for you and left the MV for your own optimisation. I have stored your data as x.
library(survival)
library(survminer)
data1 <- x %>% data.frame()
UV <- survfit(Surv(time = time_diff_MACE_months, event = match_MACE) ~ scoreMVPA, data = data1)
MV <- coxph(Surv(time = time_diff_MACE_months, event = match_MACE) ~ age + sex + strata(scoreMVPA), data = data1)
plot3 <- ggsurvplot(UV,
pval = TRUE,
break.time.by = 10,
conf.int = FALSE,
risk.table = T,
risk.table.y.text.col = TRUE,
xlim=c(0,75),
legend.labs = c("no AF proc + inactive", "no AF proc + active", "AF proc + inactive", "AF proc + active"),
xlab = "Months",
ylab = "% who do not incur MACE",
palette = c("#fba30c", "#0077b8", "#06D6A0", "#002A32"),
theme = "lancet",
pval.coord = c(0,0.1),
legend.title = "")
plot4 <- ggadjustedcurves(MV, data = data1)
UV plot
[![plot3][2]][2]
MV plot
[![plot4][1]][1]
[1]: https://i.stack.imgur.com/88Mdm.png
[2]: https://i.stack.imgur.com/r4G6z.png
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论