jokergoo / ComplexHeatmap

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

Heatmap function always alphabetically plots the rows of the input matrix #1076

Open B-1991-ing opened 1 year ago

B-1991-ing commented 1 year ago

Hi Zuguang,

It is so strange that the Heatmap function doesn't give me the desired input row order when using the rowAnnotation.

What I want is that it directly plots the matrix, because I already sorted the matrix according to the frequency.

But, what I get now.

Screenshot 2023-04-22 at 16 09 05

It feels like the rowAnnotation function doesn't work at all no matter how to set it. If it works, the row annotation should be ordered by the frequency row annotation labels. I can send you my raw data and code to your email if necessary.

rownames_list <- rownames(d) rownames_list_split <- strsplit(rownames_list, ";") Phylum_names <- sapply(rownames_list_split, function(x) x[1]) rownames(d) <- Phylum_names

group1 = rep(c("Bacteroidota", "Proteobacteria", "Desulfobacterota", "Cyanobacteria", "Chloroflexota", "Acidobacteriota", .....), c(67,47,32,25,24,18,14,10,10,9,8,7,7,5,4,3,3,3,3,3,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1)) col_list = list(F = c("Bacteroidota"="#03045e", "Omnitrophota"="#0077b6", ......)) ha2 = rowAnnotation(F = Phylum_names, simple_anno_size = unit(0.3, "cm"), col=col_list, show_annotation_name = FALSE)

The row annotation function works on my other matrixes, but just not on this one. So strange.

Best,

Bing

jokergoo commented 1 year ago

Always make sure the order of annotations and the matrix match.

You can send me the data and code, then I will have a look.

B-1991-ing commented 1 year ago

Thank you very much for your reply.

Could you please give me your email address?