# remotes::install_github("cardiomoon/multipleROC") # 安装包
# remotes::install_github("PengBingming/multipleROC") # 安装自己修改的包

library(pROC)
library(multipleROC)
library(ggplot2)

df <- as.data.frame(aSAH) # 数据
head(df)

# 1、单个变量
p <- multipleROC(outcome~s100b,data=df, plot = F)
plot_ROC(p,
         show.points = T,
         show.eta = T,
         show.sens = T,
         show.AUC = T,
         facet = F )+
#  theme_bw()+ # 主题
#  geom_line(color='red')+ # roc 线 颜色
#  geom_abline(intercept = ,slope = 1,color='white',size=2)+
#  geom_abline(intercept = 0,slope = 1,color='red',size=1,linetype="dashed")+ 对角线 线条、颜色
  theme(
    text = element_text(size = 20)
  )

# 2、多个变量
p1 <- multipleROC(outcome~s100b,data=df)
p2 <- multipleROC(outcome~ndka,data=df)
p3 <- multipleROC(outcome~age,data=df)
# 一起显示
plot_ROC(list(p1,p2,p3),
         show.points = T,
         show.eta = T,
         show.sens = T,
         show.AUC = T,
         facet = F )+
  theme(
    text = element_text(size = 20)
  )
plot

# 分面
supp.labs <- c('s100b','ndka','age')
names(supp.labs) <- 1:3

plot + facet_grid(.~no,labeller = labeller(no=supp.labs) )
plot + facet_grid(no~.,labeller = labeller(no=supp.labs) )

  # 1、多个变量联合
p <- multipleROC(outcome~s100b+age,data=df, plot = F)
plot_ROC(p,
         show.points = T,
         show.eta = T,
         show.sens = T,
         show.AUC = T,
         facet = F )+
  theme(
    text = element_text(size = 20)
  )
Avatar photo

作者 xian

发表回复