读入数据:
data <- read.delim("sample_num_per.cancerType.gene_stat.format", header=T, stringsAsFactors=F)
输入文件示例:
image.png
对gene和癌种进行排序:
data$Gene=factor(data$Gene,levels=c('CHEK2','CREBBP','CIC','ATM','IRS2','NOTCH3','ARID1B','NF1','SF3B1','SPEN','HLA-B','GRIN2A','FAT1','TP53','KMT2D','NOTCH1','ASXL1','KMT2C','TET2','DNMT3A'))
data$Item=factor(data$Item,levels=c('LUAD','NSCL','STAD','LUSC','COAD','READ','LIHC','PAAD','CHOL','ESCA','BRCA','HNSC','SCL','NASO','OV','CESC','KICH','PRAD'))
画图:
ggplot(data, aes(x=Item, y=Gene)) + geom_tile(aes(fill=Ratio), color='white')+geom_text(aes(label=round(Ratio,2)), size=3)+ theme(panel.grid.major.x=element_blank(), axis.text.x=element_text(angle=45, hjust=1), legend.position="bottom")+coord_equal() + xlab('') + ylab('')+scale_fill_gradient(low="white", high="#0000CC", name="Ratio (0,1)", limits=c(0, 1), guide=guide_colourbar(direction="horizontal", title.position="left", label.theme=element_text(angle=45, hjust=1, size=8)))
ggsave('sample_number_per_gene_each_cancer.ratio.png',dpi = 1080)
结果示例:
image.png
网友评论