ComplexHeatmap icon indicating copy to clipboard operation
ComplexHeatmap copied to clipboard

Heatmap function always alphabetically plots the rows of the input matrix

Open B-1991-ing opened this issue 1 year ago • 2 comments

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

B-1991-ing avatar Apr 21 '23 19:04 B-1991-ing

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.

jokergoo avatar Jun 05 '23 19:06 jokergoo

Thank you very much for your reply.

Could you please give me your email address?

B-1991-ing avatar Jun 05 '23 20:06 B-1991-ing