moshi4 / pyMSAviz

MSA(Multiple Sequence Alignment) visualization python package for sequence analysis
https://moshi4.github.io/pyMSAviz
MIT License
80 stars 14 forks source link

Too large pixels for large protein alignment #16

Closed baozg closed 1 week ago

baozg commented 2 weeks ago

Hi, @moshi4

Thank you for bring this awseome tool. I am trying to visualize single gene protein alignments with 282 samples. But pyMSAviz failed with this error. The command line was stucked long time pymsaviz -i AT5G61270_1.aln.fa -o AT5G61270_1.aln.png --color_scheme Identity.

However, it could easily showd by alv (https://github.com/arvestad/alv)

image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/ebio/abt6_projects/AtGraph/conda/env/lib/python3.10/site-packages/pymsaviz/msaviz.py", line 465, in savefig
    fig = self.plotfig(dpi=dpi)
  File "/ebio/abt6_projects/AtGraph/conda/env/lib/python3.10/site-packages/pymsaviz/msaviz.py", line 419, in plotfig
    fig.tight_layout()
  File "/ebio/abt6/zbao/.local/lib/python3.10/site-packages/matplotlib/figure.py", line 3540, in tight_layout
    engine.execute(self)
  File "/ebio/abt6/zbao/.local/lib/python3.10/site-packages/matplotlib/layout_engine.py", line 181, in execute
    renderer = fig._get_renderer()
  File "/ebio/abt6/zbao/.local/lib/python3.10/site-packages/matplotlib/figure.py", line 2754, in _get_renderer
    return self.canvas.get_renderer()
  File "/ebio/abt6/zbao/.local/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 398, in get_renderer
    self.renderer = RendererAgg(w, h, self.figure.dpi)
  File "/ebio/abt6/zbao/.local/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 70, in __init__
    self._renderer = _RendererAgg(int(width), int(height), dpi)
ValueError: Image size of 1120x131040 pixels is too large. It must be less than 2^16 in each direction.

If you want to test, I could send you this alignment by email.

moshi4 commented 1 week ago

The error occurs because matplotlib has a limit on the number of pixels that can be plotted. I think the visibility of a large MSA figure by pyMSAviz is poor, so I would suggest that you avoid plotting with pyMSAviz.

It may be possible to plot your example if you lower the DPI below 100.