Skip to main content

karyopyploter

DOI

PyPI - Version PyPI - Python Version Python package

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,
    make_genome_grid,
    annotate_ideogram,
    add_ideogram_coordinates,
    reset_coordinates,
    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)
# 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(TEST_DIR / "ideogram_grid1.png", dpi=300)

Will output: Example ideogram grid 1

# and with a subplots grid
fig, ax, ideogram_axes = make_ideogram_grid(
        subplot_width=15,
        grid_params=dict(hspace=1),
        ideogram_factor=0.3,
        target=[f"chr{contig_name}" for contig_name in chain(range(1, 5))],
        num_subplots=1,
        genome=genome,
    )
fig.savefig(TEST_DIR / "ideogram_grid2.png", dpi=300)

Will output: Example ideogram grid 2

# 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(TEST_DIR / "ideogram_grid3.png", dpi=300)

Will output: Example ideogram grid 3

# maybe we want to zoom in on specific regions
zoom_regions = {'chr1': (500000, 2500000), 'chr4': (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 / "ideogram_grid4.png", dpi=300)

Will output: Example ideogram grid 4

# or we want to show coordinates
for chr in zoom_regions:
    add_ideogram_coordinates(ideogram_axes[chr])
    reset_coordinates(ax[chr], ideogram_axes[chr])
fig.savefig(TEST_DIR / "ideogram_grid5.png", dpi=300)

Will output: Example ideogram grid 5

TODOs

  • Investigate the creation of circos plots, by polar transformation.
  • Provide more detailed documentation, as some features are not described

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

Metadata

Release files for karyopyploter 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for karyopyploter 0.2.0
File Size Uploaded Provenance Actions
karyopyploter-0.2.0.tar.gz 1.8 MB Without provenance Details for karyopyploter-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for karyopyploter 0.2.0
File Interpreter ABI Platform Actions
karyopyploter-0.2.0-py3-none-any.whl Python 3 none any Details for karyopyploter-0.2.0-py3-none-any.whl

Total release size: 1.8 MB

Release files / karyopyploter-0.2.0.tar.gz

Download URL karyopyploter-0.2.0.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
39ea71a85eec17ad777779a1219ed3be42546998145f4772a1f4016d5574beb9
BLAKE2b-256 checksum
How to use checksums
ad3c063bb969c698bb2425d18b70978a92ce1ff2dbe6162bf44e9e11bf541e46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Release files / karyopyploter-0.2.0-py3-none-any.whl

Download URL karyopyploter-0.2.0-py3-none-any.whl
Size 36.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d7e97f5ac45bb68ea44856533092e9531d30c303614a60ec2c836614f18400f
BLAKE2b-256 checksum
How to use checksums
96194e999f4d185cb75413c929b138fda8a19aaed6b1ad36eeee1aab6a068c19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Security for karyopyploter 0.2.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page