Color system

In OmicVerse, we offer a color system based on Eastern aesthetics, featuring 384 representative colors derived from the Forbidden City. We will utilize these colors in combination for future visualizations.

All color come from the book: “中国传统色:故宫里的色彩美学” (ISBN: 9787521716054)

import omicverse as ov
import scanpy as sc
#import scvelo as scv
ov.plot_set()

We utilized single-cell RNA-seq data (GEO accession: GSE95753) obtained from the dentate gyrus of the hippocampus in mouse.

adata = ov.read('data/DentateGyrus/10X43_1.h5ad')
adata
AnnData object with n_obs × n_vars = 2930 × 13913
    obs: 'clusters', 'age(days)', 'clusters_enlarged'
    uns: 'clusters_colors'
    obsm: 'X_umap'
    layers: 'ambiguous', 'spliced', 'unspliced'

Understanding the Color System

In OmicVerse, we offer a color system based on Eastern aesthetics, featuring 384 representative colors derived from the Forbidden City. We will utilize these colors in combination for future visualizations.

fb=ov.pl.ForbiddenCity()
from IPython.display import HTML
HTML(fb.visual_color(loc_range=(0,384),
                    num_per_row=24))
人籁青粲翠缥水龙吟碧山石发菉竹庭芜绿葱倩漆姑翠微芰荷青青翠虬官绿油绿莓莓螺青春辰麴尘欧碧苍葭兰苕青玉案
碧滋瓷秘筠雾竹香子鸣珂琬琰出岫王刍春碧执大象青圭绿沈风入松荩篋绞衣素綦苍筤天缥卵色沧浪葭菼山岚冰台青古
醽醁渌波青楸缥碧翠涛青梅雀梅苔古蕉月干山翠翕赩结绿绿云丹罽黄丹檎丹银朱洛神珠珊瑚赫朱孔阳丹雘水华朱胭脂虫朱樱
大繎顺圣爵头麒麟竭苕荣扶光十样锦海天霞驿刚朱颜酡赦霞赦尾缙云小红琼琚岱赭朱柿艳炽鹤顶红赤缇纁黄棠梨朱殷石榴裙
朱草赤灵佛赤綪茷朱湛丹秫木兰杨妃盈盈银红粉米桃夭水红夕岚彤管咸池莲红雌霓縓缘长春渥赭红䵂紫梅绛纱
茹藘美人祭唇脂牙绯鞓红葡萄褐蚩尤旗紫矿紫诰苏方霁红蜜褐福色黪紫龙膏烛苏梅琅环紫胭脂水紫茎屏风红踯躅胭脂紫魏红紫府魏紫
地血芥拾紫油紫紫薄汗退红昌容樱花丁香木槿茈藐紫蒲紫紶拂紫绵赪紫三公子齐紫凝夜紫石英香炉紫烟苍烟落照甘石紫菂银褐藕丝褐
烟红迷楼灰红藤杖鸦维玄天烟墨紫鼠栀子黄白游松花缃叶黄栗留嫩鹅黄黄河琉璃杏子红友库金鞠衣黄不老郁金裙露褐蛾黄光明砂柘黄
媚蝶黄流韎韐九斤黄弗肯红赤璋如梦令茧色芸黄椒房金埒雌黄密陀僧大块蜜合地籁仙米假山南黄粱石蜜紫花布黄封养生主沙场
黄螺蒸栗巨吕降真香大云吉金远志射干油葫芦龙战緅絺葭灰珠子褐黄埃沉香明茶褐荆褐驼褐缊韨棠梨褐檀褐朱石栗紫瓯栗壳
麝香褐椒褐枣褐目童子青骊丁香褐肉红夏籥檀唇紫磨金檀色鹰背褐赭罗老僧衣姜黄半见断肠葱青女贞黄莺儿桑蕾绢纨少艾绮钱
翠樽田赤禹余粮姚黄太一余粮栾华秋香大赤苍黄老茯神流黄青白玉玉色骨缥黄润缣缃佩玖玄校黄琮石莲褐绿豆褐綟绶茶色濯绛
黑朱冥色伽罗苍艾群青碧落晴山品月窃蓝挼蓝监德苍苍孔雀蓝青冥柔蓝碧城蓝采和细宇帝释青佛头青骐麟花青优昙瑞暮山紫
紫苑延维曾青青黛䒌靘缪琳绀蝶獭见天水碧井天云门西子正青扁青法翠吐绶蓝鱼师青软翠青緺螺子黛二绿繱犗铜青青雘
䌦色石绿竹月月白素采星郎影青逍遥游白青青鸾东方既白秋蓝空青太师青菘蓝育阳染青雀头黛霁蓝瑾瑜缟羽山矾浅云凝脂皦玉
玉頩二目鱼韶粉香皮明月珰藕丝秋半云母米汤娇酂白吉量天球霜地余白溶溶月月魄冻缥草白不皂绍衣雷雨垂石涅墨黪驖骊京元

we can get a color using get_color

fb.get_color(name='凝夜紫')
num name name_en color_rgb color_html
161 161 凝夜紫 Noctilucence (68, 36, 84) #442454

Default Colormap

We have provided a range of default colors including green, red, pink, purple, yellow, brown, blue, and grey. Each of these colors comes with its own set of sub-colormaps, providing a more granular level of color differentiation.

Here’s a breakdown of the sub-colormaps available for each default color:

  • Green:

    • green1: Forbidden_Cmap(range(1, 19))

    • green2: Forbidden_Cmap(range(19, 41))

    • green3: Forbidden_Cmap(range(41, 62))

  • Red:

    • red1: Forbidden_Cmap(range(62, 77))

    • red2: Forbidden_Cmap(range(77, 104))

  • Pink:

    • pink1: Forbidden_Cmap(range(104, 134))

    • pink2: Forbidden_Cmap(range(134, 148))

  • Purple:

    • purple1: Forbidden_Cmap(range(148, 162))

    • purple2: Forbidden_Cmap(range(162, 176))

  • Yellow:

    • yellow1: Forbidden_Cmap(range(176, 196))

    • yellow2: Forbidden_Cmap(range(196, 207))

    • yellow3: Forbidden_Cmap(range(255, 276))

  • Brown:

    • brown1: Forbidden_Cmap(range(207, 228))

    • brown2: Forbidden_Cmap(range(228, 246))

    • brown3: Forbidden_Cmap(range(246, 255))

    • brown4: Forbidden_Cmap(range(276, 293))

  • Blue:

    • blue1: Forbidden_Cmap(range(293, 312))

    • blue2: Forbidden_Cmap(range(312, 321))

    • blue3: Forbidden_Cmap(range(321, 333))

    • blue4: Forbidden_Cmap(range(333, 339))

  • Grey:

    • grey1: Forbidden_Cmap(range(339, 356))

    • grey2: Forbidden_Cmap(range(356, 385))

Each main color can be represented as a combination of its sub-colormaps:

  • green = green1 + green2 + green3

  • red = red1 + red2

  • pink = pink1 + pink2

  • purple = purple1 + purple2

  • yellow = yellow1 + yellow2 + yellow3

  • brown = brown1 + brown2 + brown3 + brown4

  • blue = blue1 + blue2 + blue3 + blue4

  • grey = grey1 + grey2

These colormaps can be utilized in various applications where color differentiation is necessary, providing flexibility in visual representation.

palette is the argument we need to revise

import matplotlib.pyplot as plt
fig, axes = plt.subplots(1,3,figsize=(9,3)) 
ov.pl.embedding(adata,
                   basis='X_umap',
                    frameon='small',
                   color=["clusters"],
                   palette=fb.red[:],
                   ncols=3,
                show=False,
                legend_loc=None,
                    ax=axes[0])

ov.pl.embedding(adata,
                   basis='X_umap',
                    frameon='small',
                   color=["clusters"],
                   palette=fb.pink1[:],
                   ncols=3,show=False,
                legend_loc=None,
                    ax=axes[1])

ov.pl.embedding(adata,
                   basis='X_umap',
                    frameon='small',
                   color=["clusters"],
                   palette=fb.red1[:4]+fb.blue1,
                   ncols=3,show=False,
                    ax=axes[2])
<AxesSubplot: title={'center': 'clusters'}, xlabel='X_umap1', ylabel='X_umap2'>
../_images/314fc0fb14cfb8a337208097d6de9e8011434cc11021f357cc96841a3d210484.png
color_dict={'Astrocytes': '#e40414',
 'Cajal Retzius': '#ec5414',
 'Cck-Tox': '#ec4c2c',
 'Endothelial': '#d42c24',
 'GABA': '#2c5ca4',
 'Granule immature': '#acd4ec',
 'Granule mature': '#a4bcdc',
 'Microglia': '#8caccc',
 'Mossy': '#8cacdc',
 'Neuroblast': '#6c9cc4',
 'OL': '#6c94cc',
 'OPC': '#5c74bc',
 'Radial Glia-like': '#4c94c4',
 'nIPC': '#3474ac'}

ov.pl.embedding(adata,
                   basis='X_umap',
                    frameon='small',
                   color=["clusters"],
                   palette=color_dict,
                   ncols=3,show=False,
                    )
<AxesSubplot: title={'center': 'clusters'}, xlabel='X_umap1', ylabel='X_umap2'>
../_images/876c1b3a85c5c195e873e073a20515c5643b4ddf1ab4d5243b1bde1f3fc89e98.png

Segmented Colormap

When we need to create a continuous color gradient, we will use another function: get_cmap_seg, and we can combine the colors we need for visualization.

colors=[
    fb.get_color_rgb('群青'),
    fb.get_color_rgb('半见'),
    fb.get_color_rgb('丹罽'),
]
fb.get_cmap_seg(colors)
custom_cmap
custom_cmap colormap
under
bad
over
colors=[
    fb.get_color_rgb('群青'),
    fb.get_color_rgb('山矾'),
    fb.get_color_rgb('丹罽'),
]
fb.get_cmap_seg(colors)
custom_cmap
custom_cmap colormap
under
bad
over
colors=[
    fb.get_color_rgb('山矾'),
    fb.get_color_rgb('丹罽'),
]
fb.get_cmap_seg(colors)
custom_cmap
custom_cmap colormap
under
bad
over
ov.pl.embedding(adata,
                basis='X_umap',
                frameon='small',
                color=["Sox7"],
                cmap=fb.get_cmap_seg(colors),
                ncols=3,show=False,
                #vmin=-1,vmax=1
                )
<AxesSubplot: title={'center': 'Sox7'}, xlabel='X_umap1', ylabel='X_umap2'>
../_images/6bb3e49bd6910f08174d220c5591cecfcfc38588160620e8bd5f0cc8e13465f8.png