This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to order columns of heatmap as they are in matrix data

Dear All,

I made a complex heatmap using complexheatmap package of R. I want to order columns of the heatmap based on order in my matrix data.

Any idea?

this is heatmap command I run:

hmap <- Heatmap(heat, name="Z-score",col=colorRamp2(myBreaks, myCol), column_order = samplesnames, cluster_columns = FALSE, heatmap_legend_param=list(color_bar="continuous", legend_direction="horizontal", legend_width=unit(3,"cm"), title_position="topcenter", title_gp=gpar(fontsize=10, fontface="bold")), split=df$EffectorName, cluster_rows=TRUE, show_row_dend=TRUE, row_title="Transcript", row_title_side="left", row_title_gp=gpar(fontsize=5, fontface="bold"), show_row_names=TRUE, row_names_side="left", row_title_rot=0,  show_column_dend=TRUE, column_title="Samples", column_title_side="top", column_title_gp=gpar(fontsize=10, fontface="bold"), column_title_rot=0, show_column_names=TRUE, clustering_distance_columns=function(x) as.dist(1-cor(t(x))), clustering_method_columns="ward.D2", column_dend_height=unit(5,"mm"), clustering_distance_rows="euclidean", clustering_method_rows="ward.D2", row_dend_width=unit(5,"mm"), top_annotation_height=unit(0.5,"cm"), top_annotation=ColAnn, bottom_annotation_height=unit(1, "cm"), bottom_annotation=boxAnnCol)
rna-seq r rna-seq

This is a continuation of the discussion, here: C: Heatmap based with FPKM values (the discussion became too long and off topic).

Mehmet, can you please again paste a sample of your data and the Heatmap() command that you are using so that everyone else can see. The ordering functions that I mention do work, as I use them a lot, but there must be some problem with your data and/or the way that you are executing the Heatmap() function.

When you paste your data, make sure that it looks presentable to others!

Thanks.

I don't know how to paste data as it is readable. Please follow the previous topic (Heatmap based with FPKM values).

Hi Kevin,

Now it is okay, I figured it out.

Here is my command:

hmap <- Heatmap(heat, name="Z-score",col=colorRamp2(myBreaks, myCol), cluster_columns = FALSE, heatmap_legend_param=list(color_bar="continuous", legend_direction="horizontal", legend_width=unit(3,"cm"), title_position="topcenter", title_gp=gpar(fontsize=10, fontface="bold")), split=df$EffectorName, cluster_rows=TRUE, show_row_dend=TRUE, row_title="Transcript", row_title_side="left", row_title_gp=gpar(fontsize=5, fontface="bold"), show_row_names=TRUE, row_names_side="left", row_title_rot=0,  show_column_dend=TRUE, column_title="Samples", column_title_side="top", column_title_gp=gpar(fontsize=10, fontface="bold"), column_title_rot=0, show_column_names=TRUE, clustering_distance_columns=function(x) as.dist(1-cor(t(x))), clustering_method_columns="ward.D2", column_dend_height=unit(5,"mm"), clustering_distance_rows="euclidean", clustering_method_rows="ward.D2", row_dend_width=unit(5,"mm"), top_annotation_height=unit(0.5,"cm"), top_annotation=ColAnn, bottom_annotation_height=unit(1, "cm"), bottom_annotation=boxAnnCol)

Thank you very very very much......

Glad that you got it working! Now you see why it is called 'complex' heatmap! :)

1 answer

Heatmap(matrix_data, cluster_columns = FALSE)

It worked perfectly.

Log in to answer this question.