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

Error in .analyseWGCNA() resulting from matplotlib .shrunk_to_aspect() #66

Closed VincentRagusa closed 8 months ago

VincentRagusa commented 8 months ago

I am following along with the network analysis tutorial, using my own data of course, and when I get to the .analyseWGCNA() step, I get the following error:

Analysing WGCNA... Calculating module trait relationship ... Traceback (most recent call last): File "/home/vincent/Documents/IDSeq_Microbiome/WGCNA.py", line 24, in pyWGCNA_microbiome.analyseWGCNA() File "/home/vincent/.local/lib/python3.10/site-packages/PyWGCNA/wgcna.py", line 388, in analyseWGCNA self.module_trait_relationships_heatmap(metaData=self.datExpr.obs.columns.tolist(), File "/home/vincent/.local/lib/python3.10/site-packages/PyWGCNA/wgcna.py", line 2775, in module_trait_relationships_heatmap res = sns.heatmap(self.moduleTraitCor.T, annot=labels, fmt="", cmap='RdBu_r', File "/home/vincent/.local/lib/python3.10/site-packages/seaborn/matrix.py", line 459, in heatmap plotter.plot(ax, cbar_ax, kwargs) File "/home/vincent/.local/lib/python3.10/site-packages/seaborn/matrix.py", line 340, in plot _draw_figure(ax.figure) File "/home/vincent/.local/lib/python3.10/site-packages/seaborn/utils.py", line 80, in _draw_figure fig.canvas.draw() File "/usr/local/lib/python3.10/dist-packages/matplotlib/backends/backend_agg.py", line 400, in draw self.figure.draw(self.renderer) File "/usr/local/lib/python3.10/dist-packages/matplotlib/artist.py", line 95, in draw_wrapper result = draw(artist, renderer, *args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/matplotlib/artist.py", line 72, in draw_wrapper return draw(artist, renderer) File "/usr/local/lib/python3.10/dist-packages/matplotlib/figure.py", line 3129, in draw artists = self._get_draw_artists(renderer) File "/usr/local/lib/python3.10/dist-packages/matplotlib/figure.py", line 221, in _get_draw_artists ax.apply_aspect(locator(ax, renderer) if locator else None) File "/usr/local/lib/python3.10/dist-packages/matplotlib/axes/_base.py", line 1933, in apply_aspect pb1 = pb.shrunk_to_aspect(self._box_aspect, pb, fig_aspect) File "/usr/local/lib/python3.10/dist-packages/matplotlib/transforms.py", line 545, in shrunk_to_aspect raise ValueError("'box_aspect' and 'fig_aspect' must be positive") ValueError: 'box_aspect' and 'fig_aspect' must be positive

My code is as bare-bones as it could get:

import PyWGCNA

countPath = "./mydata.csv"
pyWGCNA_microbiome = PyWGCNA.WGCNA(name="microbiome",
                                   species="",
                                   geneExpPath=countPath,
                                   outputPath="",
                                   save=True)

print(pyWGCNA_microbiome.geneExpr.to_df().head(5))

pyWGCNA_microbiome.runWGCNA()

pyWGCNA_microbiome.updateSampleInfo(path="./mymetadata.csv", sep=",")
pyWGCNA_microbiome.setMetadataColor("Visit",{'5':'red','7':'blue'})
pyWGCNA_microbiome.setMetadataColor("CaseEver",{'Case':'green','Control':'yellow'})

pyWGCNA_microbiome.analyseWGCNA()

Any advice would be appreciated.

VincentRagusa commented 8 months ago

My apologies, the issue seems to have been with my data formatting. Closing the issue.