squidpy icon indicating copy to clipboard operation
squidpy copied to clipboard

Delegate plots to spatialdata-plot

Open LucaMarconato opened this issue 1 year ago • 4 comments

Cowritten with @timtreis.

Many functions in squidpy essentially generate similar plots like we do in spatialdata-plot (it precedes spatialdata-plot) and was the basis of it. It’d reduce maintenance effort if we pivot those functions to delegate to spatialdata-plot. We could establish convenience wrappers for “plot the same plot with 3 genes”: example notebook here. See further discussion here.

LucaMarconato avatar Nov 08 '24 12:11 LucaMarconato

I guess the main plots where it's useful to wrap spatialdata-plot would be spatial_scatter and spatial_segment since the others are about visualizing statistics.

LLehner avatar Nov 13 '24 10:11 LLehner

Is the idea to replace the current spatial_scatter and spatial_segment with spatialdata-plot or also add different plotting capabilities? If one wants the "classic" 4 plots in a row graphic, should it just be a wrapper in the sense that the plots from spatialdata-plot are captured in memory and then put on a new grid to visualize? @LucaMarconato @timtreis

A current draft implementation of mine would yield something like this for labels (using MIBI-TOF example data set): Image

LLehner avatar Nov 13 '24 14:11 LLehner

Basically yeah, the core idea is that spatialdata-plot is akin to matplotlib, basically just delivering the base plotting capability. And anything fancy is then a wrapper around that. So, as you said, in that case a squidpy function would keep it's old interface but then just call spatialdata-plot once per gene and put that on the respective ax object 👍

timtreis avatar Nov 13 '24 15:11 timtreis

The codebase of spatialdata-plot started out as some chimera between Squidpy's plotting and a prototype from Harald, but has matured a lot since. So we're essentially maintaining duplicate code. Ideally, we can remove a lot of the spatial plotting code from Squidpy and fully delegate to spatialdata-plot so we only fix/advance that in one place.

timtreis avatar Nov 13 '24 15:11 timtreis