多因素生存分析图绘制

#1、生存分析和ROC曲线
数据格式
在这里插入图片描述
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=“lzw”,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”, “low risk”), lty = 2:3, col=c(“red”,“blue”))
plot(rocFP,rocFP, rocFP,rocTP, type=“l”, 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和生存时间
数据格式
在这里插入图片描述
#读取数据
dat <- read.table(“risk.txt”,header = TRUE,sep="\t")
library(ggplot2)
library(gridExtra)
#对第五列的low和high计数
low <- sum(dat[,5]== “low”)
high <- sum(dat[,5]== “high”)
total <- low+high
#标签
lowlable=paste(“Low :”,low)
highlable=paste(“High :”,high)
#对第二列的Alive和Dead计数
Alive <- sum(dat[,2] == “Alive”)
Dead <- sum(dat[,2] == “Dead”)
#标签
Alivelable=paste(“Alive :”,Alive)
Deadlable=paste(“Dead :”,Dead)
#绘图
tiff(file=“riskscore_sur_year.tiff”,width = 20,height = 10,units =“cm”,compression=“lzw”,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曲线的优化

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值