【问题标题】:Use customized order of axis with heatmap.2 function from gplots使用 gplots 中的 heatmap.2 函数自定义轴顺序
【发布时间】:2018-02-16 16:01:51
【问题描述】:

我需要使用按表中顺序排列的轴绘制热图。

我的数据是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

【问题讨论】:

    标签: r heatmap gplots


    【解决方案1】:

    我的解决方案是使用参数 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
    

    热图是:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-21
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-19
      • 1970-01-01
      • 2014-01-29
      相关资源
      最近更新 更多