plot ideograms in matplotlib
Project description
pyideogram
Introduction
This is a python package to plot ideograms in matplotlib, as well as simple gene tracks. I made this primarily for myself, since I could not find any nice looking svg supporting ideogram package in python that works well with matplotlib. The general design idea is that the functions should be intuitive to use for someone familiar with matplotlib and give reasonably well looking output with minimal configuration, but should also have the flexibility of other matplotlib functions. So the underlying matplotlib functions can be manipulated directly by giving the correct kwargs.
Installation
You can easily install it via pip from pypi
pip install pyideogram
or install it manually:
git clone https://github.com/balthasar-eu/pyideogram.git
cd pyideogram
pip install .
Dependencies are python3.10, matplotlib and numpy
Usage
The package comes with integrated cytobands files for hg19 and hg38, as well as MANE transcripts (only positions, and orientation) for hg38. If you run any of the functions without providing annotation files, it will assume you want to use the stored ones.
The package currently has ideogramh and ideogramv which plot horizontal and vertical ideograms respectively, as well as a genetrack function, which can plot transcripts and exons from gtf files.
full_ideogram iterates over all chromosomes and plots them with either ideogramh or ideogramv. Help is available for all functions int he docstring, which you can get with help().
Examples
import pyideogram
fig = pyideogram.full_ideogram()
fig.show()
import pyideogram
from matplotlib import pyplot as plt
chrom = "chr6"
fig = plt.figure(figsize=(10, 4), dpi=150)
fig.suptitle("Chromsome 6")
gs = fig.add_gridspec(
nrows=6,
ncols=3,
width_ratios=[2, 20, 2],
height_ratios=[1, 1, 0.5, 1, 0.5, 1],
hspace=0.01,
left=0.01,
right=0.99,
top=0.94,
)
start = 29942000
end = 29946000
ax = fig.add_subplot(gs[0, :])
pyideogram.genetrack(
f"{chrom}:{start}-{end}",
ax=ax,
textlane=True,
transcriptstyle="arrowed",
exonstyle="Box",
)
all_chrom = fig.add_subplot(gs[2, 1])
all_chrom.axis("off")
all_chrom.set_xticks([])
pyideogram.ideogramh(chrom, ax=all_chrom)
pyideogram.zoom(ax, all_chrom)
pyideogram.set_genome_xticks(ax)
start = 130000000
end = 135000000
ax = fig.add_subplot(gs[5, :])
pyideogram.genetrack(
f"{chrom}:{start}-{end}",
ax=ax,
lanenum=5,
trackkwargs={
"color": "lightblue",
},
textlane=False,
text_clip_width=True,
)
pyideogram.set_genome_xticks(ax)
ax = fig.add_subplot(gs[4, :], sharex=ax)
ax.set_xlim(start, end)
pyideogram.ideogramh(chrom, ax=ax, names=True)
pyideogram.zoom(ax, all_chrom)
plt.axis("off")
ax.tick_params(labelbottom=False)
Citation
There is currently no publication attached to this package.
If you use the provided annotation for plotting genes, you might want to cite the MANE paper.
You might also want to cite matplotlib.
Project details
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 pyideogram-0.1.1.tar.gz.
File metadata
- Download URL: pyideogram-0.1.1.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93388687b060743cf6d945b3eb6493be120c663b49c0d5bf4abcaffa657ac0af
|
|
| MD5 |
ecb9206466f0bf44c187f64fecba849a
|
|
| BLAKE2b-256 |
0619ad4b53802146aa528c9f06aad1acd03201e43e16bd143c310b63a4acfd32
|
Provenance
The following attestation bundles were made for pyideogram-0.1.1.tar.gz:
Publisher:
publish.yml on Balthasar-eu/pyideogram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyideogram-0.1.1.tar.gz -
Subject digest:
93388687b060743cf6d945b3eb6493be120c663b49c0d5bf4abcaffa657ac0af - Sigstore transparency entry: 834969415
- Sigstore integration time:
-
Permalink:
Balthasar-eu/pyideogram@caa841052167a59cfe802f62c2be5d6ada5c043d -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/Balthasar-eu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@caa841052167a59cfe802f62c2be5d6ada5c043d -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyideogram-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyideogram-0.1.1-py3-none-any.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7147451de2a696003c5be4792ab5f4441b46c032611ba51a2239a273d648e026
|
|
| MD5 |
221cc718710739da1112a1bac496c735
|
|
| BLAKE2b-256 |
d94e4d18bf09cf29775d554df311068cd597fc0f748cdea91d732e41abf58605
|
Provenance
The following attestation bundles were made for pyideogram-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Balthasar-eu/pyideogram
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyideogram-0.1.1-py3-none-any.whl -
Subject digest:
7147451de2a696003c5be4792ab5f4441b46c032611ba51a2239a273d648e026 - Sigstore transparency entry: 834969427
- Sigstore integration time:
-
Permalink:
Balthasar-eu/pyideogram@caa841052167a59cfe802f62c2be5d6ada5c043d -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/Balthasar-eu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@caa841052167a59cfe802f62c2be5d6ada5c043d -
Trigger Event:
release
-
Statement type: