Possible to choose network module colours?
Closed this issue · 3 comments
Really nice package! One thing I would like to do (and may be overlooking in documentation) is how to control the module colours. It seems that these are selected each run and sometimes they are hard to make out (lightyellow, lightcyan etc). Is there a way to control this?
I also find that producing the network statistics crashes R for me .
Hi, @sethbarr
Thank you for your kind feedback. Indeed, module colors are randomly selected. It seems that you have 2 problems related to module colors:
- Reproducibility: each time you run
exp2gcn()
, it will select different module colors. However, you can easily control this by setting a seed (e.g.,set.seed(123)
) before inferring the GCN. This will guarantee that module colors are always the same whenever you runexp2gcn()
. - "Ugly" colors: the reason why users cannot give custom colors as input is because the module detection algorithm often returns more than 20 different modules, and it is very hard to find a discrete color palette with that many distinguishable colors. Thus, choosing pre-defined colors would not solve this problem. However, note that all objects returned by BioNERO's functions are base R classes, and I did that to let users manipulate data as they wish. The result object from
exp2gcn()
is a list, and module assignment is stored in the data framegenes_and_modules
inside this list (see ?exp2gcn() for details). Thus, if you have a module color you find hard to visualize (e.g., lightcyan), you can manually replace it with a color of your preference with:
set.seed(123)
# Inferring network as in the function's example
data(filt.se)
gcn <- exp2gcn(filt.se, SFTpower = 18, cor_method = "pearson")
# Replace color "yellow" with "forestgreen"
gcn$genes_and_modules$Modules[gcn$genes_and_modules$Modules == "yellow"] <- "forestgreen"
This way, the "yellow" module will be replaced by "forestgreen", and you can plot a "forestgreen" network.
Regarding the network stats: as stated in the vignette, it takes a long time to run. I tested in a 16GB RAM machine and it worked. Perhaps it has something to do with your machine's power capacity.
Thanks @almeidasilvaf , I did have to change the colour in a few other places to get the axis colors to work for the eigen distance plot and some others.
net$MEs[net$MEs=="lightyellow"]<- "firebrick"
net$moduleColors[net$moduleColors=="lightyellow"]<- "firebrick"
net$genes_and_modules$Modules[net$genes_and_modules$Modules == "lightyellow"] <- "firebrick"
Glad to know you solved it, @sethbarr