Question: How to change colors for each column in the heatmap using "complexheatmap" package?
0
gravatar for Vasu
2.1 years ago by
Vasu420
Vasu420 wrote:

Hi,

I have a dataframe "df" like following:

 Sample ID  G1  G2  G3  G4  G5  G6
S1  3       1   1   2   1
S2  2       1   2   1   1
S3  3       2   1   1   1
S4  2   2   1   1   1   1
S5  3       2   1   1   1
S6  2       1   1   2   1
S7  3   3   1   2   1   1
S8  4       2   1   1   1
S9  3       1   2   2   1
S10 2   3   2   2   1   1
S11 2       1   2   4   1
S12 3       2   1   2   1
S13 2       2   1   1   1

I'm using "complexheatmap" R package to generate a heatmap.

plot <- data.frame(df[,-1], row.names=df[,1])

library(ComplexHeatmap)
library(circlize)

pdf("plot.pdf", width=5, height=6.5)
Heatmap(plot, show_row_names = TRUE, show_column_names = TRUE, cluster_rows = FALSE,
        cluster_columns = FALSE,show_column_dend = FALSE,show_row_dend = FALSE) 
dev.off

This gave me a heatmap like - https://imgur.com/a/HMVOH

My Question:

How can I assign different colors for each column. And how to give different legend for each column. I want to give different colors and legend for (3,2,4) in G1 column and different colors and legend for (1,2) in G3 column and different colors and legend for (1,2) in G4 column. And also different Legend headings for different columns.

How to do this?

Thank you

ADD COMMENTlink modified 2.1 years ago by Kevin Blighe54k • written 2.1 years ago by Vasu420
1

Hi Bioinfo,

Deleting a question after someone spend time helping you is unnecessary and rude. I have restored this thread.

Wouter

ADD REPLYlink written 2.1 years ago by WouterDeCoster43k
0
gravatar for Kevin Blighe
2.1 years ago by
Kevin Blighe54k
Kevin Blighe54k wrote:

That is done by setting the col parameter to Heatmap(). Take a look at my examples:

ADD COMMENTlink written 2.1 years ago by Kevin Blighe54k

No, This is not what I want. I would like to generate a plot showing G1- G6 and each column showing different colors for each values. And the legend needs to be different for each column.

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by Vasu420

You mean a color bar, like this: C: how to cluster genes in heatmap ?

THe plot that you showed is an Oncoprint, not a Heatmap. Oncoprints can be difficult to generate, but I suggest that you start by looking here: OncoPrint. You can also merge multiple oncoprints together. I recently developed a very complex oncoprint that has 100s of lines of R code.

ADD REPLYlink written 2.1 years ago by Kevin Blighe54k

But without Oncoprint, I got know how to do this.

Heatmap(plot[, 1]) + Heatmap(plot[, 2]) + Heatmap(plot[, 3]) + others...

This way heatmap for each column can be made and different colors for each column can also be given.

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by Vasu420
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1102 users visited in the last hour