ComplexHeatmap-python
A Python port of the R ComplexHeatmap package (v2.25.3), built on grid_py — a pure-Python reimplementation of R's grid graphics system.
No matplotlib dependency. The entire rendering pipeline uses grid_py's Cairo backend, producing publication-quality output identical to R's grid device.
Features
- Heatmap with row/column clustering, splitting (k-means, factor), dendrograms, and custom color mapping
- HeatmapList for combining multiple heatmaps horizontally (
+) or vertically (%), with synchronized row/column ordering and cross-heatmap body alignment - 20 annotation functions:
anno_barplot,anno_points,anno_lines,anno_mark,anno_text,anno_boxplot,anno_histogram,anno_density,anno_block,anno_image, and more - HeatmapAnnotation with flexible sizing, gap control, and annotation name positioning
- Legends with continuous color bars and discrete icon legends, packable and positionable on all four sides
- oncoPrint for mutation landscape visualization
- UpSet plots for set intersection analysis
- Heatmap3D for 3D bar-style heatmaps with CIE LUV/HCL color space
- densityHeatmap and frequencyHeatmap for distribution visualization
- Global options via
ht_opt()matching R'sht_opt$...interface - Decoration API (
decorate_heatmap_body,decorate_annotation, etc.) for post-draw customization
Installation
pip install complexheatmap-python
Or, for a local development checkout:
git clone https://github.com/Bio-Babel/ComplexHeatmap_python.git
cd ComplexHeatmap_python
pip install -e ".[dev]"
Quick Start
import numpy as np
from complexheatmap import Heatmap, color_ramp2
mat = np.random.randn(20, 10)
col = color_ramp2([-2, 0, 2], ["blue", "white", "red"])
ht = Heatmap(mat, name="example", col=col,
row_km=3, column_title="My Heatmap")
ht.draw()
Combining Heatmaps
import grid_py as gp
from complexheatmap import Heatmap, color_ramp2, rowAnnotation, anno_barplot
np.random.seed(42)
mat1 = np.random.randn(20, 8)
mat2 = np.random.randn(20, 5)
ht1 = Heatmap(mat1, name="expr",
col=color_ramp2([-2, 0, 2], ["green", "white", "red"]))
ht2 = Heatmap(mat2, name="cnv",
col=color_ramp2([-1, 0, 1], ["blue", "white", "orange"]))
ht_list = ht1 + ht2 + rowAnnotation(
bar=anno_barplot(np.random.randn(20), which="row"),
width=gp.Unit(2, "cm"),
)
ht_list.draw(merge_legends=True)
Tutorials
Jupyter notebooks porting the official R ComplexHeatmap tutorials:
| # | Notebook | Topic |
|---|---|---|
| 1 | Single Heatmap | Colors, clustering, splitting, annotations, labels |
| 2 | Heatmap Annotations | All 20 annotation types, sizing, decoration |
| 3 | A List of Heatmaps | Horizontal/vertical combination, row/column sync |
| 4 | Legends | Continuous/discrete legends, positioning |
| 5 | Heatmap Decoration | Post-draw customization via decorate API |
| 6 | OncoPrint | Mutation landscape visualization |
| 7 | UpSet Plot | Set intersection analysis |
| 8 | Integration | Combining with other analyses |
| 9 | Other High-Level Plots | densityHeatmap, frequencyHeatmap |
| 10 | 3D Heatmap | Heatmap3D with bar projections |
| 11 | Genome-Level Heatmap | Chromosome-split genome visualization |
| 12 | Examples | Gene expression, measles, methylation |
| 13 | Other Tricks | Utility functions, text measurement, ht_opt |
Testing
pip install -e ".[dev]"
pytest tests/
Metadata
Release files for complexheatmap-python 2.25.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| complexheatmap_python-2.25.3.tar.gz | 3.7 MB | Without provenance | Details for complexheatmap_python-2.25.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| complexheatmap_python-2.25.3-py3-none-any.whl | Python 3 | none | any | Details for complexheatmap_python-2.25.3-py3-none-any.whl |
Total release size: 7.4 MB
Release files / complexheatmap_python-2.25.3.tar.gz
| Download URL | complexheatmap_python-2.25.3.tar.gz |
|---|---|
| Size | 3.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f27e259dd721ff949f2e42dc9efcbc9c7003a03b4cf19feb3cc861353493b042
|
|
BLAKE2b-256 checksum How to use checksums |
e3caf2f2c839ababee161bff8151a69ee353deee486c575f96842f85d96e14a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / complexheatmap_python-2.25.3-py3-none-any.whl
| Download URL | complexheatmap_python-2.25.3-py3-none-any.whl |
|---|---|
| Size | 3.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d73a0124b29f3b07bae2179158e3a38b193e112816f39839e00b3e8bce7807a
|
|
BLAKE2b-256 checksum How to use checksums |
d67bb4a88bd9d62de3fba15cb53378d017dc7be59c4af6dc75a47da206531574
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for complexheatmap-python 2.25.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.