scanpy icon indicating copy to clipboard operation
scanpy copied to clipboard

[Proposal] Integrate Marsilea to visualize AnnData

Open Mr-Milk opened this issue 1 year ago • 5 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