Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom color schemes #147

Open
JobLeonard opened this issue Feb 6, 2018 · 3 comments
Open

Custom color schemes #147

JobLeonard opened this issue Feb 6, 2018 · 3 comments

Comments

@JobLeonard
Copy link
Contributor

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
Copy link
Contributor

Client-side or server-side?

@JobLeonard
Copy link
Contributor Author

JobLeonard commented Feb 6, 2018

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:

  • detect presence of this attribute, extract the color maps if present, and add it to the JSON (as trivial as adding an extra key to a dictionary lookup)

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

  • add the logic to extract the color maps when parsing the attribute JSON
  • a way to select the palette in the interface. Perhaps replacing the categorical button in the current two-button scheme with a drop-down when extra color maps are detected.
  • a bit of logic to select the palette for the plotters

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants