How can I draw a barplot of complexheatmap according 'Tumor Type'
1
1
Entering edit mode
Sooni ▴ 10
@fcaec06f
Last seen 2 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 • 191 views
0
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?

0
Entering edit mode

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

1
Entering edit mode
@elefthpavlos-21392
Last seen 8 weeks 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.