mortazavilab / PyWGCNA

PyWGCNA is a Python package designed to do Weighted Gene Correlation Network analysis (WGCNA)
https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btad415/7218311
MIT License
192 stars 46 forks source link

What other methods to define metadata colors are allowed, besides color labels ('black', 'pink', etc)? #91

Closed perseeker closed 4 months ago

perseeker commented 4 months ago

I'd like to not specify colors by hand, and instead use pre-made colormaps, like from maplotlib.cm. I tried to form a list of colors first, by using list([plt.cm.tab20b(j) for j in range(20)]) - this produces a list of 20 colors in format (x, y, z, 1) I then used this list to define colors for metadata categories in my pyWGCNA object, but ran into a problem - colors in this format are interpreted as an iterable instead of a single entry. In particular, when running analyseWGCNA(), function plotModuleEigenGene tries to broadcast the color as an object of length of 4 instead of 1 (line: color = np.where(color == n, self.metadataColors[m][n], color)) So I ask - is there a way to specify colors without using pre-set labels?

nargesr commented 4 months ago

Hi,

I believe you can use hex color codes as well. Basically, any single value parameter should be fine. I'm pretty sure you can convert this format to hex code through Matplotlib but please let me know if you still have the problem