Question: What Python Libraries Exist For Drawing Genes/Features/Intervals?
gravatar for Aaronquinlan
8.7 years ago by
United States
Aaronquinlan11k wrote:

I am working on new software for exploring genetic variation and genome annotations. One feature I would like to add is the ability to plot features (gene's, SNPs, SVs, etc.) in a given genomic region. What libraries are you aware of for producing "plots" or images like this in Python. Essentially, I am looking for something similar to Perl's Bio::Graphics module.

So far, I've seen that GenomeTools has a Python interface, but I am looking for possible alternatives.

python api visualization • 10k views
ADD COMMENTlink modified 3.3 years ago by Biostar ♦♦ 20 • written 8.7 years ago by Aaronquinlan11k
gravatar for Giovanni M Dall'Olio
8.7 years ago by
London, UK
Giovanni M Dall'Olio27k wrote:

Have a look at BioGraphy by Andrea Pierleoni. It is probably going to be integrated into BioPython soon.

Example of BioGraphy output (from the tutorial):

alt text

Another alternative is GenomeDiagram. I can not reach the page linked in the article now, but this library should be included in the newer versions of BioPython. You can see some examples in the BioPython cookbook, chapter 15.

Example of GenomeDiagram output:

alt text

ADD COMMENTlink modified 8.7 years ago • written 8.7 years ago by Giovanni M Dall'Olio27k

These look promising, thanks.

ADD REPLYlink written 8.7 years ago by Aaronquinlan11k

I have tryed to use BioGraphy and got it via:

git clone git://

After the two steps python build and python install, I tested the tutorial code from

from biograpy import Panel, tracks, features
panel=Panel(fig_width=900, padding = 25)#initialize a drawer, and add some padding
test_track = tracks.BaseTrack(features.Simple(name = 'feat1', start = 100, end = 356, ),
                              features.Simple(name = 'feat2', start = 30, end = 856, ),
                              features.Simple(name = 'feat3', start = 400, end = 700, ),
                              sort_by = 'None',)

However, after this I got the following error message by using the ipython notebook (python 2.7):

AttributeError                            Traceback (most recent call last)
<ipython-input-1-050f14eab25c> in <module>()
      4                               features.Simple(name = 'feat2', start = 30, end = 856, ),
      5                               features.Simple(name = 'feat3', start = 400, end = 700, ),
----> 6                               sort_by = 'None',)
      7 panel.add_track(test_track)

/home/linux/anaconda2/lib/python2.7/site-packages/biograpy-1.0b0dev_r0-py2.7.egg/biograpy/tracks.pyc in __init__(self, *args, **kwargs)
    151         self.norm = kwargs.get('norm', None)# normalizing function, if None build one. could be any function taking a value an returning a float between 0 and 1
    152         if not self.norm:
--> 153             self.norm = colors.normalize(vmin = self.min_score, vmax = self.max_score)

AttributeError: 'module' object has no attribute 'normalize'

Does somebody know how to solve this problem?


ADD REPLYlink modified 7 months ago by RamRS28k • written 4.3 years ago by jochenfra0
gravatar for Michael Schubert
8.7 years ago by
Cambridge, UK
Michael Schubert7.0k wrote:

BioPython can now do diagrams as well. The picture below is for restriction analysis, but you get the idea.

alt text

ADD COMMENTlink written 8.7 years ago by Michael Schubert7.0k

The link is outdated. It should be Chapter 17 Graphics including GenomeDiagram

ADD REPLYlink written 3.3 years ago by sbliven30
gravatar for brentp
8.7 years ago by
Salt Lake City, UT
brentp23k wrote:

I haven't tried these, but also check out:

  1. willow by Titus brown--I think that's tied to pygr somehow
  2. GenomeViewer which uses Wx for rendering.
ADD COMMENTlink written 8.7 years ago by brentp23k
gravatar for bw.
6.3 years ago by
San Francisco
bw.150 wrote:

Also, there is

ADD COMMENTlink modified 7 months ago by RamRS28k • written 6.3 years ago by bw.150
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1356 users visited in the last hour