rt=read.table("survivalInput.txt",header=T,sep="\t")
rt$futime=rt$futime/365 #如果以月为单位,除以30;以年为单位,除以365
a=rt[,"gene"]<median(rt[,"gene"])
#median(rt[,"gene"]) > min(rt[,"gene"]))#判断是否只有一组
diff=survdiff(Surv(futime, fustat) ~a,data = rt)
pValue=1-pchisq(diff$chisq,df=1)
pValue=round(pValue,5)
fit <- survfit(Surv(futime, fustat) ~ a, data = rt)
summary(fit) #查看五年生存率
pdf(file=paste(“gene,".pdf",sep = ""))
plot(fit, lty = 2:3,col=c("red","blue"),xlab="time (year)",ylab="surival rate", main=paste("surival curve (p=", pValue ,")",sep=""))
legend("topright", c(paste("gene," high expression",sep = ""), paste("gene"," low expression",sep = "")), lty = 2:3, col=c("red","blue"))
dev.off()
网友评论