日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

多因素生存分析图绘制

發(fā)布時(shí)間:2023/12/31 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 多因素生存分析图绘制 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

#1、生存分析和ROC曲線
數(shù)據(jù)格式

library(survival)
rt=read.table(“risk.txt”,header=T,sep="\t")
diff=survdiff(Surv(futime, fustat) ~risk,data = rt)
pValue=1-pchisq(diffKaTeX parse error: Expected 'EOF', got '#' at position 107: …ummary(fit) #?查看五年生存率 library…futime, status=rtfustat,marker=rtfustat, marker = rtfustat,marker=rtriskScore,
predict.time =3, method=“KM”)

tiff(file=“survival_ROC.tiff”,width = 20,height = 10,units =“cm”,compression=“l(fā)zw”,bg=“white”,res=500)

par(mfrow=c(1,2),cex.main=1.3, cex.lab=1.2, cex.axis=1.2, font=1.2, lwd = 2 )
plot(fit, lty = 2:3,col=c(“red”,“blue”),xlab=“time (year)”,ylab=“survival rate”,
main=paste(“survival curve (p=”, pValue ,")",sep=""),mark.time=T)
legend(“topright”, c(“high risk”, “l(fā)ow risk”), lty = 2:3, col=c(“red”,“blue”))
plot(rocFP,rocFP, rocFP,rocTP, type=“l(fā)”, xlim=c(0,1), ylim=c(0,1),col=‘red’,
xlab=“False positive rate”, ylab=“True positive rate”,
main=paste(“ROC curve (”, “AUC = “,round(roc$AUC,3),”)”))

abline(0,1)
dev.off()

#riskscore和生存時(shí)間
數(shù)據(jù)格式

#讀取數(shù)據(jù)
dat <- read.table(“risk.txt”,header = TRUE,sep="\t")
library(ggplot2)
library(gridExtra)
#對(duì)第五列的low和high計(jì)數(shù)
low <- sum(dat[,5]== “l(fā)ow”)
high <- sum(dat[,5]== “high”)
total <- low+high
#標(biāo)簽
lowlable=paste(“Low :”,low)
highlable=paste(“High :”,high)
#對(duì)第二列的Alive和Dead計(jì)數(shù)
Alive <- sum(dat[,2] == “Alive”)
Dead <- sum(dat[,2] == “Dead”)
#標(biāo)簽
Alivelable=paste(“Alive :”,Alive)
Deadlable=paste(“Dead :”,Dead)
#繪圖
tiff(file=“riskscore_sur_year.tiff”,width = 20,height = 10,units =“cm”,compression=“l(fā)zw”,bg=“white”,res=500)
p1 <- ggplot(dat,aes(x=x,y=riskScore)) + geom_point(shape=19,aes(colour = risk)) +xlab("") + ylab(“riskScore”) +
scale_color_manual(paste(“Risk”),values=c(“blue”,“red”))+
geom_vline(xintercept = 250,linetype =3,color=“blue”)+theme(panel.background = element_rect(fill = “transparent”, color = “gray”),legend.position=‘none’)
p2 <- ggplot(dat,aes(x=x,y=futime)) + geom_point(aes(colour = risk,shape=fustat)) +xlab("") + ylab(“Survival Year”) +
geom_vline(xintercept = 250,linetype =3,color=“red”)+theme(panel.background =
element_rect(fill = “transparent”, color = “gray”)) +scale_color_manual(paste(“Risk”), values=c(“blue”,“red”),labels=c(lowlable,highlable))+scale_shape_manual(paste(“Fustat”),
values=c(1,6),labels=c(Alivelable,Deadlable))
grid.arrange(p1,p2 ,widths=c(1.5,2),nrow=1)
dev.off()

多因素COX分析,生存圖和ROC曲線的優(yōu)化

總結(jié)

以上是生活随笔為你收集整理的多因素生存分析图绘制的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。