# Allen Brain Atlas Colormaps
[](https://badge.fury.io/py/allen-brain-colormaps)
[](https://opensource.org/licenses/MIT)
A Python package providing matplotlib and seaborn compatible colormaps for human brain cell types from the Allen Institute Brain Atlas.
## Features
- **Hierarchical color schemes** for brain cell types at three levels:
- **Class level**: 3 major categories (Non-neuronal, GABAergic, Glutamatergic)
- **Subclass level**: 24 subclasses (Astrocyte, Microglia-PVM, L6 IT, etc.)
- **Supertype level**: 136 detailed cell clusters
- **Matplotlib integration**: Register as standard matplotlib colormaps
- **Seaborn compatibility**: Works seamlessly with seaborn plotting functions
- **Consistent colors**: Based on official Allen Institute brain atlas color scheme
- **Easy to use**: Simple API for getting colors and colormaps
## Installation
```bash
pip install allen-brain-colormaps
```
## Quick Start
```python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from allen_brain_colormaps import get_brain_colors, get_brain_cmap, plot_brain_palette
# Get colors for specific cell types
colors = get_brain_colors('subclass', ['Astrocyte', 'Microglia-PVM', 'L6 IT'])
print(colors)
# {'Astrocyte': '#665C47', 'Microglia-PVM': '#94AF97', 'L6 IT': '#A19922'}
# Use with matplotlib
fig, ax = plt.subplots()
cell_types = ['Astrocyte', 'Pvalb', 'Vip', 'Sst']
values = [100, 80, 60, 40]
colors = get_brain_colors('subclass', cell_types)
ax.bar(cell_types, values, color=[colors[ct] for ct in cell_types])
# Use with seaborn
df = pd.DataFrame({'cell_type': cell_types, 'expression': values})
sns.barplot(data=df, x='cell_type', y='expression',
palette=get_brain_colors('subclass', cell_types))
# Get matplotlib colormap
cmap = get_brain_cmap('subclass')
plt.scatter(x, y, c=labels, cmap=cmap)
# Visualize color palette
plot_brain_palette('subclass')
plt.show()
```
## Usage Examples
### Basic Color Access
```python
from allen_brain_colormaps import get_brain_colors
# Get all colors for a hierarchy level
all_subclass_colors = get_brain_colors('subclass')
# Get colors for specific cell types
my_colors = get_brain_colors('supertype', ['Astro_1', 'Pvalb_1', 'Vip_1'])
# Available levels: 'class', 'subclass', 'supertype'
class_colors = get_brain_colors('class')
```
### Matplotlib Integration
```python
import matplotlib.pyplot as plt
from allen_brain_colormaps import get_brain_cmap
# Use as standard matplotlib colormap
cmap = get_brain_cmap('subclass')
plt.imshow(data, cmap=cmap)
# For categorical data
fig, ax = plt.subplots()
scatter = ax.scatter(x, y, c=cell_type_labels, cmap=cmap)
plt.colorbar(scatter)
```
### Seaborn Integration
```python
import seaborn as sns
from allen_brain_colormaps import get_brain_colors
# Direct palette use
cell_types = df['cell_type'].unique()
palette = get_brain_colors('subclass', cell_types)
sns.boxplot(data=df, x='cell_type', y='expression', palette=palette)
# With categorical plots
sns.catplot(data=df, x='condition', y='value', hue='cell_type',
palette=get_brain_colors('subclass'), kind='bar')
```
### Advanced Usage
```python
from allen_brain_colormaps import AllenBrainColormaps
# Create instance for advanced control
brain = AllenBrainColormaps()
# Get specific colormap
cmap = brain.get_cmap('supertype')
# Plot all available palettes
for level in ['class', 'subclass', 'supertype']:
brain.plot_palette(level)
plt.show()
```
## Cell Type Hierarchies
### Class Level (3 types)
- Non-neuronal and Non-neural
- Neuronal: GABAergic
- Neuronal: Glutamatergic
### Subclass Level (24 types)
- Astrocyte, Microglia-PVM, L6 IT, VLMC, L6 CT, Pvalb, Oligodendrocyte, Vip, Endothelial, L6b, Sncg, L5 IT, L2/3 IT, L5/6 NP, Sst, L6 IT Car3, OPC, Chandelier, L4 IT, L5 ET, Lamp5, Pax6, Sst Chodl, Lamp5 Lhx6
### Supertype Level (136 types)
- Detailed cluster-level annotations (Astro_1, Astro_2, Pvalb_1, Pvalb_2, etc.)
## API Reference
### Functions
- `get_brain_colors(level, cell_types=None)`: Get color dictionary for cell types
- `get_brain_cmap(level)`: Get matplotlib colormap
- `plot_brain_palette(level, figsize=(12, 8))`: Visualize color palette
### AllenBrainColormaps Class
```python
brain = AllenBrainColormaps()
brain.get_class_colors(cell_types=None)
brain.get_subclass_colors(cell_types=None)
brain.get_supertype_colors(cell_types=None)
brain.get_cmap(level='subclass')
brain.plot_palette(level='subclass', figsize=(12, 8))
```
## Data Source
Colors are based on the Allen Institute Brain Atlas single-cell RNA-seq datasets. The color scheme maintains consistency with the original research and provides a standardized palette for neuroscience visualizations.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Citation
If you use this package in your research, please cite the Allen Institute for Brain Science publications.
## Acknowledgments
- Allen Institute for Brain Science for the original color scheme
Raw data
{
"_id": null,
"home_page": null,
"name": "allen-brain-colormaps",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Matthias Flotho <matthias.flotho@ccb.uni-saarland.de>",
"keywords": "neuroscience, single-cell, visualization, colormap, matplotlib, seaborn, allen-brain-atlas, human-brain, cell-types, transcriptomics",
"author": null,
"author_email": "Matthias Flotho <matthias.flotho@ccb.uni-saarland.de>",
"download_url": "https://files.pythonhosted.org/packages/83/0a/4d7e59d091e1a1ab6eb4671cfe7a5723df5352a83945e7015998c4de5786/allen_brain_colormaps-0.1.2.tar.gz",
"platform": null,
"description": "# Allen Brain Atlas Colormaps\n\n[](https://badge.fury.io/py/allen-brain-colormaps)\n[](https://opensource.org/licenses/MIT)\n\nA Python package providing matplotlib and seaborn compatible colormaps for human brain cell types from the Allen Institute Brain Atlas.\n\n## Features\n\n- **Hierarchical color schemes** for brain cell types at three levels:\n - **Class level**: 3 major categories (Non-neuronal, GABAergic, Glutamatergic)\n - **Subclass level**: 24 subclasses (Astrocyte, Microglia-PVM, L6 IT, etc.)\n - **Supertype level**: 136 detailed cell clusters\n- **Matplotlib integration**: Register as standard matplotlib colormaps\n- **Seaborn compatibility**: Works seamlessly with seaborn plotting functions\n- **Consistent colors**: Based on official Allen Institute brain atlas color scheme\n- **Easy to use**: Simple API for getting colors and colormaps\n\n## Installation\n\n```bash\npip install allen-brain-colormaps\n```\n\n## Quick Start\n\n```python\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport pandas as pd\nfrom allen_brain_colormaps import get_brain_colors, get_brain_cmap, plot_brain_palette\n\n# Get colors for specific cell types\ncolors = get_brain_colors('subclass', ['Astrocyte', 'Microglia-PVM', 'L6 IT'])\nprint(colors)\n# {'Astrocyte': '#665C47', 'Microglia-PVM': '#94AF97', 'L6 IT': '#A19922'}\n\n# Use with matplotlib\nfig, ax = plt.subplots()\ncell_types = ['Astrocyte', 'Pvalb', 'Vip', 'Sst']\nvalues = [100, 80, 60, 40]\ncolors = get_brain_colors('subclass', cell_types)\nax.bar(cell_types, values, color=[colors[ct] for ct in cell_types])\n\n# Use with seaborn\ndf = pd.DataFrame({'cell_type': cell_types, 'expression': values})\nsns.barplot(data=df, x='cell_type', y='expression', \n palette=get_brain_colors('subclass', cell_types))\n\n# Get matplotlib colormap\ncmap = get_brain_cmap('subclass')\nplt.scatter(x, y, c=labels, cmap=cmap)\n\n# Visualize color palette\nplot_brain_palette('subclass')\nplt.show()\n```\n\n## Usage Examples\n\n### Basic Color Access\n\n```python\nfrom allen_brain_colormaps import get_brain_colors\n\n# Get all colors for a hierarchy level\nall_subclass_colors = get_brain_colors('subclass')\n\n# Get colors for specific cell types\nmy_colors = get_brain_colors('supertype', ['Astro_1', 'Pvalb_1', 'Vip_1'])\n\n# Available levels: 'class', 'subclass', 'supertype'\nclass_colors = get_brain_colors('class')\n```\n\n### Matplotlib Integration\n\n```python\nimport matplotlib.pyplot as plt\nfrom allen_brain_colormaps import get_brain_cmap\n\n# Use as standard matplotlib colormap\ncmap = get_brain_cmap('subclass')\nplt.imshow(data, cmap=cmap)\n\n# For categorical data\nfig, ax = plt.subplots()\nscatter = ax.scatter(x, y, c=cell_type_labels, cmap=cmap)\nplt.colorbar(scatter)\n```\n\n### Seaborn Integration\n\n```python\nimport seaborn as sns\nfrom allen_brain_colormaps import get_brain_colors\n\n# Direct palette use\ncell_types = df['cell_type'].unique()\npalette = get_brain_colors('subclass', cell_types)\nsns.boxplot(data=df, x='cell_type', y='expression', palette=palette)\n\n# With categorical plots\nsns.catplot(data=df, x='condition', y='value', hue='cell_type',\n palette=get_brain_colors('subclass'), kind='bar')\n```\n\n### Advanced Usage\n\n```python\nfrom allen_brain_colormaps import AllenBrainColormaps\n\n# Create instance for advanced control\nbrain = AllenBrainColormaps()\n\n# Get specific colormap\ncmap = brain.get_cmap('supertype')\n\n# Plot all available palettes\nfor level in ['class', 'subclass', 'supertype']:\n brain.plot_palette(level)\n plt.show()\n```\n\n## Cell Type Hierarchies\n\n### Class Level (3 types)\n- Non-neuronal and Non-neural\n- Neuronal: GABAergic \n- Neuronal: Glutamatergic\n\n### Subclass Level (24 types)\n- Astrocyte, Microglia-PVM, L6 IT, VLMC, L6 CT, Pvalb, Oligodendrocyte, Vip, Endothelial, L6b, Sncg, L5 IT, L2/3 IT, L5/6 NP, Sst, L6 IT Car3, OPC, Chandelier, L4 IT, L5 ET, Lamp5, Pax6, Sst Chodl, Lamp5 Lhx6\n\n### Supertype Level (136 types)\n- Detailed cluster-level annotations (Astro_1, Astro_2, Pvalb_1, Pvalb_2, etc.)\n\n## API Reference\n\n### Functions\n\n- `get_brain_colors(level, cell_types=None)`: Get color dictionary for cell types\n- `get_brain_cmap(level)`: Get matplotlib colormap\n- `plot_brain_palette(level, figsize=(12, 8))`: Visualize color palette\n\n### AllenBrainColormaps Class\n\n```python\nbrain = AllenBrainColormaps()\nbrain.get_class_colors(cell_types=None)\nbrain.get_subclass_colors(cell_types=None) \nbrain.get_supertype_colors(cell_types=None)\nbrain.get_cmap(level='subclass')\nbrain.plot_palette(level='subclass', figsize=(12, 8))\n```\n\n## Data Source\n\nColors are based on the Allen Institute Brain Atlas single-cell RNA-seq datasets. The color scheme maintains consistency with the original research and provides a standardized palette for neuroscience visualizations.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Citation\n\nIf you use this package in your research, please cite the Allen Institute for Brain Science publications.\n\n## Acknowledgments\n\n- Allen Institute for Brain Science for the original color scheme\n",
"bugtrack_url": null,
"license": null,
"summary": "Matplotlib and seaborn compatible colormaps for human brain cell types from the Allen Institute Brain Atlas",
"version": "0.1.2",
"project_urls": {
"Allen Institute": "https://alleninstitute.org/",
"Brain Atlas": "https://portal.brain-map.org/",
"Bug Tracker": "https://github.com/maflot/allen-brain-colormaps/issues",
"Documentation": "https://allen-brain-colormaps.readthedocs.io/",
"Homepage": "https://github.com/maflot/allen-brain-colormaps",
"Release Notes": "https://github.com/maflot/allen-brain-colormaps/releases",
"Repository": "https://github.com/maflot/allen-brain-colormaps"
},
"split_keywords": [
"neuroscience",
" single-cell",
" visualization",
" colormap",
" matplotlib",
" seaborn",
" allen-brain-atlas",
" human-brain",
" cell-types",
" transcriptomics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "16f4856ec8f16770ba8fae6bc4a4e458a63b0e46876228f9ccb669689de8778a",
"md5": "0f5ca8801317af25939fafad31f68c6e",
"sha256": "316241f33e0055beaf8607998eaa41ee27567eae104e7f69f1c9148d30e2a4d3"
},
"downloads": -1,
"filename": "allen_brain_colormaps-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0f5ca8801317af25939fafad31f68c6e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9156,
"upload_time": "2025-07-08T12:42:20",
"upload_time_iso_8601": "2025-07-08T12:42:20.752225Z",
"url": "https://files.pythonhosted.org/packages/16/f4/856ec8f16770ba8fae6bc4a4e458a63b0e46876228f9ccb669689de8778a/allen_brain_colormaps-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "830a4d7e59d091e1a1ab6eb4671cfe7a5723df5352a83945e7015998c4de5786",
"md5": "62067bc7a09c929870d1fbd0f98e0e4a",
"sha256": "31209f61d6c528b330e4ff2fd4dffb3e3cddf72fa2ca92a0e423d699cec99c95"
},
"downloads": -1,
"filename": "allen_brain_colormaps-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "62067bc7a09c929870d1fbd0f98e0e4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 10394,
"upload_time": "2025-07-08T12:42:22",
"upload_time_iso_8601": "2025-07-08T12:42:22.410729Z",
"url": "https://files.pythonhosted.org/packages/83/0a/4d7e59d091e1a1ab6eb4671cfe7a5723df5352a83945e7015998c4de5786/allen_brain_colormaps-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-08 12:42:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "maflot",
"github_project": "allen-brain-colormaps",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "allen-brain-colormaps"
}