R语言 | COX单因素回归和多因素回归
点上方“科学前沿进展”关注我!
1#COX单因素回归和多因素回归
2#参考网址:https://www.bioinfo-scrounger.com/archives/650/
3
4#加载包
5library("survival")
6library("survminer")
7
8#导入数据
9inputData = data.frame(CoxTestData)
10nameColnames = colnames(inputData)
11
12#COX分析需要的生存时间time和生存状态status
13time = inputData[,5:6]
14status = inputData[,nameColnames[4]]
15colnameTime = colnames(time)
16
17#COX单因素回归分析
18for (j in 1:length(colnameTime)){
19 for (i in 1:(length(nameColnames)-3)){
20 object = inputData[,nameColnames[i]]
21 res.cox_Single <- coxph(Surv(time[,j], status) ~ object, data = inputData)
22 #分割线
23 divideLine = paste(paste(colnameTime[j],'------------------------------------------------'),nameColnames[i])
24 print(divideLine)
25 #COX单因素的统计结果
26 print(summary(res.cox_Single))
27
28 }
29
30}
31
32
33#COX多因素回归分析
34res.cox_Multible_first <- coxph(Surv(time[,1], status) ~ NLR_A + LMR_A + PLR_A, data = inputData)
35summary(res.cox_Multible)
36
37res.cox_Multible_second <- coxph(Surv(time[,2], status) ~ NLR_A + LMR_A + PLR_A, data = inputData)
38summary(res.cox_Multible)
你可能还喜欢
生物信息
科研软件
文献解读
SCI文章写作
科研信息
--END--
读完、看完,点在看~
版权声明
Copyright statement
The content of this article does not represent personal views.If involved in copyright issues, please timely contact me to delete, modify.