linnarsson-lab / loom-viewer

Tool for sharing, browsing and visualizing single-cell data stored in the Loom file format
BSD 2-Clause "Simplified" License
35 stars 6 forks source link

Custom color schemes #147

Open JobLeonard opened 6 years ago

JobLeonard commented 6 years ago

Request by lars :)

Probably a global attribute would be enough. Some convention for a name and then just a list of hex strings would be enough. Multiple color maps should be supported.

slinnarsson commented 6 years ago

Client-side or server-side?

JobLeonard commented 6 years ago

Well, it requires a bit of work on both ends, but only in the loom-viewer. It shouldn't be too complicated (see below). The main decision revolves around the best naming and schema convention in the loom file.

Actually, the most logical schema also seems self-evident (see below as well), it really boils down to choosing a good name for the convention. We may also want to distinguish categorical maps and scales.

Would Categorical color maps and Sequential color maps be fine as attribute names? Or are you worried we might clash with other groups? Do we need something to distinguish it, like a leading underscore?

Color map convention

Per the loompy docs:

Global attributes can be scalars, or multidimensional arrays of any shape, and the elements can be integers, floats or strings. See below for the exact types allowed.

I think the easiest way (for the user) then is to store an array of strings (when adding one color map), or an array of arrays of strings when using multiple. The number of colors per map may be anything, but users should realise that categorical colors cycle around when exhausted (awaiting future support of multiple shapes in the scatter-plot to complement this)

Valid color strings follow the pattern "#RRGGBB", where RRGGBB can be any hexadecimal value, "#000000 for black, "#FFFFFF" for white, etc. The strings are case-insensitive. Any invalid string should default to black in the viewer (to make it obvious something is off).

If we want to support named color maps, things would get a bit more difficult.

Code-changes in loom-viewer

Server-side needs to:

Client side code is set up to make color palettes easy to swap already, so all I need to add is

Aside: we currently don't list any conventions for Global Attributes, I was under the impression that we do have a few. For that matter, should the new time stamp support be added, given that it is specific to the loompy implementation?

JobLeonard commented 6 years ago

By the way, couldn't we adopt a similar convention for custom gene selection lists? Although I suppose we would like to name those.