empress icon indicating copy to clipboard operation
empress copied to clipboard

Support specifying a midpoint / etc. in quantitative color scaling

Open fedarko opened this issue 3 years ago • 3 comments

When drawing barplots of things like differentials using a diverging color map, it would be nice to be able to say "ok, the midpoint of this color map should coincide with a value = 0", to ensure that things are colored consistently even if there are outliers. I think iTOL supports something like this?

fedarko avatar Sep 01 '20 22:09 fedarko

In addition it would also be nice to set the high and low values so that anything above/below is capped. This should help with outliers.

ElDeveloper avatar Sep 02 '20 00:09 ElDeveloper

Bumping this is as it came up while making the slide for lab meeting presentation. iTOL allows something similar to what @fedarko & @ElDeveloper mentioned. Basically, you can specify the midpoint and endpoint colors but not where the midpoint and endpoints actually occur. I think it makes more sense to allow the user to set the values themselves.

image

For the below tree (differentials), the midpoint being -1.14 pretty substantially hampers interpretation when 0 is the "average" log-fold change.

image

gibsramen avatar Nov 18 '20 17:11 gibsramen

Thanks @gibsramen. Agreed that this would be a really useful feature to have.

Adding UI controls to the continuous coloring sections that let the user define the exact "domain" of the color map based on at least two (but ideally arbitrarily many) numerical values should be enough for most use cases, I think. chroma.js' chroma.scale.domain() function supports this really nicely (and the "capping" happens by default, so e.g. if you pass in [-2, 2] as the domain for a scale, -5 just maps to whatever -2's color is).

image

There would be lots of fancier things possible here (e.g. letting the user specify arbitrary colors alongside the numbers in order to create a scale without using any of the preset color maps in Empress, similarly to how iTOL works), but I think for a first pass just the customization described above would be useful.

fedarko avatar Nov 18 '20 19:11 fedarko