Skip to main content

cvmplot

PyPI - Version Static Badge

Table of content

Overview

cvmplot is a data visualization python package for SZQ lab used in TransposonSequencing/cgMLST/wgMLST data analysis based on matplotlib.

Installation

Python 3.9 or later is required for installation.

Install PyPI package:

pip3 install cvmplot

API Examples

Jupyter notebooks containing code examples below is available here.

General plot

import random
from cvmplot.cvmplot import cvmplot as cvmplot

# prepare cds data
gene_data = [
    {"start": 11120, "end": 13800, "strand": 1, "name": "gene1", 'color':'red'},
    {"start": 14231, "end": 15286, "strand": -1, "name": "gene2", 'color':'lightblue'},
    {"start": 16868, "end": 18212, "strand": 1, "name": "gene3", 'color':'green'},
    {"start": 18500, "end": 19863, "strand": -1, "name": "gene4", 'color':'blue'},
    {"start": 20123, "end": 24632, "strand": 1, "name": "gene5", 'color':'#d1af3f'},
    {"start": 25159, "end": 27000, "strand": -1, "name": "gene6", 'color':'cyan'},
    {"start": 27360, "end": 29888, "strand": 1, "name": "gene7", 'color':'#f9d9d9'},
]


bar_positions = np.random.randint(10000, 30000, size=1000) # Bar x-axis positions
bar_data = np.random.randint(50,100, size=1000) # Bar plot values


fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=True, cds_labelsize=7, cds_labrotation=45, track_start=10000, cds_color='lightblue'
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()

fig.savefig('general_plot.png', bbox_inches='tight')

general_plot.png

Add CDS track name using track_label

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=True, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs'
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('tracklabel_plot.png', bbox_inches='tight')

tracklabel_plot.png

Change CDS track label size using track_labsize

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=True, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_labelsize=8
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('tracklabelsize_plot.png', bbox_inches='tight')

tracklabelsize_plot.png

Change the height of CDS track using track_height

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=True, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_labelsize=8, track_height=0.3,
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('trackheight_plot.png', bbox_inches='tight')

trackheight_plot.png

Adjust the space between CDS track and insertion bar plot using bax_bottompos

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=True, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_labelsize=8, track_height=0.3, bax_bottompos=2
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('bax_bottompos.png',  bbox_inches='tight')

bax_bottompos.png

Display gene labels or not using cds_label

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=False, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_labelsize=8, track_height=0.3, bax_bottompos=2
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('cds_label.png',  bbox_inches='tight')

cds_label.png

Adjust the CDS track name using track_labelsize

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=False, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_height=0.3, bax_bottompos=2, track_labelsize=15
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('tracklabelsize.png', bbox_inches='tight')

tracklabelsize.png

Change the track sublabel using track_sublabelpos

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=False, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_height=0.3, bax_bottompos=2.2, track_labelsize=8, track_sublabelpos='top-right'
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('track_sublabelpos_plot.png', bbox_inches='tight')

track_sublabelpos_plot.png

Change the insertion frequency barplot color using bar_color

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=False, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_height=0.3, bax_bottompos=2.2, track_labelsize=8, track_sublabelpos='top-right',
                                   bar_color='lightblue'
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('barcolor_plot.png', bbox_inches='tight')

barcolor_plot.png

Change the insertion frequency barplot height using bax_height

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=False, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_height=0.3, bax_bottompos=2.2, track_labelsize=8, track_sublabelpos='top-right',
                                   bar_color='lightblue', bax_height=7
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('bax_height_plot.png', bbox_inches='tight')

bax_height_plot.png

Change the cds arrow using cds_arrowshaftratio

fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_length=20000,
                                   cds_label=False, cds_labelsize=7, cds_labrotation=45, track_start=10000, track_label='GENEs',
                                   track_height=0.3, bax_bottompos=2.2, track_labelsize=8, track_sublabelpos='top-right',
                                   bar_color='lightblue', bax_height=4, cds_arrowshaftratio=1
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('cds_arrowshaftratio_plot.png', bbox_inches='tight')

cds_arrowshaftratio_plot.png

Generate gene data from genbank file

gb2cds('GENEBANKE_FILE.gb') function will return a dict with contigs name as key and a list as value including the CDS 'start, end, strand, name, color' used in tnseqplot funtion

cds_data = cvmplot.gb2cds('HA3S26.gbff')
gene_data = cds_data['NODE_1_length_1210584_cov_117.87540']

# Simulate the insertion data in the range of 1-20000
bar_positions = np.random.randint(1, 20000, size=500) # Bar x-axis positions
bar_data = np.random.randint(50,100, size=500) # Bar plot values


fig, cds_ax, bar_ax = cvmplot.tnseqplot(inspos=bar_positions, inscount=bar_data, cds=gene_data, track_start=1,
                                   track_length=20000, cds_label=False, track_height=0.3, bax_bottompos=2
                                  )

bar_ax.set_ylabel('Insert frequency')
plt.show()
fig.savefig('genbank_plot.png', bbox_inches='tight')

genbank_plot.png

Metadata

Release files for cvmplot 0.1.2

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

Source distribution (sdist)

Source distribution for cvmplot 0.1.2
File Size Uploaded Provenance Actions
cvmplot-0.1.2.tar.gz 21.0 kB Without provenance Details for cvmplot-0.1.2.tar.gz

Built distribution (wheel)

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

Total release size: 40.1 kB

Release files / cvmplot-0.1.2.tar.gz

Download URL cvmplot-0.1.2.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a5fea51c6bfe2ee29800f32328e492271484200b3bd694f03f8ebc94b46b8b20
BLAKE2b-256 checksum
How to use checksums
657b9b88b2a94e1850624eac342da91e3c8e2f32a7d23654a84903518f554a03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release files / cvmplot-0.1.2-py3-none-any.whl

Download URL cvmplot-0.1.2-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4904a581de35b556f17d93fbbe7bac613b70ef487537512c87dc7c4e8f64d871
BLAKE2b-256 checksum
How to use checksums
713cdd2f4a67eb3c37292dd2643c5d4dc2096bd56278cd546dddd07895b8e83d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Security for cvmplot 0.1.2

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