pheatmap for Python
Project description
pheatmap
pheatmap for Python.
You can create a heatmap with its annotation bars, just like pheatmap of R. Documnets at here
Requirements
pheatmap need python > 3.8, and numpy, pandas and matplolib.
Install
You can install pheatmap by pip.
pip install pheatmap
Run the command above, pip will automatically install numpy, pandas and matplolib.
Usage
import numpy as np
import pandas as pd
from pheatmap import pheatmap
nrows, ncols = 10, 10
mat = np.linspace(-1, 1, nrows * ncols).reshape(nrows, ncols)
rownames = ["abcdefghig"[i % 10] for i in np.arange(nrows)]
colnames = ["xyz"[i % 3] for i in np.arange(ncols)]
mat = pd.DataFrame(mat, index=rownames, columns=colnames)
anno_row = pd.DataFrame(dict(
anno1=np.linspace(0, 10, nrows),
anno2=["CNS"[i % 3] for i in np.arange(nrows)]
))
anno_col = pd.DataFrame(dict(
anno3=np.linspace(0, 20, ncols),
anno4=["ABC"[i % 3] for i in np.arange(ncols)]
))
anno_row_cmaps = {"anno1": "Blues", "anno2": "Set1"}
anno_col_cmaps = {"anno3": "Purples", "anno4": "Set3"}
fig = pheatmap(
self.mat, annotation_row=self.anno_row, annotation_col=self.anno_col,
annotation_row_cmaps=self.anno_row_cmaps, annotation_col_cmaps=self.anno_col_cmaps
)
fig.savefig("tests/pheatmap.png")
Run the above code at the ipython or jupyter notebook. You can see the fellow heatmap with its annotation bars.
Also, you can save the figure to file. For example, save the figure to PDF file.
fig.savefig("pheatmap.pdf")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pheatmap-1.0.1.tar.gz.
File metadata
- Download URL: pheatmap-1.0.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c83bf267c20b1652c1961d8b13ccb0799da317a108254f81a73cd0799b17f0e
|
|
| MD5 |
cec1ef157523d06fb13d66c5985ebfac
|
|
| BLAKE2b-256 |
c47762d8e5f76bfe06f337e1569fe2ed66efe5d76eefb9f6194427ca00a15880
|
File details
Details for the file pheatmap-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pheatmap-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a5da6c4026c96f7b2259b67c35e97cf3b379134671886dd8c018222c7409db6
|
|
| MD5 |
8f6da075ff0a7958ea49a0b4630d5550
|
|
| BLAKE2b-256 |
12754b384579247b3a11f0310c839d0adab28ada701db27b5d3a9070e7e8f66c
|