Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot issue (Image size is too large) #115

Open
nliorni opened this issue Aug 15, 2024 · 1 comment
Open

Plot issue (Image size is too large) #115

nliorni opened this issue Aug 15, 2024 · 1 comment

Comments

@nliorni
Copy link

nliorni commented Aug 15, 2024

Hi!

I used pyWGCNA on a count matrix containing 3000+ samples. I have an error at analyseWGCNA(), where at the "plotting module heatmap eigengene" I get:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[25], line 1
----> 1 a.analyseWGCNA()

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/PyWGCNA/wgcna.py:433, in WGCNA.analyseWGCNA(self, order, geneList, show, alternative)
    431     print(f"{OKCYAN}plotting module heatmap eigengene...{ENDC}")
    432     for module in modules:
--> 433         self.plotModuleEigenGene(module, metadata, show=show)
    434     print("\tDone..\n")
    436 if self.save:

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/PyWGCNA/wgcna.py:2961, in WGCNA.plotModuleEigenGene(self, moduleName, metadata, show)
   2958     axs[1, 0].set_facecolor('white')
   2960     cmap = sns.color_palette("dark:red", as_cmap=True)
-> 2961     sns.heatmap(heatmap, cmap=cmap,
   2962                 cbar=False,  # cbar_ax=axs[2,1],
   2963                 yticklabels=False, xticklabels=False,
   2964                 ax=axs[2, 0])
   2965 else:
   2966     fig, axs = plt.subplots(nrows=2, ncols=1, figsize=(ME.shape[0], 20),
   2967                             sharex='col', gridspec_kw={
   2968             'height_ratios': [1, 1.5]}, facecolor='white')

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/seaborn/matrix.py:459, in heatmap(data, vmin, vmax, cmap, center, robust, annot, fmt, annot_kws, linewidths, linecolor, cbar, cbar_kws, cbar_ax, square, xticklabels, yticklabels, mask, ax, **kwargs)
    457 if square:
    458     ax.set_aspect("equal")
--> 459 plotter.plot(ax, cbar_ax, kwargs)
    460 return ax

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/seaborn/matrix.py:340, in _HeatMapper.plot(self, ax, cax, kws)
    337 plt.setp(ytl, va="center")  # GH2484
    339 # Possibly rotate them if they overlap
--> 340 _draw_figure(ax.figure)
    342 if axis_ticklabels_overlap(xtl):
    343     plt.setp(xtl, rotation="vertical")

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/seaborn/utils.py:84, in _draw_figure(fig)
     82 """Force draw of a matplotlib figure, accounting for back-compat."""
     83 # See https://github.com/matplotlib/matplotlib/issues/19197 for context
---> 84 fig.canvas.draw()
     85 if fig.stale:
     86     try:

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:383, in FigureCanvasAgg.draw(self)
    381 def draw(self):
    382     # docstring inherited
--> 383     self.renderer = self.get_renderer()
    384     self.renderer.clear()
    385     # Acquire a lock on the shared font cache.

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:398, in FigureCanvasAgg.get_renderer(self)
    396 reuse_renderer = (self._lastKey == key)
    397 if not reuse_renderer:
--> 398     self.renderer = RendererAgg(w, h, self.figure.dpi)
    399     self._lastKey = key
    400 return self.renderer

File /scratch/miniconda3/envs/WGCNA/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:70, in RendererAgg.__init__(self, width, height, dpi)
     68 self.width = width
     69 self.height = height
---> 70 self._renderer = _RendererAgg(int(width), int(height), dpi)
     71 self._filter_renderers = []
     73 self._update_methods()

ValueError: Image size of 326600x500 pixels is too large. It must be less than 2^16 in each direction.

The module-trait relationships heatmap is correctly plotted.
Any solutions? I need those plots.
Thanks a lot in advance!

nl

@nargesr
Copy link
Member

nargesr commented Aug 29, 2024

Hi @nliorni

I believe the error is coming from the fact that it's trying to adjust the padding between and around subplots. Since you have a lot of samples, you got this error.

More info here.

Also maybe if you can increase the memory and the RAM that would fix your problem.

Not sure if the solution they provide here will work in your case but if you are willing to share your pyWGCNA object with me I'm happy to test it out in my end.

@nargesr nargesr changed the title Plot issue Plot issue (Image size is too large) Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants