Closed crazyhottommy closed 8 years ago
How different they are? Does it have anything to do with the monitor? In your case, the colors are mapped to discrete values and it has nothing to do with the color space (which means, the color is exactly one of c("#A6FFB6", "#33a1f6", "#d16303", "#322f64")
). The color space only matters if more colors are interpolated from a list of certain colors. E.g. if red (#FF0000
) is mapped to 1, white (#FFFFFF
) is mapped to 0, green (#00FF00
) is mapped to -1, the color of 0.5 is linearly interpolated in a certain color space. If it is in sRGB color space, the color for 0.5 is #FF8080
, which is (oxFF0000 + oxFFFFFF)/2
, while in LAB space, the color of 0.5 becomes "#FF9E81FF"
.
Hi Zuguang,
Please see here http://rpubs.com/crazyhottommy/heatmap_demystified
In the heatmaps with top annotations, I set the color either by RcolorBrewer or manually, but they all do not look the same in the Heatmap
as in their own. Initially I did not pay much attention, then I found they really look different when I want to reproduce the figures in the paper trying to use the same colors. In the PCA plot (which I use ggplot2) you will see the colors match though . Wondering if it is a ComplexHeatmap
issue.
Best, Ming
Here cell.name
should be cell.line
because the column in df.brain
is cell.line
.
change
ha.brain<- HeatmapAnnotation(df = df.brain,
col = list(cell.name = cell.cols.assigned))
to
ha.brain<- HeatmapAnnotation(df = df.brain,
col = list(cell.line = cell.cols.assigned))
great catch!! It was my mistake, but glad I learned some on color space. I will fix it.
Thanks! Tommy
Now I updated the package a little bit that if the color is defined while no corresponding annotations, there will be warnings.
a warning would be better than silence. thx!
A side question, in the link I posted where I created a heatmap with
Heatmap(Y[genes.3PC, ], name = "log2 RNAseq\ncounts scaled",
col = colorRamp2(c(-10, 0, 10), c("Darkblue", "white", "red")),
show_row_names = FALSE,
show_column_names = FALSE,
row_dend_reorder = TRUE, column_dend_reorder = FALSE,
clustering_distance_rows = "pearson",
clustering_distance_columns = "euclidean",
clustering_method_rows = "complete",
clustering_method_columns = "complete",
top_annotation = ha.brain,
gap = unit(0.5, "mm"))
How do I manually rotate the dendrogram at the very right corner to flip the brown and green cluster so it looks better? Note that I used column_dend_reorder = FALSE
but if I specify TRUE, it looks even more different than the original figure in the paper.
I know dendersort
and dendextend
can do something like that, not sure how to do it exactly in ComplexHeatmap
.
Thanks! Ming
If column_dend_reorder
is set to TRUE
, it will call reorder.dendrogram()
which reorders or rotate the branches of the dendrogram according the the column mean of the matrix.
If you want to customize the rotation of the dendrogram, you need to first generate a dendrogram
object, then send to cluster_columns
. E.g:
column_dend = as.dendrogram(hclust(dist(t(mat))))
# rotate the branches by e.g. `rotate()` in dendextend
column_dend = rotate(column_dend, ...)
Heamtap(..., cluster_columns = column_dend)
Thanks for the tip!
Hi,
I want to manually set colors for my heatmap annotation. The problem is that the colors do not look the same using the color picked from http://www.color-hex.com/
I guess ComplexHeatmap use LAB color space by default, how can I convert to RGB color space? Thanks! Ming