0

我正在制作热图,但我无法将结果分配到变量中以在绘图前检查结果。Rstudio 自动绘制它。我想按热图的顺​​序获取行名列表。我不确定这是否可能。我正在使用这段代码:

hm <-    heatmap.2( assay(vsd)[ topVarGenes, ], scale="row", 
         trace="none", dendrogram="both", 
         col = colorRampPalette( rev(brewer.pal(9, "RdBu")) )(255),
         ColSideColors = c(Controle="gray", Col1.7G2="darkgreen", JG="blue", Mix="orange")[
           colData(vsd)$condition ] )
4

2 回答 2

1

可以将绘图分配给对象。绘图仍将在绘图窗口中绘制,但是,您还将获得一个包含每个绘图元素的所有数据的列表。然后,您只需要从列表中提取所需的绘图元素。例如:

library(gplots)

p = heatmap.2(as.matrix(mtcars), dendrogram="both", scale="row")

p是一个包含绘图所有元素的列表。

p # Outputs all the data in the list; lots of output to the console

str(p) # Struture of p; also lots of output to the console

names(p) # Names of all the list elements

p$rowInd # Ordering of the data rows

p$carpet # The heatmap values

如果您浏览列表元素,您将看到与树状图和热图相关的所有其他值。

于 2016-02-25T20:10:52.560 回答
0

对于其他人来说,一种更完整的描述方式来捕获由 gplots 创建的热图的矩阵表示:

matrix_map <- p$carpet
matrix_map <- t(matrix_map)
于 2016-02-28T19:46:29.363 回答