我有一项测试数据,可用于区分正常细胞和肿瘤细胞。根据ROC曲线,此目的看起来不错(曲线下的面积为0.9):
我的问题是:
- 如何确定该测试的临界点及其置信区间,在该区间应该将读数判断为不明确?
- 可视化此最佳方法(使用
ggplot2
)是什么?
图是使用ROCR
和ggplot2
包呈现的:
#install.packages("ggplot2","ROCR","verification") #if not installed yet
library("ggplot2")
library("ROCR")
library("verification")
d <-read.csv2("data.csv", sep=";")
pred <- with(d,prediction(x,test))
perf <- performance(pred,"tpr", "fpr")
auc <-performance(pred, measure = "auc")@y.values[[1]]
rd <- data.frame(x=perf@x.values[[1]],y=perf@y.values[[1]])
p <- ggplot(rd,aes(x=x,y=y)) + geom_path(size=1)
p <- p + geom_segment(aes(x=0,y=0,xend=1,yend=1),colour="black",linetype= 2)
p <- p + geom_text(aes(x=1, y= 0, hjust=1, vjust=0, label=paste(sep = "", "AUC = ",round(auc,3) )),colour="black",size=4)
p <- p + scale_x_continuous(name= "False positive rate")
p <- p + scale_y_continuous(name= "True positive rate")
p <- p + opts(
axis.text.x = theme_text(size = 10),
axis.text.y = theme_text(size = 10),
axis.title.x = theme_text(size = 12,face = "italic"),
axis.title.y = theme_text(size = 12,face = "italic",angle=90),
legend.position = "none",
legend.title = theme_blank(),
panel.background = theme_blank(),
panel.grid.minor = theme_blank(),
panel.grid.major = theme_line(colour='grey'),
plot.background = theme_blank()
)
p
data.csv包含以下数据:
x;group;order;test
56;Tumor;1;1
55;Tumor;1;1
52;Tumor;1;1
60;Tumor;1;1
54;Tumor;1;1
43;Tumor;1;1
52;Tumor;1;1
57;Tumor;1;1
50;Tumor;1;1
34;Tumor;1;1
24;Normal;2;0
34;Normal;2;0
22;Normal;2;0
32;Normal;2;0
25;Normal;2;0
23;Normal;2;0
23;Normal;2;0
19;Normal;2;0
56;Normal;2;0
44;Normal;2;0