emdann / milopy

Python implementation of Milo for differential abundance testing on KNN graph
MIT License
60 stars 7 forks source link

plotNhoodGraphDA in python version #7

Closed alitinet closed 2 years ago

alitinet commented 2 years ago

Hi all,

is it possible to get the same plot as with plotNhoodGraphDA() in R in the python version too? I'm aware of milopy.plot.plot_nhood_graph() but it's not as pretty :) Thanks!

emdann commented 2 years ago

Hi @alitinet Unfortunately I am yet to crack the code on how to make python plots as pretty as R plots :) What feature of the R version plots would you like to see implemented in particular? Is it the edges between points?

alitinet commented 2 years ago

Hi @emdann, exactly :)

emdann commented 2 years ago

If it's just that then you can simply put plot_edges=True in plot_nhood_graph. Apparently I had put in this option and I didn't even remember it 😅 From the vignette:

milopl.plot_nhood_graph(adata, 
                        alpha=0.01, ## SpatialFDR level (1%) 
                        min_size=2, ## Size of smallest dot
                        plot_edges=True
                       )

Screenshot 2022-05-23 at 16 06 02

What's missing compared to the R version would be edge thickness proportional to the overlap, although I have rarely found that to be particularly insightful, as it is often obscured by overplotting. Then adding legends for points size (i.e. no of cells in nhoods) would be desirable, I can look into this, any suggestion is welcome.

alitinet commented 2 years ago

Oh this is great already, I also didn't notice there was an option to add edges! Thanks for pointing this out!