Skip to main content

MSA visualization python package for sequence analysis

Project description

pyMSAviz

Python3 OS License Latest PyPI version Bioconda CI

Table of contents

Overview

pyMSAviz is a MSA(Multiple Sequence Alignment) visualization python package for sequence analysis implemented based on matplotlib. This package is developed for the purpose of easily and beautifully plotting MSA in Python. It also implements the functionality to add markers, text annotations, highlights to specific positions and ranges in MSA. pyMSAviz was developed inspired by Jalview and ggmsa. More detailed documentation is available here.

example01.png
Fig.1 Simple visualization result

example03.png
Fig.2 Customized visualization result

Installation

Python 3.7 or later is required for installation.

Install PyPI package:

pip install pymsaviz

Install bioconda package:

conda install -c conda-forge -c bioconda pymsaviz

API Usage

Only simple example usage is described in this section. For more details, please see Getting Started and API Docs.

API Example

API Example 1

from pymsaviz import MsaViz, get_msa_testdata

msa_file = get_msa_testdata("HIGD2A.fa")
mv = MsaViz(msa_file, wrap_length=60, show_count=True)
mv.savefig("api_example01.png")

example01.png

API Example 2

from pymsaviz import MsaViz, get_msa_testdata

msa_file = get_msa_testdata("MRGPRG.fa")
mv = MsaViz(msa_file, color_scheme="Taylor", wrap_length=80, show_grid=True, show_consensus=True)
mv.savefig("api_example02.png")

example02.png

API Example 3

from pymsaviz import MsaViz, get_msa_testdata

msa_file = get_msa_testdata("MRGPRG.fa")
mv = MsaViz(msa_file, end=180, wrap_length=60, show_consensus=True)

# Extract MSA positions less than 50% consensus identity
pos_ident_less_than_50 = []
ident_list = mv._get_consensus_identity_list()
for pos, ident in enumerate(ident_list, 1):
    if ident <= 50:
        pos_ident_less_than_50.append(pos)

# Add markers
mv.add_markers([1])
mv.add_markers([10, 20], color="orange", marker="o")
mv.add_markers([30, (40, 50), 55], color="green", marker="+")
mv.add_markers(pos_ident_less_than_50, marker="x", color="blue")
# Add text annotations
mv.add_text_annotation((76, 102), "Gap Region", text_color="red", range_color="red")
mv.add_text_annotation((112, 123), "Gap Region", text_color="green", range_color="green")

mv.savefig("api_example03.png")

example03.png

CLI Usage

pyMSAviz provides simple MSA visualization CLI.

Basic Command

pymsaviz -i [MSA file] -o [MSA visualization file]

Options

-i I, --infile I    Input MSA file
-o O, --outfile O   Output MSA visualization file (*.png|*.jpg|*.svg|*.pdf)
--format            MSA file format (Default: 'fasta')
--color_scheme      Color scheme (Default: 'Zappo')
--start             Start position of MSA visualization (Default: 1)
--end               End position of MSA visualization (Default: 'MSA Length')
--wrap_length       Wrap length (Default: None)
--wrap_space_size   Space size between wrap MSA plot area (Default: 3.0)
--show_grid         Show grid (Default: OFF)
--show_count        Show seq char count without gap on right side (Default: OFF)
--show_consensus    Show consensus sequence (Default: OFF)
--consensus_color   Consensus identity bar color (Default: '#1f77b4')
--consensus_size    Consensus identity bar height size (Default: 2.0)
--sort              Sort MSA order by NJ tree constructed from MSA distance matrix (Default: OFF)
--dpi               Figure DPI (Default: 300)
-v, --version       Print version information
-h, --help          Show this help message and exit

Available Color Schemes:
['Clustal', 'Zappo', 'Taylor', 'Flower', 'Blossom', 'Sunset', 'Ocean', 'Hydrophobicity', 'HelixPropensity', 
 'StrandPropensity', 'TurnPropensity', 'BuriedIndex', 'Nucleotide', 'Purine/Pyrimidine', 'Identity', 'None']

CLI Example

Click here to download example MSA files.

CLI Example 1

pymsaviz -i ./example/HIGD2A.fa -o cli_example01.png --color_scheme Identity

example01.png

CLI Example 2

pymsaviz -i ./example/MRGPRG.fa -o cli_example02.png --wrap_length 80 \
         --color_scheme Taylor --show_consensus --show_count

example02.png

CLI Example 3

pymsaviz -i ./example/MRGPRG.fa -o cli_example03.png --start 100 --end 160 \
         --color_scheme Flower --show_grid --show_consensus --consensus_color tomato 

example03.png

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

pymsaviz-0.2.1.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

pymsaviz-0.2.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file pymsaviz-0.2.1.tar.gz.

File metadata

  • Download URL: pymsaviz-0.2.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.15 Linux/5.15.0-1022-azure

File hashes

Hashes for pymsaviz-0.2.1.tar.gz
Algorithm Hash digest
SHA256 74d358ed4b3cce471467e18e216644fa9a26388d3361f7ff4c3d71178ac9808c
MD5 5f8e5c076311af6d686f90890e114bda
BLAKE2b-256 bb9b3e7674b67a7a8c5e75dd80926172f0134a78fe7d3db58a63404625c5d185

See more details on using hashes here.

File details

Details for the file pymsaviz-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pymsaviz-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.15 Linux/5.15.0-1022-azure

File hashes

Hashes for pymsaviz-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53a7adf2c12283d304cd14b0463e4d34021c50fb84319f33bff43ad54a3cdda1
MD5 88db541d5f62dfbc72cc50c210a71ed5
BLAKE2b-256 bf37ab69e6193c459f46b6408c53fe705f9f24ac2cb8511f5698ff611fccda49

See more details on using hashes here.

Supported by

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