Complex Heatmap

I want to reorder the column clusters in the complex heatmap. For example: I want cluster 0, 1 ,3 ,2 and then 4, 5 and 6 in the heatmap. I am attaching my code and heatmap here. Please let me know how can I do that. The clusters are form Seurat object.

Below is my code and the heatmap that I want to reorder:

markers<- read.csv("markers.csv")
markers %>% group_by(cluster) %>% top_n(n = 15, wt = avg_log2FC) -> top15
toplot_gene<- top15$gene
mat<- combined[["RNA"]]@data[toplot_gene, ] %>% as.matrix()
mat<- t(scale(t(mat)))
head(mat)

cluster_anno<- combined@meta.data$seurat_clusters
head(combined@meta.data)

myCol <- colorRampPalette(c('dodgerblue', 'black', 'yellow'))(50)
myBreaks <- seq(-2, 2, length.out = 50)

Heatmap(mat, name = "Expression",  
        column_split = factor(cluster_anno),
        cluster_columns = TRUE,
        show_column_dend = FALSE,
        cluster_column_slices = TRUE,
        column_title_gp = gpar(fontsize = 8),
        column_gap = unit(0.5, "mm"),
        cluster_rows = FALSE,
        show_row_dend = FALSE,
        col = colorRamp2(myBreaks, myCol),
        row_names_gp = gpar(fontsize = 6),
        column_title_rot = 90,
        top_annotation = HeatmapAnnotation(foo = anno_block(gp = gpar(fill = scales::hue_pal()(9)))),
        show_column_names = FALSE,
        use_raster = TRUE)

enter image description here

Read more here: Source link