[d6960c]: / Nomogram.R

Download this file

121 lines (104 with data), 4.8 kB

  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
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
## Here are the simple examples for plotting nomogram, ROC curves, Calibration curves, and Decision curves
## in training and test dataset by using R language.
# Library and data
library(rms)
library(pROC)
library(rmda)
train <-read.csv("E:/Experiments/YinjunDong/nomogram/EGFR-nomogram.csv")
test <-read.csv("E:/Experiments/YinjunDong/nomogram/EGFR-nomogram-test.csv")
# Nomogram
dd=datadist(train)
options(datadist="dd")
f1 <- lrm(EGFR~ Rad
+Smoking
+Type
,data = train,x = TRUE,y = TRUE)
nom <- nomogram(f1, fun=plogis,fun.at=c(.001, .01, seq(.1,.9, by=.4)), lp=F, funlabel="Risk")
plot(nom)
# ROC train
f2 <- glm(EGFR~ Rad
+Smoking
+Type
,data = train,family = "binomial")
pre <- predict(f2, type='response')
plot.roc(train$EGFR, pre,
main="ROC Curve", percent=TRUE,
print.auc=TRUE,
ci=TRUE, ci.type="bars",
of="thresholds",
thresholds="best",
print.thres="best",
col="blue"
#,identity=TRUE
,legacy.axes=TRUE,
print.auc.x=ifelse(50,50),
print.auc.y=ifelse(50,50)
)
# ROC test
pre1 <- predict(f2,newdata = test)
plot.roc(test$EGFR, pre1,
main="ROC Curve", percent=TRUE,
print.auc=TRUE,
ci=TRUE, ci.type="bars",
of="thresholds",
thresholds="best",
print.thres="best",
col="blue",legacy.axes=TRUE,
print.auc.x=ifelse(50,50),
print.auc.y=ifelse(50,50)
)
# Calibration Curve train
rocplot1 <- roc(train$EGFR, pre)
ci.auc(rocplot1)
cal <- calibrate(f1, method = "boot", B = 1000)
plot(cal, xlab = "Nomogram Predicted Survival", ylab = "Actual Survival",main = "Calibration Curve")
# Calibration Curve test
rocplot2 <- roc(test$EGFR,pre1)
ci.auc(rocplot2)
f3 <- lrm(test$EGFR ~ pre1,x = TRUE,y = TRUE)
cal2 <- calibrate(f3, method = "boot", B = 1000)
plot(cal2, xlab = "Nomogram Predicted Survival", ylab = "Actual Survival",main = "Calibration Curve")
# Decision Curve train
Rad<- decision_curve(EGFR~
Rad, data = train, family = binomial(link ='logit'),
thresholds= seq(0,1, by = 0.01),
confidence.intervals =0.95,study.design = 'case-control',
population.prevalence = 0.3)
Clinical<- decision_curve(EGFR~
Smoking+Type, data = train, family = binomial(link ='logit'),
thresholds= seq(0,1, by = 0.01),
confidence.intervals =0.95,study.design = 'case-control',
population.prevalence = 0.3)
clinical_Rad<- decision_curve(EGFR~ Rad
+Smoking+Type, data = train,
family = binomial(link ='logit'), thresholds = seq(0,1, by = 0.01),
confidence.intervals= 0.95,study.design = 'case-control',
population.prevalence= 0.3)
List<- list(Clinical,Rad,clinical_Rad)
plot_decision_curve(List,curve.names= c('Clinical','Rad-Score','Nomogram'),
cost.benefit.axis =FALSE,col = c('green','red','blue'),
confidence.intervals =FALSE,standardize = FALSE,
#legend.position = "none"
legend.position = "bottomleft"
)
# Decision Curve test
Rad1<- decision_curve(EGFR~
Rad, data = test, family = binomial(link ='logit'),
thresholds= seq(0,1, by = 0.01),
confidence.intervals =0.95,study.design = 'case-control',
population.prevalence = 0.3)
Clinical1<- decision_curve(EGFR~
Smoking+Type, data = test, family = binomial(link ='logit'),
thresholds= seq(0,1, by = 0.01),
confidence.intervals =0.95,study.design = 'case-control',
population.prevalence = 0.3)
clinical_Rad1<- decision_curve(EGFR~ Rad
+Smoking+Type, data = test,
family = binomial(link ='logit'), thresholds = seq(0,1, by = 0.01),
confidence.intervals= 0.95,study.design = 'case-control',
population.prevalence= 0.3)
List1<- list(Clinical1, Rad1, clinical_Rad1)
plot_decision_curve(List1,curve.names= c('Clinical','Rad-Score','Nomogram'),
cost.benefit.axis =FALSE,col = c('green','red','blue'),
confidence.intervals =FALSE,standardize = FALSE,
legend.position = "bottomleft")