R语言绘制heatmap(热图)

作者: 落寞的橙子 | 来源:发表于2019-04-23 23:01 被阅读7次

热图的教程网上一抓一大把,本文使用pheatmap。

library(pheatmap)
rt<-read.csv("yourdir/liver_cpm_1_all.csv",header = T,row.names = 1,check.names = F)
rt[1:4,1:4]
                GTEX-1192X-1026-SM-5H12P GTEX-11DXY-0526-SM-5EGGQ GTEX-11DXZ-0126-SM-5EGGY GTEX-11EQ9-0526-SM-5A5JZ
ENSG00000227232                9.9633549                 5.925740                 4.691167                 2.484820
ENSG00000237683                5.1900366                 5.016777                 1.097475                 2.165542
ENSG00000225972                0.7387278                 3.286251               805.029998                 1.513103
ENSG00000225630               45.0813398               623.321412               355.840044               216.512510
group<-read.csv("yourdir/gene_list.csv",header = T,check.names = F)
group[1:4,1:2]
             list Group
1 ENSG00000165637   TOP
2 ENSG00000254827   TOP
3 ENSG00000134962   TOP
4 ENSG00000226479   TOP
genes<-as.character(group[,1])
data<-rt[genes,]
annotation_row<-data.frame(Group=factor(group[,2]))#对行(基因名进行分组,TOP,BOTTOM组)
row.names(annotation_row)<-row.names(data)
ann_colors <- list(Group=c( TOP ="aquamarine1",BOTTOM="plum1"))#设置row两组的颜色
pheatmap(log10(data+0.001),annotation_row =annotation_row,annotation_colors = ann_colors,color = colorRampPalette(c("navy", "white", "firebrick3"))(30),cellwidth =1.6, cellheight = 0.05,cluster_rows=F,cluster_cols = T,show_rownames = F,show_colnames = F)#取对数让数值分布更均匀

相关文章

网友评论

    本文标题:R语言绘制heatmap(热图)

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