- 最可能问的问题 - 运行Heatmap()函数后没有plot出来。 - 检索订单和树状图。< / toc >- How should I control the height or width of the heatmap annotations? - How should I control the axes of the annotations? - How to control the style of legends? - Some text are cut by the plotting region. - Can the heatmaps be added vertically? - Does Heatmap title supports mathematical expression? - I have many heatmaps and I want to put them into different panels for a big figure for my paper. - I have a matrix with too many rows and I want to simplify the row dendrogram. - I have a matrix with huge nunmber of rows or columns, what is the efficient way to visualize it? - How to add axes for dendrograms? - I set row_km/column_km and it gives me different k-means clusterings for different runs. - I only want to draw dendrograms plus a list of annotations. - I still have a problem with the package and I am lost in the ocean of the huge vignette. - Can I also add heatmaps produced by pheatmap()? - Can I make an interactive heatmap?
在这种情况下,您需要使用画()
显式函数。看到https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#plot-the-heatmap而且https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#plot-the-heamtap-list.
用于从单个热图中检索订单和树状图。看到https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#get-orders-and-dendrograms-from-heatmap.
用于从热图列表中检索顺序和树状图。看到https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#get-orders-and-dendrograms-from-a-list-of-heatmaps.
生成的复杂注释anno_ * ()
函数,宽度或高度应设置在anno_ * ()
函数,例如anno_points(…,身高=…)
.简单注释的大小由anno_simple_size
.的宽度
/高度
而且annotation_width
/annotation_height
是用来调整大小的多个注释是放在一个HeatmapAnnotation
对象。看到https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap-annotations.html#multiple-annotations
在注释函数中anno_ * ()
,论证axis_param
可用于设置轴。该值应该是一个列表,axis的默认设置可以通过以下方式获取:
default_axis_param(“列”)default_axis_param(“行”)
图例的样式可以通过heatmap_legend_param
在热图()
,或annotation_legend_param
在HeatmapAnnotation ()
.控制图例的参数就是这些参数传奇()
函数。看到https://jokergoo.github.io/ComplexHeatmap-reference/book/legends.html#heatmap-and-annotation-legends.
的布局ComplexHeatmap不完美的是,仍有可能将部分文字绘制出绘图区域。在这种情况下,您可以设置填充
论点画()
函数增加最终图周围的空白区域。看到https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#manually-increase-space-around-the-plot.
是的,使用% v %
而不是+
.看到https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#vertical-concatenation.
是的,所有与文本相关的元素(例如标题,行名,图例标题,图例标签,…)都允许数学表达式。
你可以设置newpage = FALSE
在画()
功能及用途grid.layout ()
来管理面板的布局。
pushViewport(layout = grid.layout(…)))Row =…, layout.pos.col =…))绘制(ht, newpage = FALSE) #或绘制(ht_list, newpage = FALSE) popViewport()…
但我更建议使用grid.grabExpr ()
可以直接捕获热图的输出,然后将整个plot作为单个图形元素绘制grid.draw ()
.
Ht_grob = grid。grabExpr(draw(ht,…))pushViewport(viewport(layout = grid.layout(…)))pushViewport(viewport(layout.pos.…)Row =…, layout.pos.col =…))grid.draw(ht_grob) popViewport()…
您可以首先将行分组为几个组,并在其上制作组级树状图。请看下面的例子:
m = matrix(rnorm(1000*10), nr = 1000) hc = hclust(dist(m)) group = cutree(hc, k = 6) Heatmap(m, cluster_rows = cluster_within_group(t(m), group), row_split = 6, border = TRUE) #如果还设置了row_split会更好
热图用于可视化矩阵的全局模式,而不是每一行或列。我建议将样本行或列随机分成一个合理的小数目,最终的热图应该看起来和你仍然坚持使用完整的矩阵一样。
你需要使用decorate_row_dend ()
或decorate_column_dend ()
手动添加坐标轴。请看以下例子:
m = matrix(rnorm(100), 10) ht = Heatmap(m, name = "foo", row_dend_width = unit(4, "cm"), column_dend_height = unit(4, "cm")) draw(ht, padding = unit(c(15,2,2,2), "mm") decorate_column_dend("foo", {grid.yaxis()}) decorate_row_dend("foo", {vp = current.viewport() xscale = vp$xscale网格。Xaxis (at = xscale[2] - 0:5, label = 0:5)})
注意对于左行树状图,x轴是从右向左的,需要自定义在
而且标签
在grid.xaxis ()
函数。
你也可以检查annotation_axis_grob ()
功能(后续使用)grid.draw ()
为了画出一个更好的轴)。
是的,这是意料之中的,因为k-means使用随机起点,对于不同的运行可能会给出不同的结果。要解决这个问题,您可以采用以下两种方法:
set.seed(…)
在制作热图之前。这确保了随机种子对于不同的运行总是相同的。row_km_repeats
/column_km_repeats
多次运行k-means以获得最终一致的k-means聚类。注意,你可能仍然会得到不同的结果,但比只运行一次k-means的机会要小得多。你需要将树状图分配给一个零行/零列矩阵:
Heatmap(matrix(nc = 0, nr = 10), cluster_rows = hc, right_annotation = rowAnnotation(foo = anno_points(1:10), sth = 1:10, bar = anno_barplot(1:10)), row_split = 2)
小插图(https://jokergoo.github.io/ComplexHeatmap-reference/book/)包含大量的例子和图表,展示了该软件包的不同用法。有时要找到你正在寻找的解决方案并不容易。在这种情况下,不要犹豫在GitHub上发布问题。我很高兴回答你所有的问题!
是的,你可以参考https://jokergoo.github.io/2020/05/06/translate-from-pheatmap-to-complexheatmap/.
是的,请参考的InteractiveComplexHeatmap包.