BiomedicalMachineLearning / stLearn

A novel machine learning pipeline to analyse spatial transcriptomics data
Other
190 stars 25 forks source link

AttributeError: 'NoneType' object has no attribute **'_get_renderer' #241

Closed Ding7928 closed 9 months ago

Ding7928 commented 1 year ago

when i tried to built up a new adata project,i came across AttributeError, could you please help?

across AttributeError: 'NoneType' object has no attribute '_get_renderer'

count_matrix = pd.read_csv("./spatial_protein.csv", index_col='label') spatial= pd.read_csv('./spatial.csv') adata = st.create_stlearn(count=count_matrix,spatial=spatial,library_id="Sample_test", scale=1,background_color="white") adata AnnData object with n_obs × n_vars = 240 × 1353 obs: 'imagecol', 'imagerow' uns: 'spatial' obsm: 'spatial' st.pl.QC_plot(adata)

AttributeError Traceback (most recent call last) File /opt/anaconda3/envs/stlearn/lib/python3.8/site-packages/IPython/core/formatters.py:340, in BaseFormatter.call(self, obj) 338 pass 339 else: --> 340 return printer(obj) 341 # Finally look for special method names 342 method = get_real_method(obj, self.print_method)

File /opt/anaconda3/envs/stlearn/lib/python3.8/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, kwargs) 149 from matplotlib.backend_bases import FigureCanvasBase 150 FigureCanvasBase(fig) --> 152 fig.canvas.print_figure(bytes_io, kw) 153 data = bytes_io.getvalue() 154 if fmt == 'svg':

File /opt/anaconda3/envs/stlearn/lib/python3.8/site-packages/matplotlib/backend_bases.py:2353, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs) 2350 bbox_inches = bbox_inches.padded(pad_inches) 2352 # call adjust_bbox to save only the given area -> 2353 restore_bbox = _tight_bbox.adjust_bbox( 2354 self.figure, bbox_inches, self.figure.canvas.fixed_dpi) 2356 _bbox_inches_restore = (bbox_inches, restore_bbox) 2357 else:

File /opt/anaconda3/envs/stlearn/lib/python3.8/site-packages/matplotlib/_tight_bbox.py:28, in adjust_bbox(fig, bbox_inches, fixed_dpi) ... --> 399 renderer = self.figure._get_renderer() 400 bbox = self.get_bbox(renderer) 401 try: # Some subclasses redefine get_offset to take no args.

AttributeError: 'NoneType' object has no attribute **'_get_renderer'

duypham2108 commented 1 year ago

I think your code is fine when you create the adata object. The issue is the st.pl.QC_plot. I am using matplotlib==3.7.1 and it still works well. Can you check it again?

Ding7928 commented 1 year ago

Thanks for your reply. I chekced the version is matplotlib: 3.7.2