scverse / spatialdata-plot

Static plotting for spatialdata
BSD 3-Clause "New" or "Revised" License
35 stars 14 forks source link

Plotting multiple genes #321

Open wangjiawen2013 opened 3 months ago

wangjiawen2013 commented 3 months ago

Hi, Scanpy/squidpy can plot mutliple genes at once and save as a image file. such as sc.pl.umap(adata, color=["genes1", "genes2", "genes3"], save="a.pdf") This is very convinient. while spatialdata_plot can plot only one genes now and cannot be saved: sdata.pl.render_shapes("cell_circles", color='genes').pl.show() It would be nice for the parameter color to support gene list.

This features is not indispensable, becuase we can use plt.subplots to achieve this. But they will bring more convinience and ergonomics, just like scanpy and squidpy.

Besides, there is a parameter ncols in pl.show(), as you can see with help(sdata.pl.render_shapes("cell_circles", color="n_counts").pl.show), but where to use it ? what's the function of it ? It seems that it's useless because we can only plot one gene a time. image

LucaMarconato commented 3 months ago

Hi, I see that save is not documented but it's there https://github.com/scverse/spatialdata-plot/blob/a5e12d5febf27a478076113b8b96c1afe8e43242/src/spatialdata_plot/pl/basic.py#L981; so you should be able to use it.

This features is not indispensable, becuase we can use plt.subplots to achieve this. But they will bring more convinience and ergonomics, just like scanpy and squidpy.

I usually take this approach; I'll tag someone to the conversation for extra details.

It would be nice for the parameter color to support gene list. @melonora, after the view configuration refactoring is this supported/planned or not in scope? Thanks for the info.

timtreis commented 3 months ago

I'd tentatively say that we won't support the use case of passing a list of genes. Not too long ago we flattened the entire plotting logic to only generate one axis because the hierarchical type checking was just getting out of control. Accepting a list of genes to color by would open the door for requests for this hierarchy again.

We might consider a usecase where for >>very few selected parameters<<< we soften this stance but then don't accept any further modifications between the plots. Wdyt @melonora ?

I think one long-term goal of Squidpy 2.0 could also be to transition, where possible, the plots to spatialdata_plot. Then we could add such simple convenience functions there, essentially just calling ax.subplots for the user