肿瘤预后类文章的常规步骤之一是绘制诺模图,并进行相关分析。以下总结了相关基础绘制工具。
示例数据集 1 2 3 4 5 6 library(survival) head(lung) # inst time status age sex ph.ecog ph.karno pat.karno meal.cal wt.loss # 1 3 306 2 74 1 1 90 100 1175 NA # 2 3 455 2 68 1 0 90 90 1225 15 # 3 3 1010 1 56 1 0 90 90 NA 15 1、rms包 参考用法:https://atm.amegroups.com/article/view/14736/15089 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 library(rms) # var.labels = c(age="Age in Years", # lac="lactate", # sex="Sex of the participant", # shock="shock", # y="outcome", # Y="ordinal") # label(data) = lapply(names(var.labels), # function(x) label(data[,x]) = var.labels[x]) mod.cox <- cph(Surv(time,status) ~ ph.ecog+sex+age,lung, surv=TRUE) ddist <- datadist(lung) options(datadist='ddist') surv.cox <- Survival(mod.cox) # 定义函数 med <- Quantile(mod.cox) surv <- Survival(mod.cox) nom.cox <- nomogram(mod.cox, # 根据total point进行特定函数计算 fun=list(function(x) surv.cox(365, x), # 一年生存率 function(x) med(lp=x, q=0.5)), # 中位生存时间 funlabel=c("200-Day Sur. Prob.", "Median Survival Time"), lp=F, # 不展示Linear Predictor conf.int=c(0.1,0.5) # 两个置信区间 ) plot(nom.cox, col.conf=c('red','green'), # 置信区间的颜色 col.grid = c("grey30","grey") # 网格的颜色 ) # f = cph(Surv(time, status) ~ age + sex + ph.karno, data = lung, # x = T, y = T, sur = T) # pred_score = apply(lung, 1, function(x){ # pred=Predict(f, age=x["age"], sex=x["sex"], ph.karno=x["ph.karno"]) # return(pred$yhat) # }) %>% unlist() # summary(pred_score) 校准曲线
...