scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.82k stars 586 forks source link

densmap #1619

Open ivirshup opened 3 years ago

ivirshup commented 3 years ago

This seems related to the new Densmap feature https://umap-learn.readthedocs.io/en/latest/densmap_demo.html (see https://www.biorxiv.org/content/10.1101/2020.05.12.077776v1)

Would be cool to support it in scanpy.

Originally posted by @gokceneraslan in https://github.com/theislab/scanpy/issues/1509#issuecomment-748156450

lazappi commented 3 years ago

I would be keen to see densmap added to scanpy. I can maybe help with a PR but not sure whether it's better/prefered to add a new sc.tl.densmap() function or add arguments to the existing sc.tl.umap()?

ivirshup commented 3 years ago

I can maybe help with a PR but not sure whether it's better/prefered to add a new sc.tl.densmap()

Good question. In UMAP, I believe it's just a key word argument.

My instinct would be separate function, since it takes a few new arguments and has a few new values associated. Also, could potentially add a different key in obsm, since I don't think you can transform data into the existing space and this may conflict with ingest (any thoughts @Koncopd?).

I would also be interested in any thoughts you had on the applicability/ usefulness of the method in general. One question that comes up for me, is PCA space a reasonable original space to be using here?

lazappi commented 3 years ago

I think being able to see density could be really useful but I've only tried it a couple of times so not sure how it goes in practice. A lot of the motivation for wanting it in scanpy is to make it easier to try out 😸. The umap developers adding it to the main package seems like a good argument that it's useful though.

I hadn't thought about inputs but first guess is that PCA (or equivalent) should capture density relatively well? The function would let the user choose the input though right (with some sensible default)?

ivirshup commented 3 years ago

A lot of the motivation for wanting it in scanpy is to make it easier to try out 😸.

We've definitely ended up with a number of features this way, but more so when we had fewer users... I think this would be a good candidate for an experimental module.

The umap developers adding it to the main package seems like a good argument that it's useful though.

I should look through the paper on this more carefully, but from my initial skimming I wasn't particularly convinced the relative density was meaningful.

I hadn't thought about inputs but first guess is that PCA (or equivalent) should capture density relatively well?

I'm suspicious it could be dependent on dataset make-up, e.g. what the components represent and whether they are likely to be shared.

lazappi commented 3 years ago

Ok, well I have half a function based on the current UMAP function which seems to work ok if that ends up being helpful for whatever implementation.

ivirshup commented 3 years ago

Great, I think we may go for an experimental module as soon as next release (though, maybe the one after).

If you form any strong opinions or have any cool use cases for the function, I'd definitely be interested in hearing about it.

pakiessling commented 6 months ago

Hi, did any one ever end up testing Densmap for scRNA ?

lazappi commented 6 months ago

I tried it out and I guess I had a function somewhere (not sure if I can find it again) but I don't think anyone looked more into adding it to scanpy.

chansigit commented 1 month ago

how's it going now