Skip to main content

Easy sequence alignment plots

Project description


A python tool to plot BAM or CRAM sequence reads.


install cairo if not already installed:

# macOS via conda, or via homebrew (choose one, then set the library path)
conda install cairo pkgconfig
brew install cairo pkg-config

Install shabam:

pip install shabam

The dream

from shabam import seqplot
seqplot('example.bam', chrom='1', start=30243, end=30321,
    fastafile='reference.fasta', out='plot.svg')


Plotting options

  • shade reads by strand with by_strand=True
  • plot multiple sequence files together with a list of paths e.g. ['child.bam', 'mom.bam', 'dad.bam']
  • export PDF, PNG, SVG or PS formatted plots with matching filename extensions

Command line version

shabam \
  --seqfiles tests/data/example.bam \
  --chrom 1 \
  --start 30243 \
  --end 30321 \
  --fastafile tests/data/reference.fasta \
  --out plot.svg

Further improvements to the dream

  • <input type="checkbox" disabled="" /> Use consensus sequence when we don't provide a reference sequence
  • <input type="checkbox" disabled="" /> Allow custom colors
  • <input type="checkbox" disabled="" /> Compute proportion of variants at any site
  • <input type="checkbox" disabled="" /> Plot read depth
  • <input type="checkbox" disabled="" /> At positions with proportion of variants > threshold, reflect proportion with base colors
  • <input type="checkbox" disabled="" /> Option to scale plotted base size, currently at 10 pixels per base
  • <input type="checkbox" disabled="" /> Optionally shade plots deepVariant style:
    • red channel: nucleotide
    • blue channel: read strand
    • green channel: base quality
    • alpha: base supports ref or alt
  • <input type="checkbox" disabled="" /> Flatten vertical plotting in high depth sequence data
  • <input type="checkbox" disabled="" /> Down-sample reads for extremely high depth sequence data (>1000X)


Initial cigar parsing code lifted with permission from pybamview.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for shabam, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size shabam-1.0.0.tar.gz (10.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page