Reputation: 10820
I want to change the clustering method that heatmap.2 uses for the hierarchical clustering. It uses hclust by default, which I want to keep using, but hclust uses the "complete" method and I want to do "average". Heatmap.2 has an hclustfun parameter, but I can't figure out how to use it. I tried
heatmap.2(..., hclustfun=hclust(method="average"))
but it gave an error that the 'd' argument is required. Heatmap.2 does it's own distance calculation that can be specified with the distfun parameter. I'm not sure how to somehow pass the distances to hclust, or how else to specify a parameter to be passed to hclust.
Upvotes: 1
Views: 1149
Reputation: 48211
You are really close. As hclustfun
needs to be a function, the parameter value should indeed be a function, while hclust(method = "average")
is calling hclust
without specifying d
. Meanwhile,
heatmap.2(x, hclustfun = function(d) hclust(d, method = "average"))
works.
Upvotes: 1