jokergoo / EnrichedHeatmap

make enriched heatmap which visualizes the enrichment of genomic signals to specific target regions.
http://jokergoo.github.io/EnrichedHeatmap/
Other
185 stars 25 forks source link

color for anno_enriched #72

Open olechnwin opened 1 year ago

olechnwin commented 1 year ago

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.

jokergoo commented 1 year ago

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))]))
olechnwin commented 1 year ago

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!