当前位置:   article > 正文

多因素生存分析图绘制_多因素图

多因素图

#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=rt f u s t a t , m a r k e r = r t fustat, marker = rt fustat,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(roc F P , r o c FP, roc FP,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曲线的优化

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/132213
推荐阅读
相关标签
  

闽ICP备14008679号