最近在簡書
中找到比較好看的聚類熱圖趴腋,自己也跟著模仿一下实昨,也非常感謝作者的分享毅整。真的非常高興在簡書中有這樣的作者袋哼。
也希望在簡書中或其他平臺中有越來越多的人進行分享。
現(xiàn)在自己也分享一下自己這個歷程胚宦,最后驶睦,最后晨炕,最后掏愁,還是一句話歇由,“使用R畫圖,數(shù)據(jù)準備非常非常的重要”果港。
1 數(shù)據(jù)準備
第一列沦泌,gene_id, 后面是重復辛掠,3個重復谢谦,我的共4個處理數(shù)據(jù),12組
2導入數(shù)據(jù)
#文件所在位置
setwd("I:FPKM")
library(pheatmap)
#BiocManager::install("heatmaps") #如沒有按照“pheatmap包請安裝”
dataset <- read.table('FPKM_聚類圖數(shù)據(jù).txt',header = TRUE, row.names = 1)
3 構(gòu)建矩陣
# 構(gòu)建樣本分類數(shù)據(jù)
sample_calss=c(rep('CS_Leaf',3),
rep('CK_Lead',3),
rep('CS_Root',3),
rep('CK_Root',3))
level = c(1:12)
annotation_c <- data.frame(sample_calss, level)
rownames(annotation_c) <- colnames(exp_ds)
gene_class=c(rep('High',30),
rep('Low',30))
sample_type=c(rep('CS',20),
rep('CK',20),
rep('Immunology',20))
annotation_r <- data.frame(gene_class, gene_type)
rownames(annotation_r) <- rownames(exp_ds)
畫圖
pheatmap(exp_ds, #表達數(shù)據(jù)
cluster_rows = T,#行聚類
cluster_cols = T,#列聚類
annotation_col =annotation_c, #樣本分類數(shù)據(jù)
annotation_row = annotation_r,
annotation_legend=TRUE, # 顯示樣本分類
show_rownames = T,# 顯示行名
scale = "row", #對行標準化
color =colorRampPalette(c("#8854d0", "#ffffff","#fa8231"))(100), # 熱圖基準顏色
)
結(jié)果圖形
原文鏈接 【支持原文】