EnrichedHeatmap icon indicating copy to clipboard operation
EnrichedHeatmap copied to clipboard

color for anno_enriched

Open olechnwin opened this issue 1 year ago • 2 comments

Hi, I am wondering if there is a way to tie the anno_enriched color to the row_split? For example, below if I set ngroup1 to 10, setting anno_enriched to the color of partition will correctly color the first group red.

load(system.file("extdata", "chr21_test_data.RData", package = "EnrichedHeatmap"))
mat3 = normalizeToMatrix(meth, cgi, value_column = "meth", mean_mode = "absolute",
                         extend = 5000, w = 50, smooth = TRUE)
ngroup1=10
partition=factor(c(rep("group1",ngroup1),rep("group2",nrow(mat3)-ngroup1)),levels=c("group1","group2"))
col.partition=c("red","blue")
names(col.partition)=levels(partition)
EnrichedHeatmap(mat3, name = "methylation", column_title = "methylation near CGI",row_split=partition,
                top_annotation = HeatmapAnnotation(lines = anno_enriched(gp = gpar(col = col.partition))))

image

However if there is no group 1, the color becomes red. I was expecting it to be blue for the group2. ngroup1=0 image

Thank you in advance for your help.

olechnwin avatar Sep 20 '22 14:09 olechnwin

I think you need to manually check how many groups are there in your data.

col.partition=c("group1" = "red", "group2" = "blue")

Then in EnrichedHeatmap():

anno_enriched(gp = gpar(col = col.partition[unique(as.vector(partition))]))

jokergoo avatar Sep 28 '22 14:09 jokergoo

I think you need to manually check how many groups are there in your data.

col.partition=c("group1" = "red", "group2" = "blue")

Then in EnrichedHeatmap():

anno_enriched(gp = gpar(col = col.partition[unique(as.vector(partition))]))

I'll do that. Thank you!

olechnwin avatar Sep 29 '22 15:09 olechnwin