Skip to content

barplotModuleEigenGene() Error w/ Tutorial and Data - colorBar #143

@park-minjun

Description

@park-minjun

I'm running analyseWGCNA() from Quick_Start.ipynb and I run across this error even with the tutorial:

----> 1 pyWGCNA_5xFAD.analyseWGCNA()

File ~/***/.venv/lib/python3.12/site-packages/PyWGCNA/wgcna.py:470, in WGCNA.analyseWGCNA(self, order, geneList, show, alternative)
468 else:
469 for module in modules:
--> 470 self.barplotModuleEigenGene(module, metadata, colorBar=metadata[-1], show=show)
471 print("\tDone..\n")
473 if self.save:

File ~/***/.venv/lib/python3.12/site-packages/PyWGCNA/wgcna.py:3133, in WGCNA.barplotModuleEigenGene(self, moduleName, metadata, combine, colorBar, show)
3131 else:
3132 palette = cat[[colorBar]].copy()
-> 3133 palette[[colorBar]] = palette[[colorBar]].astype('int')
3134 palette[colorBar] = palette[colorBar].apply(lambda x: mcolors.to_hex(self.metadataColors[colorBar].to_rgba(float(x))) if pd.notna(x) else "#FFFFFF")
3135 palette = palette[colorBar].values

File ~/***/.venv/lib/python3.12/site-packages/pandas/core/generic.py:6662, in NDFrame.astype(self, dtype, copy, errors)
6656 results = [
6657 ser.astype(dtype, copy=copy, errors=errors) for _, ser in self.items()
6658 ]
6660 else:
6661 # else, only a single dtype is given
...
132 # Explicit copy, or required since NumPy can't view from / to object.
--> 133 return arr.astype(dtype, copy=True)
135 return arr.astype(dtype, copy=copy)

ValueError: invalid literal for int() with base 10: '5xFADHEMI'

All metadata properly updated, followed step by step. Tracing back I'm not sure why colorBar argument is set as metadata[-1] as metadata seems to be self.datExpr.obs.columns.tolist() which makes this a list of columns and the colorBar is theoretically expecting a dictionary.

Thank you so much for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions