Skip to content

Binding colour values across columns #426

Open

Description

@Hrovatin

Sometimes one has multiple columns that contain similar categorical values (e.g. different cell type annotations). Each of these columns gets its own colour mapping which can also change when the column is changed. It would be nice if there was a function to bind multiple columns to a single colour mapping (e.g. dict) that would contain the union of all values in these columns. Thus the same values in different columns would get the same colour.
Example:
slika
Above a few cell types (left) have been merged into one cell type (right, saphire blue), but all the colours are now different.

Activity

  1. ivirshup commented on Aug 26, 2020

    @ivirshup
    Member

    How about passing a dict mapping the category names to colors which you can pass for palette? Then you could do:

    sc.pl.umap(
        pbmc,
        color="highlevel",
        palette={
            "B cells": "#01FFD0",
            "T cells": "#509CFF",
            "Monocytes": "#FF7161",
            "NK cells": "#FF476E"
        },
    )

    ugly_colors

  2. Hrovatin commented on Aug 26, 2020

    @Hrovatin
    Author

    Having a dict as input to umap would be very nice (based on the documentation I thought it was not possible). However, with the dict, one needs to create and update the dict whenever changing the columns, which is a bit of an inconvenience.

  3. ivirshup commented on Aug 31, 2020

    @ivirshup
    Member

    Its not (though I thought it was originally), so I've opened a PR to support it.

    What sort of column changing are you thinking? What I'm imagining right now seems a bit more complicated to implement, but I'm not sure if it's the same idea. Could you write out some examples of the API you're proposing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions