IGS / gEAR

The gEAR Portal was created as a data archive and viewer for gene expression data including microarrays, bulk RNA-Seq, single-cell RNA-Seq and more.
https://umgear.org
GNU Affero General Public License v3.0
10 stars 5 forks source link

add colorblind color option for UMAP/TSNE #324

Open songeric1107 opened 2 years ago

songeric1107 commented 2 years ago

Just had a user request for adding a color-blind color pattern for the UMAP display.

We could follow the suggestion based on Wong B's manuscript, "Points of view: Color blindness." Nature Methods, 2011 .

we can use a similar color-bind color pattern from dittoseq package.

https://bioconductor.org/packages/devel/bioc/vignettes/dittoSeq/inst/doc/dittoSeq.html

Screen Shot 2022-05-23 at 8 33 43 AM

color_bind_pattern.txt

adkinsrs commented 2 years ago

Odd... I thought I had made a ticket for a color-blind accessibility option.

I think there are accessibility toolkits/packages that will adjust the entire site, plot and all when the various colorblindness options are set.

songeric1107 commented 2 years ago

@adkinsrs , if you had a ticket already, I could close this. I could not find a ticket with keywords such as "color blind". should I close this?

adkinsrs commented 2 years ago

No don't close it. I thought I had made one with the intention of adding these features in the future but I did not make one it seems.

adkinsrs commented 1 year ago

I'm noting that #91 indirectly addresses this. In that ticket, the user can create heatmap or dotplots from color-accessible palettes but that ticket does not address the issue from the perspective of someone who wants to view plots.

adkinsrs commented 1 year ago

I'm going to start with the main page first, since this will be the most likely place a user will view displays. My plan is to add a checkbox on the dataset display page (post-search, not on the pre-search page though). When checked, this will set a flag that will eventually make its way to the various plot API calls.

Inside each API plotting script, if this flag is true, they will use the "Cividis" color palette, which addresses some shortcomings with "Viridis" and other perceptionally uniform scales (see https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0199239). If we are dealing with a colormap, such as that with discrete or quantified plots, I will just break up the "cividis" colorscheme based on equal parts based on the number of things to plot. Plots with continuous data will just use the sequential scale.

Currently, volcano and quadrant plots (multigene curator) do not have any colorization options yet, but I plan on adding something there too.

Worth noting that personally I feel "Viridis" may give better differentiation in categorical plots than "Cividis" but this is based on my personal, hypothetical opinion. If I find that "Cividis" colors do not seem to differentiate enough on plots like tSNE/UMAP, then it's a trivial change to use "Viridis" instead

adkinsrs commented 1 year ago

Change of plans... moving the "colorblind button" into the user profile, as a user-by-user basis. @jorvis will send out an email to users notifying them of this feature when it is available in the production server.

adkinsrs commented 1 year ago

For tSNE plots,

Using a reversed "Cividis" scale for expression levels, and will use "Viridis" if we colorize by a cell type. I may be coming from the perspective of a person who does not have color vision deficiencies, but I felt that if a lot of cell types are presented, it can be difficult to distinguish between some groups with Cividis. Viridis seems to have that extra shade of "green" that Cividis lacks. If other people feel Viridis has a similar issue, I can switch to Turbo, which has a larger variety of colors at the cost of some grayscale redundancies.

Screen Shot 2022-07-08 at 10 59 28 AM
adkinsrs commented 1 year ago
Screen Shot 2022-07-08 at 3 08 04 PM

Plotly plots should now show colorblind plots (Cividis for continuous scales, and Viridis for qualitiative).

As an aside, I also ran into an issue within the scRNA-seq - P2 cochlea (Heller 2021) profile, where a dataset "scRNA-Seq of all principal neonatal cochlear cell groups,gate (Heller)" had a color mapping whose keys did not match any of the values from that particular adata.obs column. I realized that these values seemed to be truncated after the space in the dataframe series value names, so I added some code to a) validate the colormap keys match the column values, and b) if not, apply the colors to a sorted list of the dataframe series values. I believe that truncation probably happens in the dataset curator, so I will need to look into that.

adkinsrs commented 1 year ago
Screen Shot 2022-07-08 at 3 51 22 PM

SVG colors.

I may just end up changing this to a single shade like the "purples" that were originally used. This is a bit more applicable when the user selected custom colors for the low and high settings.

Also the SVG plot on the right has some "cell" colors that would have to be edited in the SVG, which may be too difficult at this point.

adkinsrs commented 1 year ago

I've done the following:

Currently, I have yet to modify the other scanpy plotting steps, and this is largely because most, if not all, of these scanpy steps save the plot image to disk. My philosophy is that colorblind mode should be for the current user to view and not propagate to other users (i.e. saving colorblind displays). It's probably not a big deal provided the current analysis is a private "per user" session, but I want to assess first.