Open KGZaker opened 3 months ago
Hi, Thank you for your kind comments:)
I will update the Data_format in the next week to reflect changes (I will notify you through this issue).
thanks for catching this :)
Thanks for your quick reply. Sorry, I may still have a naive question😂. Regarding the second solution, I attempted the following codes, but encountered an error: AttributeError: 'ScalarMappable' object has no attribute 'keys'
.
import matplotlib as mpl
norm = mpl.colors.Normalize(vmin=min(adata.obs['age']),
vmax=max(adata.obs['age']))
cmap = mpl.colormaps['viridis']
pyWGCNA.setMetadataColor('age', mpl.cm.ScalarMappable(norm, cmap))
pyWGCNA.analyseWGCNA(geneList=adata.var)
Hi @KGZaker,
I believe I used the same script! lol can you send me the full error?
import matplotlib as mpl
norm = mpl.colors.Normalize(vmin=adata.obs['age'].min(),
vmax=adata.obs['age'].max())
my_palette_age = mpl.cm.ScalarMappable(norm=norm, cmap='viridis')
Hi, thanks for helping me figure out what's wrong. Here is the code I used and errors I got:
pyWGCNA.updateSampleInfo(adata.obs[["sex", "age"]])
norm = mpl.colors.Normalize(vmin=adata.obs['age'].min(), vmax=adata.obs['age'].max())
my_palette_age = mpl.cm.ScalarMappable(norm=norm, cmap='viridis')
pyWGCNA.setMetadataColor('age', my_palette_age)
pyWGCNA.barplotModuleEigenGene(moduleName="white", metadata=["age"])
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[229], line 1
----> 1 pyWGCNA.barplotModuleEigenGene(moduleName="white", metadata=["age"])
File [~/micromamba/envs/macbiom/lib/python3.11/site-packages/PyWGCNA/wgcna.py:3028](http://localhost:8889/~/micromamba/envs/macbiom/lib/python3.11/site-packages/PyWGCNA/wgcna.py#line=3027), in WGCNA.barplotModuleEigenGene(self, moduleName, metadata, combine, colorBar, show)
3026 height_ratios = []
3027 for m in metadata:
-> 3028 height_ratios.append(len(list(self.metadataColors[m].keys())))
3029 height_ratios.reverse()
3031 modules = np.unique(self.datExpr.var['moduleColors']).tolist()
AttributeError: 'ScalarMappable' object has no attribute 'keys'
Hi @KGZaker
I just released the new version (2.0.4) which hopefully will solve your problem. Please upgrade the PyWGCNA and let me know if you still have the same problem
Hi @nargesr , thanks so much for your time and kind help. Now everything works well in the new version.
Hello @nargesr . I also want to setup this one. But I still meet the error: "'ScalarMappable' object has no attribute 'keys'". And I'm using 2.0.4 the new version. How to get it corrected?
Hi @realzhipeng
could you please provide me with the script you used and the full error you got?
Thanks
@nargesr , Yes. Actually, I'm using the above code that you shared with KGZaker.
pyWGCNA_datset.setMetadataColor('Sex',` {'F': 'Pink',
'M': 'blue'})
norm = mpl.colors.Normalize(vmin=df_sampleids_expr['Age'].min(), vmax=df_sampleids_expr['Age'].max())
my_palette_age = mpl.cm.ScalarMappable(norm=norm, cmap='viridis')
pyWGCNA_datset.setMetadataColor("Age",my_palette_age)
Additionally, df_sampleids_expr is:
And the error after run pyWGCNA_datset.analyseWGCNA()
:
Let me know if you need the more detail.
Firstly, thanks so much for developing such a useful tool. It has been immensely helpful in my research. However, I've encountered a couple of challenges that I hope you could assist me with:
I came across the following description in the Data_format.md:
Based on this: if the rows of the sample metadata and the rows of the gene expression matrix are not in the same order, or if the columns of the gene metadata and the rows of the gene expression matrix are not in the same order, in which function should I specify
order=False
? Should it be inpyWGCNA.analyseWGCNA()
or do I need to specify it in other functions likePyWGCNA.WGCNA
,pyWGCNA.preprocess()
, orpyWGCNA.findModules()
? I tried usingpyWGCNA.analyseWGCNA(order=False)
, but I encountered the following error:TypeError: 'bool' object is not iterable
.It appears that I need to first specify colors using
pyWGCNA.setMetadataColor
before I can correctly callpyWGCNA.analyseWGCNA()
. However, in the step ofpyWGCNA.setMetadataColor()
, does it only support categorical variables and not continuous variables, which means I need to convert continuous variables into categorical ones?Thank you sooooo much for your time and assistance.