R如何在右侧绘制“样本”,在gplots heatmap2中绘制顶部的“变量”?

时间:2012-07-09 18:38:37

标签: r rotation heatmap

使用命令:

heatmap.2(exp, col = greenred(100), scale="none", ColSideColors = Carcolors, 
    # dendrogram = "row",
    key=T, symkey=FALSE, density.info="none", trace="none", cexRow=1, cexCol=0.9)

heatmap2将“samples”绘制为列,将变量绘制为行。如何将热图逆时针旋转90度,以便样品名称列在右侧,变量列在顶部(右侧也有RowSideColors)?谢谢!

1 个答案:

答案 0 :(得分:3)

我不确定我是否理解你,但你的矩阵的转置是否有效?

以下是一个例子:

 require(gplots)
data(mtcars)
x  <- as.matrix(mtcars)
heatmap.2(x)

enter image description here

# transpose the matrix
heatmap.2(t(x))

enter image description here