[英]Formatting issues with Heatmap.2 function in gplots library - margins and axis
[英]Use customized order of axis with heatmap.2 function from gplots
我需要使用表中排列的軸繪制熱圖。
我的數據是csv格式:
"X" "Mescla" "HCL" "HSL" "Kmeans" "soma"
"1" "DR" 15.33559 14.7499 14.7556 14.32343 89.78054
"2" "DA" 16.59264 14.764 14.9968 14.36513 91.08672
"3" "UMR80" 16.28646 15.88403 14.01783 15.96327 94.55977
"4" "UMR" 16.46229 15.87505 14.34763 15.87903 94.83926
"5" "MR50" 16.61305 16.04243 14.85003 16.15599 96.20576
> data
X merge A1 A2 K sum
1 DR 15.33559 14.74990 14.75560 14.32343 89.78054
2 DA 16.59264 14.76400 14.99680 14.36513 91.08672
3 UMR80 16.28646 15.88403 14.01783 15.96327 94.55977
4 UMR 16.46229 15.87505 14.34763 15.87903 94.83926
5 MR50 16.61305 16.04243 14.85003 16.15599 96.20576
我的解決方案是使用參數Rowv = FALSE和Colv = FALSE:
library(gplots)
library(RColorBrewer)
rnames <- data[,1]
mat_data <- data.matrix(data[,3:ncol(data)-1])
rownames(mat_data) <- rnames
my_palette <- colorRampPalette(c("red", "yellow", "green"))(n = 299)
col_breaks = c(seq(-1,0,length=100), # for red
seq(0,0.8,length=100), # for yellow
seq(0.81,1,length=100)) # for green
heatmap.2(mat_data,
main = "Rank", # heat map title
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
trace="none", # turns off trace lines inside the heat map
margins =c(7,5), # widens margins around plot
col=my_palette, # use on color palette defined earlier
Rowv=FALSE,
Colv=FALSE,
dendrogram="none") # turn off column clustering
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.