Spatial Segment TypeError

Hi all!

Currently running:
scanpy==1.9.3 anndata==0.9.1 umap==0.5.3 numpy==1.22.4 scipy==1.10.1 pandas==2.0.0 scikit-learn==1.2.2

I am attempting to visualise NanoString spatial transcriptomics using sq.pl.spatial_segment() and am passing the usual arguments; adata, color, library_key, and seg_cell_id. However, it is failing to overlay cell images onto the graphs and returning a type-error:

TypeError: ‘collection’ must be an instance of matplotlib.collections.Collection, not a matplotlib.image.AxesImage

My guess is that it seems SquidPy is not passing the images onto the collection object when plotting multiple FOV’s and retaining it in an image container.

Has anyone encountered this error, and is there a fix?

Any help would much be appreciated. Thanks

1 Like

I had this issue as well. Downgrading back down to matplotlib 3.5 solves the issue.

sq.pl in general is pretty broken. I believe the plan is to move all plotting functionality to the authors’ new package SpatialData. Until we get a robustly documented SD package it’s all going to be pretty touch and go.