How can I draw a barplot of complexheatmap according 'Tumor Type'
Entering edit mode
Sooni ▴ 10
Last seen 11 hours ago
South Korea

I drew a heatmap using 'ComplexHeatmap' package. I want to draw barplots grouped by 'Tumor Type'.

Here is my code.

ha1 <- HeatmapAnnotation("Tumor Type" = pheno.df$sample_type.samples,
                     col = list("Tumor Type" = c("Primary Tumor" = "#B9061F",
                                                 "Solid Tissue Normal" = "#FFDC3C")))

Heatmap(mat_scaled, name = "Expression", col = colorRamp2(c(-2, 0, 2), c("blue", "white", "red")),
    cluster_columns = T, show_column_names = F, show_row_names = F, cluster_rows = T,
    top_annotation = ha1)

And here is my heatmap.

How can I solve this problem?

heatma heatmaps ComplexHeatmap • 112 views
Entering edit mode

Can you explain what you mean by 'barplots grouped by tumor type'? Are you saying you want the columns of the heatmap ordered to keep the tumor types together, or do you want to add a barplot as an annotation for the columns?

Entering edit mode

I want the columns of the heatmap ordered to keep the tumor types together.

Entering edit mode
Last seen 6 days ago
BRFAA Athens, Greece

Hi Sooni,

One easy way to accomplish this, is to have the data frame you use in Heatmap function (in this case mat_scaled) in the preferred order i.e., first the Primary Tumor columns and then the Solid Tissue Normal or vice versa and change to FALSE the cluster_columns argument.

You'll probably need to change the order of the dataframe pheno.df used in the HeatmapAnnotation function,

Keep in mind that use of cluster_columns = T changes the order of your dataframe's columns according to the clustering algorithm, same for cluster_rows.

Hope this will help you


Login before adding your answer.

Traffic: 524 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6