Code Monkey home page Code Monkey logo

Comments (13)

nargesr avatar nargesr commented on July 26, 2024 1

Hi,
Thank you for your kind comments:)

  1. you need to specify this when you update your metadata. but I just realized I updated it in a way you don’t need to specify it. the only key import thing is that the index should match and it will update it based on the index
    for more information look at the updateGeneInfo() and updateSampleInfo().

I will update the Data_format in the next week to reflect changes (I will notify you through this issue).

thanks for catching this :)

  1. if you have a continuous value you can pass the color as a color palette using matplotlib.cm.ScalarMappable.

from pywgcna.

KGZaker avatar KGZaker commented on July 26, 2024 1

Hi @nargesr , thanks so much for your time and kind help. Now everything works well in the new version.

from pywgcna.

KGZaker avatar KGZaker commented on July 26, 2024

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)

from pywgcna.

nargesr avatar nargesr commented on July 26, 2024

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')

from pywgcna.

KGZaker avatar KGZaker commented on July 26, 2024

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'

from pywgcna.

nargesr avatar nargesr commented on July 26, 2024

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

from pywgcna.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.