美文网首页
风险曲线

风险曲线

作者: 萍智医信 | 来源:发表于2021-08-17 01:41 被阅读0次
    输入文件risk.png
    inputFile="risk.txt"              #风险文件
    riskScoreFile="riskScore.pdf"     #风险曲线
    survStatFile="survStat.pdf"       #生存状态图
    setwd("D:\\biowolf")      #设置工作目录
    
    rt=read.table(inputFile, header=T, sep="\t", row.names=1, check.names=F)   #读取输入文件
    rt=rt[order(rt$riskScore),]        #按照riskScore对样品排序
            
    #绘制风险曲线
    riskClass=rt[,"risk"]
    lowLength=length(riskClass[riskClass=="low"])
    highLength=length(riskClass[riskClass=="high"])
    lowMax=max(rt$riskScore[riskClass=="low"])
    line=rt[,"riskScore"]
    line[line>10]=10
    pdf(file=riskScoreFile, width=7, height=4)
    plot(line, type="p", pch=20,
         xlab="Patients (increasing risk socre)", ylab="Risk score",
         col=c(rep("green",lowLength),rep("red",highLength)) )
    abline(h=lowMax,v=lowLength,lty=2)
    legend("topleft", c("High risk", "Low Risk"),bty="n",pch=19,col=c("red","green"),cex=1.2)
    dev.off()
            
    #绘制生存状态图
    color=as.vector(rt$fustat)
    color[color==1]="red"
    color[color==0]="green"
    pdf(file=survStatFile, width=7, height=4)
    plot(rt$futime, pch=19,
         xlab="Patients (increasing risk socre)", ylab="Survival time (years)",
         col=color)
    legend("topleft", c("Dead", "Alive"),bty="n",pch=19,col=c("red","green"),cex=1.2)
    abline(v=lowLength,lty=2)
    dev.off()
    

    相关文章

      网友评论

          本文标题:风险曲线

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