在这种情况下,您需要使用画()
明确功能。看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-anders-and-dendrograms-from-heatmap。
从热图列表中检索订单和树状图。看https://jokergoo..github.io/complexheatmap-reference/book/a-list-of-heatmaps.html#get-orders-anders-and-dendrograms-from-a-list from-a-a-list-of-Heatmaps。
对于复杂的注释Anno _*()
应在内部设置功能,宽度或高度Anno _*()
功能,例如anno_points(...,高度= ...)
。简单注释的大小由anno_simple_size
。这宽度
/高度
和Annotation_width
/Annotation_height
用于调整多个注释的大小热门通道
目的。看https://jokergoo..github.io/complexheatmap-reference/book/heatmap-annotations.html#multiple-annotations
在注释功能中Anno _*()
,论点AXIS_PARAM
可用于设置轴。该值应该是一个列表,可以通过以下方式获得轴的默认设置:
default_axis_param(“列”)default_axis_param(“ row”)
传说的风格可以由heatmap_legend_param
在热图()
, 或者Annotation_legend_param
在热门通道()
。控制传说的参数是传奇()
功能。看https://jokergoo..github.io/complexheatmap-reference/book/legends.html#heatmap-andmap-and-annotation-legends。
布局复杂的图像仍然有可能将某些文本从绘图区域中抽出并不是完美的。在这种情况下,您可以设置填充
参数画()
功能以增加最终图周围的空白区域。看https://jokergoo.github.io/complexheatmap-reference/book/a-list-of-heatmaps.html#manally increase-increase-space-around-the-plot。
是的,使用%v%
代替+
。看https://jokergoo..github.io/complexheatmap-reference/book/a-list-of-heatmaps.html#vertical-concatenation。
是的,所有与文本相关的元素(例如标题,行名,传奇标题,传奇标签,…)允许主修表达。
您可以设置newPage = false
在画()
功能和使用网格布局()
管理面板的布局。
pushViewport(viewport(layout = grid.layout(...)))pushViewport(viewport(layout.pos.row = ...,layout.pos.col = ...))draw(ht,newpage = false)#或绘制(ht_list,newpage = false)popviewport()...
但我建议使用grid.grabexpr()
直接捕获热图的输出,然后通过grid.draw()
。
ht_grob = grid.grabexpr(draw(ht,...))pushViewport(fiewport(layout = grid = grid.layout(...)))pushViewport(viewport(layout.pos.row = ...,layout.pos.col)= ...))grid.draw(ht_grob)popviewport()...
您可以首先将行分为几个组,并在其上进行组级树状图。请参阅以下示例:
m =矩阵(rnorm(1000*10),nr = 1000)hc = hcclust(dist(m))group = cutree(hc,k = 6)heatmap(m,cluster_rows = cluster_within_group(t(m),组,组),,cluster_within_grouprow_split = 6,border = true)#如果还设置row_split会更好
热图用于在不是每个行或列时可视化矩阵的全局图案。我建议将随机的样品行或列随机成一个合理的小数,而最终的热图应看起来与您仍然坚持使用完整矩阵相同。
您需要使用decorate_row_dend()
或者decorate_column_dend()
手动添加轴。请参阅以下示例:
m =矩阵(rnorm(100),10)ht = hatmap(m,name =“ foo”,row_dend_width = unit(4,“ cm”),column_dend_height = uite(4,“ cm”))draw(ht,填充,填充,填充=单位(c(15,2,2,2),“ mm”))decorate_column_dend(“ foo”,{grid.yaxis()})docorate_row_dend(“ foo”,{vp = current.vercer.viewport()xscale = vp = VP$ xscale grid.xaxis(at = xscale [2] - 0:5,标签= 0:5)})
注意左行模拟图,X轴是从右到左的,您需要自定义在
和标签
在grid.xaxis()
功能。
您也可以检查Annotation_axis_grob()
功能(以后使用grid.draw()
绘制轴)以绘制更好的轴。
是的,这是应该期望的,因为K-均使用随机起点,并且可能会给不同的运行带来不同的结果。要解决这个问题,您可以按以下方式执行以下操作:
set.seed(...)
制作热图之前。这确保随机种子对于不同的运行始终相同。row_km_repeats
/column_km_repeats
多次运行K-均值以获得最终的共识K-均值聚类。请注意,您可能仍然会获得不同的结果,但是机会比仅运行K-均值一次要小得多。您需要将树状图分配给零行/列矩阵:
hc = hclust(dist(矩阵(rnorm(100),10)))热图(矩阵(nc = 0,nr = 10),cluster_rows = hc,right_annotation = rowannotation = rowannotation(foo = anno_points(1:10),sth = 1 = 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包裹。