【发布时间】:2019-02-27 06:59:34
【问题描述】:
我有一个包含 100 个样本的数据集,每个样本有 195 个突变及其对应的已知临床意义(“RealClass”)和根据某些预测工具的预测值(“PredictionValues”)
为了演示,这是一个与我的数据集具有相同结构的随机数据集:
predictions_100_samples<-as.data.frame(matrix(nrow=19500,ncol=3))
colnames(predictions_100_samples)<-c("Sample","PredictionValues","RealClass")
predictions_100_samples$Sample<-rep(c(1:100), each = 195)
predictions_100_samples$PredictionValues<-sample(seq(0,1,length.out=19500))
predictions_100_samples$RealClass<-rep(c("pathogenic","benign"),each=10)
colours_for_ROC_curves<-rainbow(n=100)
我通过 PROC 包将所有这 100 个样本绘制为 ROC 曲线:
library("pROC")
roc_both <- plot(roc(predictor=predictions_100_samples[1:195,2],response = predictions_100_samples[1:195,3]), col = colours_for_ROC_curves[1],main="100 samples ROC curves",legacy.axes=TRUE,lwd=1)
i=2
for(i in 1:100){
set.seed(500)
roc_both <- plot(roc(predictor=predictions_100_samples[(((i-1)*195)+1):(i*195),2],response = predictions_100_samples[(((i-1)*195)+1):(i*195),3]), col = colours_for_ROC_curves[i], add = TRUE,lwd=1)
i=i+1
}
这就是最终情节的样子:
现在,我想将所有 100 条绘制的 ROC 曲线的平均 ROC 曲线添加到同一个图中。
我尝试使用我编写的循环中通过“roc”函数为每个阈值计算的灵敏度和特异性(可以通过roc_both$sensitivities、roc_both$specificities、roc_both$thresholds 实现)
但主要问题是选择的阈值是随机的,并且在我绘制的 100 条 ROC 曲线上并不相等,因此我无法手动计算平均 ROC 曲线。
是否有不同的软件包可以让我生成多个 ROC 曲线的平均 ROC 曲线?或者是否有一个包允许手动设置计算灵敏度和特异性的阈值,这样我以后就可以计算平均 ROC 曲线? 您可能对我的问题有不同的解决方案吗?
谢谢!
【问题讨论】: