首页 > 解决方案 > 使用 ComplexHeatmap 包创建行注释时,R 找不到函数 anno_simple()

问题描述

我正在尝试创建一个包含 p 值的行注释的热图,如使用 ComplexHeatmap 包指南中的示例中所述(https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap- annotations.html#simple-annotation)。

我试图重现这个例子:

library(ComplexHeatmap)
library(circlize)  # colorRamp2 function

set.seed(123)
pvalue = 10^-runif(10, min = 0, max = 3)
is_sig = pvalue < 0.01
pch = rep("*", 10)
pch[!is_sig] = NA

# color mapping for -log10(pvalue)
pvalue_col_fun = colorRamp2(c(0, 2, 3), c("green", "white", "red"))
ha = HeatmapAnnotation(
   pvalue = anno_simple(-log10(pvalue), col = pvalue_col_fun, pch = pch),
   annotation_name_side = "left")
ht = Heatmap(matrix(rnorm(100), 10), name = "mat", top_annotation = ha)

# now we generate two legends, one for the p-value
# see how we define the legend for pvalue
lgd_pvalue = Legend(title = "p-value", col = pvalue_col_fun, at = c(0, 1, 2, 3),
   labels = c("1", "0.1", "0.01", "0.001"))

# and one for the significant p-values
lgd_sig = Legend(pch = "*", type = "points", labels = "< 0.01")

# these two self-defined legends are added to the plot by `annotation_legend_list`
draw(ht, annotation_legend_list = list(lgd_pvalue, lgd_sig))

但是当我创建注释时,ha我得到了错误

Error in anno_simple(-log10(pvalue), col = pvalue_col_fun, pch = pch) :
 could not find function "anno_simple"

可能显示包装可能存在问题。我正在运行的 ComplexHeatmap 包的版本是 1.20.0。R 版本是 3.5.1。

你能帮我解决这个问题吗?

谢谢

标签: rannotationsheatmap

解决方案


推荐阅读