美文网首页
ggplot2画热图

ggplot2画热图

作者: bioYIYI | 来源:发表于2020-08-10 14:22 被阅读0次

    读入数据:

    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

    相关文章

      网友评论

          本文标题:ggplot2画热图

          本文链接:https://www.haomeiwen.com/subject/hehjdktx.html