Skip to main content

DOI

ColorMyCells

A Biological Approach to Cell Type Visualization

colormycells is a Python package that solves a common problem in single-cell analysis: creating colormaps where the perceptual distance between colors meaningfully represents the biological similarity between cell types.

The Problem: Color Selection in Single-Cell Visualization

Standard colormaps like tab10 or rainbow aren't great when applied to single-cell data:

  • Biological meaning is lost: Default colormaps assign colors arbitrarily, with no relation to cell type similarity
  • Perceptual imbalance: Some colors jump out while others blend together, drawing attention to cell types for no biological reason
  • Limited palette: Most standard colormaps support 10-20 colors, but you may have hundreds of cell types
Standard Colormap ColorMyCells

Installation

pip install colormycells

For 3D visualization support (optional):

pip install colormycells[full]

Dependencies

  • numpy
  • pandas
  • matplotlib
  • seaborn
  • scikit-learn
  • scipy
  • colour-science

Optional Dependencies (for 3D visualization)

  • pillow
  • ipython

Usage

import scanpy as sc
from colormycells import get_colormap

# Load your data
adata = sc.read_h5ad("your_data.h5ad")

# Create a colormap based on cell type similarities
colors = get_colormap(adata, key="cell_type")

# Use the colormap for plotting
sc.pl.umap(adata, color="cell_type", palette=colors)

# Visualize the color space with 2D and 3D plots
colors = get_colormap(adata, key="cell_type", plot_colorspace=True)
# A 2D scatter plot will be displayed, and in Jupyter notebooks
# an interactive 3D rotating visualization will also be shown

# Create reproducible colormap with seed
colors1 = get_colormap(adata, key="cell_type", seed=123)
colors2 = get_colormap(adata, key="cell_type", seed=123)  # colors1 and colors2 will be identical

You can also pass a file path directly:

# Load directly from file
colors = get_colormap("your_data.h5ad", key="cell_type")

# Works with various file formats
colors = get_colormap("expression_matrix.csv", key="cell_type")

Parameters

  • adata: AnnData object with observations/cells as rows and variables/genes as columns
  • key: Key in adata.obs encoding cell type information (default: "cell_type")
  • plot_colorspace: Whether to visualize the colorspace (default: False)
  • include_unknown: Whether to include "Unknown" category in the colormap (default: False)
  • unknown_color: Color to use for "Unknown" category if not included (default: 'w')
  • deficiency: Type of color vision deficiency to simulate (options: None, "Deuteranomaly", "Protanomaly", "Tritanomaly", default: None)
  • severity: Severity of color vision deficiency (0-100, default: 0)
  • seed: Random seed for reproducible colormaps (default: 42, set to None for stochastic behavior)

Our Approach: Biology-Driven Color Assignment

colormycells takes a fundamentally different approach:

  1. Biological similarity drives color selection: Similar cell types receive similar colors
  2. Gene expression determines color: We use the average expression profile of each cell type (pseudobulk) to measure cell type similarity
  3. Perceptually uniform color space: We map cell type relationships to the LUV color space, where perceptual distances are uniform
  4. Intuitive visualization: The result is a colormap where visual intuition aligns with biological reality

The result is a colormap where:

  • Similar cell types appear in similar colors
  • Color distances reflect biological relationships
  • Visualizations become more intuitive to interpret

Description

Note

Color vision deficiency simulation is currently not fully implemented.

License

GPL-3.0 License

How to Cite

If you use ColorMyCells in your research, please cite:

Ari Benjamin. (2025). ColorMyCells: A Python package for biologically faithful colormaps for cell type visualization. (Version 0.1.0). Zenodo. https://doi.org/10.5281/zenodo.15595324

or the bibtex entry:

@software{colormycells2025,
  author       = {Benjamin, Ari},
  title        = {{ColorMyCells: A Python package for biologically
                  faithful colormaps for cell type visualization}},
  month        = jun,
  year         = 2025,
  publisher    = {Zenodo},
  version      = {0.1.0},
  doi          = {10.5281/zenodo.15595324},
  url          = {https://doi.org/10.5281/zenodo.15595324},
  note         = {Available at: https://github.com/ZadorLaboratory/colormycells}
}

Metadata

Release files for colormycells 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colormycells 0.1.3
File Size Uploaded Provenance
colormycells-0.1.3.tar.gz 23.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for colormycells 0.1.3
File Interpreter ABI Platform
colormycells-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 45.3 kB

Release files / colormycells-0.1.3.tar.gz

Download URL colormycells-0.1.3.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e2c40c4afa1c1a1c406ef044af9c60462211d68722281391b3605e9fdf066637
BLAKE2b-256 checksum
How to use checksums
c0cb14e00582683ed31eb26006cba4e37d47b431297f9b857ff8f513f1145b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / colormycells-0.1.3-py3-none-any.whl

Download URL colormycells-0.1.3-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4e4c719654c612637e4a35732b7eca6edcfae83f3bde99c3830b2a934cf695b
BLAKE2b-256 checksum
How to use checksums
3fc508858910537877f8e5fae2ab89a61c02d6aee3a63d3dc55e2fa98ef6f5d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Security for colormycells 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page