#install.packages("pheatmap")
library(pheatmap)
rt=read.table("risk.txt",sep="\t",header=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"])
line=rt[,"riskScore"]
line[line>10]=10
pdf(file="riskScore.pdf",width = 10,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=median(rt$riskScore),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="survStat.pdf",width = 10,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()
#绘制风险热图
rt1=rt[c(3:(ncol(rt)-2))]
rt1=log2(t(rt1)+0.001)
annotation=data.frame(type=rt[,ncol(rt)])
rownames(annotation)=rownames(rt)
pdf(file="heatmap.pdf",width = 10,height = 4)
pheatmap(rt1,
annotation=annotation,
cluster_cols = FALSE,
fontsize_row=11,
show_colnames = F,
fontsize_col=3,
color = colorRampPalette(c("green", "black", "red"))(50) )
dev.off()
风险曲线+生存状态图+风险热图
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 读书虽好,却教不会你行动的能力2015-05-27 360doc个人图书馆点击上面↗-360doc个人图书馆-进行...
- 1.生存曲线 基础包survival+扩展包survminer。 survival包内置肺癌数据集lung。 生存...
- libiary(survival) library(survivalROC) fit_curve_train4<-...