enrichplot icon indicating copy to clipboard operation
enrichplot copied to clipboard

Is it possible to change color of nodes for cnetplot.compareClusterResult

Open alexyfyf opened this issue 3 years ago • 1 comments

Hi Dr Yu,

Is it possible to change color of nodes for cnetplot.compareClusterResult and emapplot.compareClusterResult? By default the nodes are colored based on clusters, using ggplot color scheme. For example: image

However, when one or more clusters don't have enriched terms, the color will automatically adjust. For example: image In this case the color is different from the previous one, although in the same dataset. This inconsistency makes data interpretation difficult.

Is it possible to provide a fixed color for the clusters provided? Sorry if I missed it in you manual, but I really cannot get my head around it.

Thank you.

alexyfyf avatar Oct 14 '20 03:10 alexyfyf

Hello @alexyfyf,

I had the same question and found out that cnetplot returns a ggplot2 object, so we can use the same modifiers as we use for regular visualization. Check the example below based on the vignette example

library(org.Hs.eg.db)
library(clusterProfiler)

data(gcSample)
ck <- compareCluster(geneCluster = gcSample, fun = enrichKEGG)
ck <- setReadable(ck, OrgDb = org.Hs.eg.db, keyType="ENTREZID")
cnetplot(ck)
cnetplot(ck) + scale_fill_grey(start=0.8, end=0.2)
cnetplot(ck) + scale_fill_manual(values = rainbow(length(gcSample)))

lljotall avatar Nov 08 '22 18:11 lljotall