squidpy icon indicating copy to clipboard operation
squidpy copied to clipboard

`sc.pl.spatial` alpha values for continuos/discrete annotations

Open giovp opened this issue 5 years ago • 6 comments

  • [ ] Additional function parameters / changed functionality / changed defaults?
  • [ ] New analysis tool: A simple analysis tool you have been using and are missing in sc.tools?
  • [x] New plotting function: A kind of plot you would like to seein sc.pl?
  • [ ] External tools: Do you know an existing package that should go into sc.external.*?
  • [ ] Other? image

as done in cell2location @vitkl

...

giovp avatar Apr 07 '21 21:04 giovp

This is the function (it is a bit hidden in code): https://github.com/BayraktarLab/cell2location/blob/a35d0ade4ad921b1952635c318c3553149009cad/cell2location/plt/mapping_video.py#L109

vitkl avatar Apr 07 '21 21:04 vitkl

What API are you thinking here?

cmap should already support alpha levels. I'm not sure how the data is encoded in this example (e.g. how is the alpha channel coded for each category). There could just be an alpha argument for embedding, which could specify the transparency for each point.

Thinking a bit more on this, what are you trying to show here? Is it a problem that some of the points are pretty hard to see?

ivirshup avatar Apr 08 '21 05:04 ivirshup

The simplest extension would be to use continuous variables to define alpha without providing support for multiple colours.

Multiple colours need to be selected manually and interpolated in a way that makes sense. You can copy our code for the backend. @yozhikoff and I are happy to explain how it works.

On Thu, 8 Apr 2021, 06:30 Isaac Virshup, @.***> wrote:

What API are you thinking here?

cmap should already support alpha levels. I'm not sure how the data is encoded in this example (e.g. how is the alpha channel coded for each category). There could just be an alpha argument for embedding, which could specify the transparency for each point.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/theislab/scanpy/issues/1792#issuecomment-815458846, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMFTV5LGTZ5WP4HCSQIJ6LTHU5P3ANCNFSM42RRESJA .

vitkl avatar Apr 08 '21 08:04 vitkl

unfortunately #437 does not address this but gets very close. Will keep this open for next release.

giovp avatar Apr 19 '22 11:04 giovp

this is gonna be worked sometime else in the future, closing due to inactivity

giovp avatar Oct 18 '22 12:10 giovp

I am still interested in the solution.

The value of using alpha is that spots become transparent when the value is 0 rather than becoming black and obscuring the underlying view of the tissue.

In principle, we can already just use this function from cell2location package. Maybe you can just put this function into external or as a separate plotting function? You/I can just copy this code and make the interface consistent with sc.pl.spatial.

One limitation is that it doesn't allow printing multiple panels, one panel per variable/column like sc.pl.spatial - only up to 6 variables in one panel. It is often useful to plot variables one by one.

vitkl avatar Oct 26 '22 21:10 vitkl