本文主要是介绍R语言:ROC分析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
> install.packages("pROC")
> library(pROC)
> inputFile="结果.txt"
> rt=read.table(inputFile, header=T, sep="\t", check.names=F, row.names=1)
> head(rt)
con treat TCGA-E2-A1L7-11A-con 0.9980384 2.026520e-03 TCGA-E2-A1IG-11A-con 1.0016393 -1.576685e-03 TCGA-BH-A0BS-11A-con 1.0003537 -2.915156e-04 TCGA-E9-A1NA-11A-con 1.0000117 5.027697e-05 TCGA-BH-A0H9-11A-con 0.9990589 1.003181e-03 TCGA-BH-A0BQ-11A-con 0.9617862 3.859257e-02
> y=gsub("(.*)\\-(.*)\\-(.*)\\-(.*)\\-(.*)", "\\5", row.names(rt))
> y=ifelse(y=="con", 0, 1)
> roc1=roc(y, as.numeric(rt[,2]))
> ci1=ci.auc(roc1, method="bootstrap")
> ciVec=as.numeric(ci1)
> pdf(file="ROC.pdf", width=5, height=5)
> plot(roc1, print.auc=TRUE, col="red", legacy.axes=T, main="Train group")
> text(0.39, 0.43, paste0("95% CI: ",sprintf("%.03f",ciVec[1]),"-",sprintf("%.03f",ciVec[3])), col="red")
> dev.off()
结果不好,但过程可以学习。
这篇关于R语言:ROC分析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!