Skip to main content

Package to mimic the functionality of KaryoploteR, but in Python.

Project description

DOI

karyopyploter

PyPI - Version PyPI - Python Version


Table of Contents

Acknowledgements

This project was based on the work by @Adoni5 and his repository pyryotype. It was made to provide similar functionality to what is being offered by KaryoploteR package, but in a more pythonic style, using Matplotlib as the basis, and giving the user full liberty to plot anything they want.

Installation

    pip install karyopyploter

Example usage

from karyopyploter import GENOME, plot_ideogram, make_ideogram_grid, annotate_ideogram, zoom
from matplotlib import pyplot as plt
from itertools import chain
from pathlib import Path

OUT_DIR = Path(__file__).parent.parent / "example_outputs" / "readme_example"
OUT_DIR.mkdir(parents=True, exist_ok=True)
genome = GENOME.CHM13

fig, axes = plt.subplots(
    ncols=1,
    nrows=22,
    figsize=(11, 11),
    facecolor="white",
)
for ax, contig_name in zip(axes, [f"chr{i}" for i in chain(range(1, 23), "XY")]):
    chromosome = contig_name
    plot_ideogram(ax, target=chromosome, genome=genome, label=contig_name)
fig.savefig(OUT_DIR / "ideogram1.png", dpi=300)
# similar to:
fig = plt.figure(figsize=(11, 11), facecolor="white")
fig, _, ideogram_axes = make_ideogram_grid(target=[f"chr{contig_name}" for contig_name in chain(range(1, 23), "XY")], num_subplots=0, genome=genome, fig=fig)
fig.savefig(OUT_DIR / "ideogram2.png", dpi=300)

Will output: Example ideogram 2

# and with a subplots grid
fig, ax, ideogram_axes = make_ideogram_grid(subplot_width=15,ideogram_factor=0.2, target=[f"chr{contig_name}" for contig_name in chain(range(1, 23), "XY")], num_subplots=1, genome=genome)
fig.savefig(OUT_DIR / "ideogram3.png", dpi=300)

Will output: Example ideogram 3

# and with some regions annotated
regions = {'chr1':[(1000000,2000000, "red")], 'chr2':[(3000000, 4000000, 'blue')], 'chr3':[(5000000,6000000, (0,1,0)), (7000000,8000000, (1,0,0))]}
for chr in regions:
    annotate_ideogram(ideogram_axes[chr], regions=regions[chr], genome=genome)
fig.savefig(OUT_DIR / "ideogram4.png", dpi=300)

Will output: Example ideogram 4

# maybe we want to zoom in on specific regions
zoom_regions = {'chr1':(500000,2500000), 'chr10':(3000000, 4000000)}
for chr in zoom_regions:
    zoom(ideogram_axes[chr], start=zoom_regions[chr][0], stop=zoom_regions[chr][1])
fig.savefig(OUT_DIR / "ideogram5.png", dpi=300)

Will output: Example ideogram 5

TODOs

  • Add the ability to have axis ticks in human format
  • Provide more detailed documentation, as some features are not described (e.g. the make_genome_grid function)

License

karyopyploter is distributed under the terms of the BSD-3-Clause license. Feel free to use in both academic and commercial applications, and please consider to cite the software in your work.

Cytoband data

  • HG38
  • HG19
  • CHM13

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

karyopyploter-0.1.3.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

karyopyploter-0.1.3-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file karyopyploter-0.1.3.tar.gz.

File metadata

  • Download URL: karyopyploter-0.1.3.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for karyopyploter-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e55475169ff6c1beb224ae965c6fcc96989b29db5b181d912080a6ad1a6a0340
MD5 6316d12d5cc5b2268c47d7e85c5e95e0
BLAKE2b-256 5d155a62f4ea3ebb536819c958b2f503867ab4054638c0832ee85390797bf2a6

See more details on using hashes here.

File details

Details for the file karyopyploter-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: karyopyploter-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for karyopyploter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2323f6464a184ff938e019540e42b30fd8aa9265d9eed442697f627d33e6ecf0
MD5 9b5135051f83aab22b1fc867f509e673
BLAKE2b-256 38415e3fdf56f77262656f95cd1b9d107b6972f17f836a4019b8fc12fec12063

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page