scanpy icon indicating copy to clipboard operation
scanpy copied to clipboard

[Proposal] Integrate Marsilea to visualize AnnData

Open Mr-Milk opened this issue 2 years ago • 9 comments

  • [x] New plotting function: A kind of plot you would like to seein sc.pl?
  • [x] External tools: Do you know an existing package that should go into sc.external.*?

Hi, thanks for developing such a fantastic framework for analyzing single-cell data, it really helps a lot in my research. I'm the developer of Heatgraphy, which is a python package to visualize multi-dimensional data using the x-layout system. You may think of it as python's version of complexHeatmap, but Heatgraphy can do much more.

Personally, I think Heatgraphy can help visualize the AnnData intuitively. Here is an example of visualization of the PBMC3K dataset using Heatgraphy. The structure of AnnData fits the structure of this visualization quite well. We can plot the .X as the heatmap, and other attributes in .obs/.var or .obsm/.varm as side plots.

Therefore, I propose adding a new API using Heatgraphy to help visualize AnnData.

If adding to sc.pl, the API may look like this:

sc.pl.heatgraphy(adata, left=[("cell_type", "color"), ("cell_type", "label")], right=[("gene_name", "label")])

If added as an extra class, the API can be more flexible and offer much more customization. It may look like this:

viz = AnnDataViz(adata)
viz.add_left(key="cell_type", plot="color", cmap="Set2")  # use a key from .obs and plot as color strip
viz.add_left(key="cell_type", plot="label")
viz.render()

It can also be applied to specific visualization for analysis.

Mr-Milk avatar Mar 09 '23 12:03 Mr-Milk

This sounds great! Please go for it and submit a minimal draft PR. Then we can iterate over it

Zethson avatar Mar 14 '23 22:03 Zethson

Example of creating dot plot, which to my mind was a main missing feature. This should go great with sc.get.aggregate: https://github.com/Marsilea-viz/marsilea/issues/27#issuecomment-2022353426

Ideally, I think we could switch to marsilea for many plots for scanpy 2.0, replacing our existing BasePlot subclasses. This definitely requires more exploration first though.

@Mr-Milk, wdyt about including a how-to example in scanpy for Marsilea?

cc: @grst

ivirshup avatar Mar 27 '24 12:03 ivirshup

It's great! Please let me know what to do from my side.

Mr-Milk avatar Mar 27 '24 14:03 Mr-Milk

If you open a PR with a short notebook in https://github.com/scverse/scanpy-tutorials that would be a great place to start.

ivirshup avatar Mar 27 '24 14:03 ivirshup

Hi, I've now implemented many scanpy plots using Marsilea in the notebook. Please let me know what you think of it and if you have any further questions or requests that could be useful for the community. Looking forward to integrating this!

Mr-Milk avatar Apr 30 '24 10:04 Mr-Milk