美文网首页R画图R for statisticsData science
【R>>survivalROC】ROC最佳cutoff

【R>>survivalROC】ROC最佳cutoff

作者: 高大石头 | 来源:发表于2021-05-24 09:45 被阅读0次

    KM(Kaplan-Meier)需要分组变量是二分类的,如果是基因表达量或者riskScore时,则需要转化为二分类。当然这个转化是有技巧可言的,比如下面这篇文章:


    PMID: 33954109

    选择的分割点是ROC最靠左上角的点。在文中作者的描述:

    An optimal cut-off was determined based on the ROC analysis (Figure 2B). As shown in Figure 2B, we selected the point with the maximal sensitivity and specificity as the cut-off point (value = 1.349) and the patients in training set were divided into two groups, high risk group (n = 130) and low risk group (n = 278) (Figure 2A).

    图形复现

    rm(list = ls())
    library(tidyverse)
    library(survivalROC)
    risk <- data.table::fread("temp_data/riskTrain.txt",data.table = F) %>% 
      column_to_rownames("id")
    predict_time1=3
    predict_time2=5
    
    auc_text=c()
    you_roc <- survivalROC(Stime=risk$futime,
                           status = risk$fustat,
                           marker = risk$riskScore,
                           predict.time = predict_time1,
                           method = "KM")
    
    cutoff_3years <- you_roc$cut.values[which.max(you_roc$TP-you_roc$FP)]
    cutoff_3years
    y1 <- you_roc$TP[you_roc$cut.values==cutoff_3years]
    x1 <- you_roc$FP[you_roc$cut.values==cutoff_3years]
    
    plot(you_roc$FP,you_roc$TP,
         xlim=c(0,1),ylim=c(0,1),
         col="firebrick3",
         xlab="False positive rate", 
         ylab="True positive rate",
         lwd = 2, cex.main=1.5, cex.lab=1.3, cex.axis=1.3, font=1.3)
    title (paste0("ROC curve"," (AUC=",sprintf("%.3f",you_roc$AUC),")"),
           font.main=1)
    abline(0,1)
    arrows(x0=0.3,y0=0.9,x1=x1,y1=y1,length = 0.2,angle = 10,code = 2,col = "royalblue")
    text(0.3,0.92,
         labels = paste("Cutoff value: ",round(cutoff_3years,3)))
    

    是不是看着有点神似了。

    参考链接:
    利用ROC曲线寻找最佳cutoff值(连续型变量组成的riskscore)

    相关文章

      网友评论

        本文标题:【R>>survivalROC】ROC最佳cutoff

        本文链接:https://www.haomeiwen.com/subject/klctsltx.html