#install.packages("pheatmap") library(pheatmap) setwd("D:\\bioinformaticanalysis\\riskPlot") rt=read.table("risk.txt",sep="\t",header=T,row.names=1,check.names=F) rt=rt[order(rt$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("blue",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","blue"),cex=1.2) dev.off() color=as.vector(rt$fustat) color[color==1]="red" color[color==0]="blue" 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","blue"),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 = 8,height = 4) pheatmap(rt1, annotation=annotation, cluster_cols = FALSE, fontsize_row=10, show_colnames = F, fontsize_col=3, color = colorRampPalette(c("blue", "white", "red"))(50) ) dev.off()