How can I draw a barplot of complexheatmap according 'Tumor Type'
1
1
Entering edit mode
Sooni ▴ 10
@fcaec06f
Last seen 3 months 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 • 1.4k views
ADD COMMENT
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?

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
@elefthpavlos-21392
Last seen 5 months 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

ADD COMMENT

Login before adding your answer.

Traffic: 574 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6