[Proposal] Integrate Marsilea to visualize AnnData
- [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.
This sounds great! Please go for it and submit a minimal draft PR. Then we can iterate over it
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
It's great! Please let me know what to do from my side.
If you open a PR with a short notebook in https://github.com/scverse/scanpy-tutorials that would be a great place to start.
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!