jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.3k stars 230 forks source link

no applicable method for 'as.dendrogram' #595

Closed akhst7 closed 4 years ago

akhst7 commented 4 years ago

I created the heatmap with a following;

o1.mds<-seriate(dist(n5.merged.df[1:73,]), method = "MDS") o2.mds<-seriate(dist(t(n5.merged.df[1:73,])), method = "MDS")

Heatmap(as.matrix(n5.merged.df[1:73,]),cluster_rows = F,cluster_columns = F,row_order = get_order(o1.mds),column_order = get_order(o2.mds) ,row_names_gp = gpar(fontsize=8), column_names_gp = gpar(fontsize=10, column_names_rot = 90, column_names_centered = T), column_title = "Heatmap with serration", name="Subset")

I want to add only the column dendrogram ;

Heatmap(as.matrix(n5.merged.df[1:73,]),cluster_rows = F, cluster_columns = as.dendrogram(o2.mds[[1]]), row_order = get_order(o1.mds), column_order = get_order(o2.mds) ,row_names_gp = gpar(fontsize=8), column_names_gp = gpar(fontsize=10, column_names_rot = 90, column_names_centered = T), column_title = "Heatmap with serration", name="Subset")

but I get this following error message;

Error in UseMethod("as.dendrogram") : 
  no applicable method for 'as.dendrogram' applied to an object of class "c('ser_permutation_vector', 'integer')"

Any way to address this issue ?

Thanks.

akhst7 commented 4 years ago

MDS doesn't produce a seriation matrix unlike other methods, and therefore, it can't be used to generate the dendrogram.

jokergoo commented 4 years ago

Yes, you cannot get the dendrogram from a seriation object, but you can obtain the ordering by get_order() function (https://www.rdocumentation.org/packages/seriation/versions/1.2-8/topics/get_order) and assign to row_order/column_order argument in Heatmap().