Skip to main content

A tool for exploring multiple sequence alignments.

Project description

Logo

language License: GPL v3 PiPy Downloads

MSAexplorer is a python package and also a standalone app to analyse multiple sequence alignments and generate publication ready figures. Want to just use the MSAexplorer app? The curently stable version of the MSAexplorer app is hosted on github pages.

[!WARNING]
You might fall in love with plotting alignments in python.

Requirements and installation

[!NOTE] MSAexplorer can be installed via PyPi. There are three different possibilities depending on whether you want to only install the python package or the python package and front end app or the python package, front end app and additional tools for aligning and trimming.

Requirements prior installation

python >= python 3.11

Basic installation (python library):

Relies on:

  • matplotlib>=3.8
  • biopython>=1.81
  • numpy>=2.0

Can be installed via:

pip install msaexplorer 

Extended installation (python library + app):

Relies on:

  • matplotlib>=3.8
  • biopython>=1.81
  • numpy>=2.0
  • shiny>=1.3
  • shinywidgets>=0.5.2
  • plotly>=5.23

Can be installed via:

pip install msaexplorer[app] 

Full installation (python library + app + in-app calculations).

[!NOTE] Pyfamsa and pytrimal will require that Cmake is installed.

Relies on:

  • matplotlib>=3.8
  • biopython>=1.81
  • numpy>=2.0
  • shiny>=1.3
  • shinywidgets>=0.5.2
  • plotly>=5.23
  • pyfamsa>=0.5.3
  • pytrimal>=0.8.1

Can be installed via:

pip install msaexplorer[app-plus] 

Installation for development

git clone https://github.com/jonas-fuchs/MSAexplorer
cd MSAexplorer
pip install .[app-plus]

Features of MSAexplorer as an app

usage:  msaexplorer --run --port (optional) --host (optional)

The MSAexplorer app is an interactive visualization tool designed for exploring multiple sequence alignments (MSAs).

options:
  -h, --help   show this help message and exit
  --run        Start the MSAexplorer app
  --host ip    The address that the app should listen on. Defaults to 127.0.0.1
  --port port  The port that the app should listen on. Set to 0 to use a random port. Defaults to 8080.
  --version    show program's version number and exit  
  • :white_check_mark: The app runs solely in your browser. No need to install anything, just might take a few seconds to load.
  • :white_check_mark: Use the app offline (after loading it).
  • :white_check_mark: Analyse alignments on your smartphone or tablet.
  • :white_check_mark: Download alignment statistics (e.g. entropy, SNPs, coverage, consensus, ORFs and more).
  • :white_check_mark: Annotate the alignment by additionally reading in gb, gff or bed files.
  • :white_check_mark: Flexibility to customize plots and colors.
  • :white_check_mark: Easily export the plot as pdf.
  • :white_check_mark: Generate plots of the whole alignment as well as just parts of it.
  • :white_check_mark: Publication ready figures with just a few clicks.

Hosting MSAexplorer yourself

If you want to host MSAexplorer e.g. for your group, you can export the app as a static html with a few easy steps. However, in-app calculations with pyfamsa and pytrimal are currently not supported.

# install shinylive for exporting
pip install shinylive
git clone https://github.com/jonas-fuchs/MSAexplorer
cd MSAexplorer
shinylive export ./ site/  # you should now have a new 'site' folder with the app

Features of MSAexplorer as a python package (full documentation)

  • :white_check_mark: Access MSAexplorer as a python package
  • :white_check_mark: Seamlessly integrates with Biopython.
  • :white_check_mark: Maximum flexibility for the plotting and analysis features while retaining minimal syntax.
  • :white_check_mark: Integrates seamlessly with matplotlib.
  • :white_check_mark: Minimal requirements.
### Minimal analysis example ###

from msaexplorer import explore, export

# load the alignment
aln = explore.MSA('example_alignments/DNA.fasta')
print(aln.aln_type)  # print alignment type
print(aln.length)  # print alignment length

# adjust what you want to look at
aln.reference_id = 'AB032031.1 Borna disease virus 1 genomic RNA, complete genome'  # set a reference if needed
aln.zoom = (0, 1000)  # set a zoom range

# now print for example all snps in that zoom range compared to the reference id
snps = aln.get_snps(include_ambig=True)
print(snps)
# and then save to file
export.snps(snps, path='my_path/snps.vcf', format_type='vcf')

# see documentation for full usage
### Two minimal plotting examples ###

from msaexplorer import explore, draw
import matplotlib.pyplot as plt

# Example 1
draw.identity_alignment('example_alignments/DNA.fasta')
plt.show()

# Example 2
aln = explore.MSA('example_alignments/DNA.fasta')
# adjust zoom levels (for example to also plot sequence text)
aln.zoom = (0,60)
plt.figure(figsize=(10,12))  # adjust so the sequence text fits in your figure well
draw.identity_alignment(aln, show_identity_sequence=True)
plt.show()
### Extended plotting example  ####

import matplotlib.pyplot as plt
from msaexplorer import explore
from msaexplorer import draw

#  load alignment
aln = explore.MSA("example_alignments/DNA.fasta", reference_id=None, zoom_range=None)
# set reference to first sequence
aln.reference_id = list(aln.alignment.keys())[0]

fig, ax = plt.subplots(nrows=2, height_ratios=[0.2, 2], sharex=False)

draw.stat_plot(
    aln,
    ax=ax[0],
    stat_type="entropy",
    rolling_average=1,
    line_color="indigo"
)

draw.identity_alignment(
    aln,
    ax=ax[1],
    show_gaps=False,
    show_mask=True,
    show_mismatches=True,
    reference_color='lightsteelblue',
    color_scheme='purine_pyrimidine',
    show_seq_names=False,
    show_ambiguities=True,
    fancy_gaps=True,
    show_x_label=False,
    show_legend=True,
    bbox_to_anchor=(1,1.05)
)

plt.show()

Exampel gallery

Citing MSAexplorer

Coming soon...

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

msaexplorer-0.4.6.tar.gz (135.7 kB view details)

Uploaded Source

Built Distribution

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

msaexplorer-0.4.6-py3-none-any.whl (123.0 kB view details)

Uploaded Python 3

File details

Details for the file msaexplorer-0.4.6.tar.gz.

File metadata

  • Download URL: msaexplorer-0.4.6.tar.gz
  • Upload date:
  • Size: 135.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for msaexplorer-0.4.6.tar.gz
Algorithm Hash digest
SHA256 6bb2d1a1a830e42cc1755e669449197109cbb386565d0a9e60060cc75db93a7c
MD5 3cf5c722ea74722b46fd46f16f1a8824
BLAKE2b-256 f8cdde2f083fcc9c358aee84b9ad154930e0be4c0f839db2f3163588e2cc6f4b

See more details on using hashes here.

File details

Details for the file msaexplorer-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: msaexplorer-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 123.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for msaexplorer-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9d6043605f2155a1e893ee0591b99236317fc908efbee4a781f3f89d8b340a16
MD5 55697c990e2da69c8e4a1d9e51a5fe7d
BLAKE2b-256 340572170c33824865d9c9155f238450ea12e24acb59be40dce1e8855ce76a8b

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