jokergoo / ComplexHeatmap

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

save dendrogram & annotation track (without heatmap) #301

Closed itsvenu closed 5 years ago

itsvenu commented 5 years ago

Hi Zuguang,

As title says, I would like to save column dendrogram and annotation to pdf. I didn't find any info in the manual regarding this (or did I miss anything?). Is it possible yet all?

Thanks a lot for the awesome package.

jokergoo commented 5 years ago

What do you mean by "to save column dendrogram and annotation to pdf"? Do you mean to save the whole plot as a PDF? If so, just put pdf() in front of your heatmap calls:

pdf(...)
Heatmap(...)
dev.off()
itsvenu commented 5 years ago

Thanks for the reply. I would like to save only dendrogram and annotation track without heatmap. Somethings like this: this, adding colored bars

Thank you.

jokergoo commented 5 years ago

It is not supported yet, but I've added it to my future plan.

itsvenu commented 5 years ago

aw, alright then. Thank you.

jokergoo commented 5 years ago

Or you can treat the heatmap annotations as heatmaps. Compare following two heatmaps:


m = matrix(rnorm(100), 10)
dend = as.dendrogram(hclust(dist(t(m))))

Heatmap(m, cluster_columns = dend, 
    top_annotation = HeatmapAnnotation(foo = 1:10, bar = anno_barplot(1:10)))

# take the first heatmap annotation as a normal heatmap (one-row heatmap)
Heatmap(rbind(1:10), cluster_columns = dend, height = unit(5, "mm"), 
    top_annotation = HeatmapAnnotation(bar = anno_barplot(1:10)))
itsvenu commented 5 years ago

That trick seems to do what I want. Thanks a lot.

jokergoo commented 5 years ago

I've updated the package. Now you just set a zero-row or zero-column matrix to the heatmap. See the following example:

hc = hclust(dist(matrix(rnorm(100), 10)))
Heatmap(matrix(nc = 0, nr = 10), cluster_rows = hc, 
    right_annotation = rowAnnotation(
        foo = anno_points(1:10),
        sth = 1:10,
        bar = anno_barplot(1:10)),
    row_split = 2)
itsvenu commented 5 years ago

Hi Zuguang,

this is really awesome. Thanks a lot. Should I install directly from github?

jokergoo commented 5 years ago

Yes.

iranmdl commented 2 years ago

Hi @jokergoo ! Sorry for commenting on this old closed issue, let me know if I should open a new one. I have done what suggested here, and I manage to get my dendogram without heatmap, however, it seems that the dendo is missing the labels? Is there anyway to put them back? Thank you in advance

jokergoo commented 2 years ago

Hi @iranmdl , can you post it in a new issue and also add code and plot there? Then I will have a look.