jokergoo / ComplexHeatmap

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

row_split reorders row_order even with cluster_row_slices = FALSE #959

Open ojziff opened 2 years ago

ojziff commented 2 years ago

Hi @jokergoo

I am unable to control the heatmap ordering when using row_split and row_order even when specifying cluster_row_slices = FALSE. The row order is correct when I don't specify row_split.

 Heatmap(mat,
          row_order = topVar$gene_name,
          show_row_names = FALSE, 
          row_split =  factor(topVar$database, levels = c(1,2)),
          right_annotation = rowAnnotation(markers = anno_block(gp = gpar(fill = c("white", "white")), labels = c("1 markers", "2 markers"), labels_gp = gpar(fontsize = 8))), row_title = NULL,
          column_order = marker.column_order$sample,
          column_split = factor(marker.column_order$fraction, levels = c("cyto", "nuc", "who")),
          bottom_annotation = HeatmapAnnotation(markers = anno_block(gp = gpar(fill = c("white", "white", "white")), labels = c("Cyto samples", "Nuc samples", "Who samples"), labels_gp = gpar(fontsize = 8))), column_title = NULL,
          column_names_gp = gpar(fontsize = 6),
          cluster_row_slices = FALSE, cluster_column_slices = FALSE, cluster_columns = FALSE,cluster_rows = FALSE,
          border = TRUE, heatmap_legend_param = list(title = "", direction = "vertical"))

I have exactly the same issue with column_split

Please could you advise how I can set the row/column order whilst using row/column split.

I am using ComplexHeatmap_2.13.1

Many thanks! Oliver

jokergoo commented 2 years ago

The row ordering should be kept in each row slice.

Can you send me the data, i.e., mat and topVar?

blueskypie commented 2 years ago
row_split =  factor(topVar$database, levels = c(1,2))
cluster_rows = FALSE
cluster_row_slices = FALSE

The order of the slices will be defined by the order of topVar$database. Within each slice, the row ordering should be kept.

ojziff commented 2 years ago

Thanks @blueskypie but those arguments are already set and the row ordering is lost with row_split = factor(topVar$database, levels = c(1,2))

blueskypie commented 2 years ago

by the row ordering is lost, do you mean the order of the slice is different from the order of topVar$database? or do you mean that, within each slice, the order of the rows are different from your expectation?

jokergoo commented 2 years ago

@ojziff I think it would be great if you can also attach the plot and explain your issue.

aspides-js commented 1 month ago

Hi @jokergoo I was getting the same issue. Using row_split seems to revert the order of rows back to the original mat, which can be circumvented by ordering mat by row_order before using Heatmap.