pinellolab / STREAM

STREAM: Single-cell Trajectories Reconstruction, Exploration And Mapping of single-cell data
http://stream.pinellolab.org
GNU Affero General Public License v3.0
173 stars 48 forks source link

transpant hex color not used by streamplot #68

Closed ccshao closed 4 years ago

ccshao commented 4 years ago

We would like to plot the control and treatment groups together in the stream plot after mapping the treatment to control. For better presentation, we try to a set of paletter of RColorBrewer and an associated transparent palette. Eight subgroups in each condtion.

First get the color codes in R.

col1 <- RColorBrewer::brewer.pal(11,'BrBG')[c(1:4, 8:11)]
[1] "#543005" "#8C510A" "#BF812D" "#DFC27D" "#80CDC1" "#35978F" "#01665E"
[8] "#003C30"

#- transparent palette
col2 <- scales::alpha(RColorBrewer::brewer.pal(11,'BrBG')[c(1:4, 8:11)], 0.4)
[1] "#54300566" "#8C510A66" "#BF812D66" "#DFC27D66" "#80CDC166" "#35978F66"
[7] "#01665E66" "#003C3066"

Then save the col2 together with treatment labels . However, in the stream plot with treatment, only the first 6 hex codes are used, while the last two are ignored, resulting the same color as control. Is this a bug or simply python could not recognize the transpant hex codes? And how to do it correctly? Thanks very much.

huidongchen commented 4 years ago

Hey,

Sorry about the delay. It has been quite hectic lately. In STREAM plot, unfortunately we don't support the adjustment of transparency. The alpha is hard-coded as '0.8' (it will overwrite your hex code). This is mostly due to the aesthetics controlling.

As you noticed, in STREAM plot, different cell types may cross each other around branching points. Making STREAM plot less opaque will help keep track of them even around the overlapping area. To make STREAM plot look consistent across different datasets, we are using a constant transparency degree. And I would not suggest tuning the transparency to distinguish different groups.

A potential solution to your case would be using the palette 'paired' sns.palplot(sns.color_palette("Paired")). https://seaborn.pydata.org/tutorial/color_palettes.html. By doing so, you should be able to separate two groups by hex codes instead of transparency.

ccshao commented 4 years ago

Thanks for the solutions! "e tried the "Paired" and D3 category 20 palettes, both works well in stream.