ShobiStassen / VIA

trajectory inference
https://pyvia.readthedocs.io/en/latest/
MIT License
76 stars 20 forks source link

Color scheme in via_streamplot #41

Closed barbareyex closed 11 months ago

barbareyex commented 1 year ago

Hi,

I am trying to set a specific color palette for the via_streamplot(), but I haven't found out how to do it. The thing is in the via.plot_scatter() there is an argument named color_dict where you can input a dict with the existing labels and a color code for that label, but there's not the same option in via_streamplot().

Any idea?

MinatoKobashi commented 1 year ago

Currently, the only way to specify a color palette for via_streamplot() is to use the cmap_str which will call the matplotlib.pyplot.get_cmap() to retrieve the color palette. Check out this link for the list of cmap you can choose from: https://matplotlib.org/stable/tutorials/colors/colormaps.html

ShobiStassen commented 1 year ago

@RRRReyes Thanks for bringing this up. minato is right the via_streamplot() function doesn't support th dictionary pallette yet. But i can work that in for you by mid next week

barbareyex commented 1 year ago

Thanks, @MinatoKobashi. Changing the colormap is useful as well, but my desire would be to apply the same colors from UMAP clusters to the streamplot.

If you solve this, I would be very grateful! Just tell me in case you manage to do it @ShobiStassen.

Thanks!

ShobiStassen commented 11 months ago

hi @RRRReyes

In case this is still relevant for you, i finally added in the color dictionary parameter for streamplots in via. Here are a few examples of the coloring options in the streamplot, the last example uses color_dict

via_streamplot(via_object=v0, scatter_size=20) 
via_streamplot(via_object=v0, scatter_size=20, labels=v0.single_cell_pt_markov,title='labels of pt')  
via_streamplot(via_object=v0, scatter_size=20,  color_scheme='cluster',title='cluster')
via_streamplot(via_object=v0, scatter_size=20,  color_scheme='annotation',title='annotation')
via_streamplot(via_object=v0, scatter_size=20, color_scheme='time', title='auto pt', cmap_str='viridis')
color_dict = {'M1':'blue','M2':'red','M3':'purple','M4':'orange','M5':'yellow','M6':'green','M7':'pink','M8':'gray'}
via_streamplot(via_object=v0, scatter_size=20, color_dict=color_dict, labels = v0.true_label)  
plt.show()

color_dict_example

realzehuali commented 10 months ago

When I used color_dict parameter in VIA, it did not change the default color. Thank you for any help!

realzehuali commented 10 months ago

Sorry to disturb you, when I tried to set labels = v0.true_label, it worked! Thank you for your code!