【问题标题】:plot heatmap of data after clustering in R在 R 中聚类后绘制数据的热图
【发布时间】:2013-11-25 11:11:45
【问题描述】:

我正在尝试在聚类后创建矩阵的热图。

heatmap(r.matrix, 
        distfun = dist(r.matrix, method="euclidean"), 
        hclustfun = hclust(dist(r.matrix, method="euclidean"), method ="ward"))

我在热图的帮助信息之后使用了上述命令,但返回以下错误信息:

Error in heatmap(r.matrix, distfun = dist(r.matrix, method = "euclidean"),  :
                 could not find function "hclustfun"

如何进行聚类,绘制聚类数据的热图,同时保留树状图?我可能没有很好地理解参数列表中的函数。

【问题讨论】:

    标签: r heatmap hierarchical-clustering


    【解决方案1】:

    distfunhclustfun 参数应该是函数。您正在传递这些函数的 results,并且由于结果本身不是函数,因此会引发错误。例如,您知道apply 想要一个函数作为其第三个参数吗?然后它自己调用那个函数? heatmap也是一样的。

    试试这个:

    heatmap(r.matrix, distfun=dist, hclustfun=function(d) hclust(d, method="ward"))
    

    实际上,由于dist 是默认参数(参见?heatmap),您可以在函数调用中省略distfun。您必须为hclust 创建匿名函数的唯一原因是默认方法不是“ward”。

    heatmap(r.matrix, hclustfun=function(d) hclust(d, method="ward"))
    

    【讨论】:

      猜你喜欢
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多