Custom color mapping circos nodes and edges #689
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves issue #682 and #572.
PR Checklist
Please ensure that you have done the following:
AUTHORS.rst
.Code Changes
If you are adding code changes, please ensure the following:
$ pytest .
) locally on your machine.Documentation Changes
If you are adding documentation changes, please ensure the following:
PR Description
Please describe the changes proposed in the pull request:
Hi, first just want to express my gratitude for making this fantastic package!
In this PR, I've just simply added
node_palette
andedge_palette
kwargs with the main idea to allowcircos
to accept either a list or dictionary of custom color palettes for colouring categories.annotate.node_colormapping
andannotate.edge_colormapping
also received a similar treatment but acceptspalette
as the kwarg.This gets around the issue of only limited to 12 colours and allow for custom color selection. I've inserted the kwargs into the functions in
.api
but I've only tried this oncircos
so i'm not sure if it impacts on the rest of the package.Minimal example to illustrate the outcome:
Current default behavior as it is right now (before/after this PR) i.e. don't specify the palette options:
when there's >12 categories, just modified the error message to ask for people to provide their own palette.
this PR's proposed changes:
now with more than 12 categories (14), and a long color palette (20 colors)
same as above but limit to 7 colors - colors start to cycle if palette is provided as a list.
if provided as a dictionary:
order of keys don't matter
can mix colors/hex codes
swapping of order of colors in a list matters. But the plot should reflect this correctly - if you look up at the dictionary examples, the same order is preserved.
Can be used on edges as well:
As a sanity check, just to ensure that the color/order is respected you can see in this small graph where only 2 categories will be repeated twice (sun and moon), the color mapping remains consistent:
default i.e. palette not provided
palette provided as a list. Because sun was added first (it was added sequentially as 'sun', 'moon', 'stars', 'cloud', 'sun', 'moon'), it should be pink. cloud is the last unique entry, so should be green.
palette is provided as a dictionary.
let me know what you think!
Cheers,
Kelvin
Relevant Reviewers
Please tag maintainers to review.