broadinstitute / CellBender

CellBender is a software package for eliminating technical artifacts from high-throughput single-cell RNA sequencing (scRNA-seq) data.
https://cellbender.rtfd.io
BSD 3-Clause "New" or "Revised" License
285 stars 52 forks source link

error running scanpy highly_variable_genes #227

Open kunalkathuria opened 1 year ago

kunalkathuria commented 1 year ago

Hello,

I was able to run Cellbender but could not read the filtered h5 using the latest version of scanpy. So, I used your workaround in #128 to read it properly. However, I ran into the following error when it got to running one of scanpy's preprocessing functions:

Traceback (most recent call last): File "/users/kkathuri/nscripts/python/createUMAP_collation.v4.parse.py", line 102, in sc.pl.highly_variable_genes(adata_allp, save='1')
File "/users/kkathuri/.local/lib/python3.7/site-packages/scanpy/plotting/_preprocessing.py", line 93, in highly_variable_genes _utils.savefig_or_show('filter_genes_dispersion', show=show, save=save) File "/users/kkathuri/.local/lib/python3.7/site-packages/scanpy/plotting/_utils.py", line 312, in savefig_or_show savefig(writekey, dpi=dpi, ext=ext) File "/users/kkathuri/.local/lib/python3.7/site-packages/scanpy/plotting/_utils.py", line 288, in savefig pl.savefig(filename, dpi=dpi, bbox_inches='tight') File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 979, in savefig res = fig.savefig(args, kwargs) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/figure.py", line 3046, in savefig self.canvas.print_figure(fname, kwargs) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 2292, in print_figure print_method, orientation=orientation) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1544, in _get_renderer print_method(io.BytesIO()) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1648, in wrapper return func(args, *kwargs) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/_api/deprecation.py", line 389, in wrapper return func(inner_args, inner_kwargs) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py", line 2785, in print_pdf file.newPage(width, height) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py", line 754, in newPage self.reserveObject('length of content stream')) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py", line 845, in beginStream self.currentstream = Stream(id, len, self, extra, png) File "/users/kkathuri/.local/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py", line 529, in init mpl.rcParams['pdf.compression']) ValueError: Invalid initialization option**

Thanks in advance for your help!

Best,

Kunal

sjfleming commented 1 year ago

Hi Kunal, I'm glad you were able to find the workaround to open the output in scanpy.

It looks to me like this error is coming from scanpy itself because of something wrong with the installation of Matplotlib. I'm guessing you might be running scanpy.pl.highly_variable_genes() with save=True? It seems like something with Matplotlib's PDF writer is complaining at you. Maybe try this

import matplotlib
matplotlib.use('pdf')

or try updating your matplotlib version.

sjfleming commented 1 year ago

In the newest v0.3.0, this issue with loading in scanpy is hopefully fixed.

Potentially closed by #238