Visualization : The Genome Diagram

Introduction

GenomeDiagram was designed for drawing whole genomes, either as linear diagrams (optionally broken up into fragments to fit better) or as circular wheel diagrams.

This module is easiest to use if you have your genome loaded as a SeqRecord object containing lots of SeqFeature objects - for example as loaded from a GenBank file (see Chapters 4 and 5).

The Bio.Graphics.GenomeDiagram module was added to Biopython 1.50

Top level of the GenomeDiagram:

  • horizontal axis: diagram object representing a sequence (or sequence region)

  • vertical axis: several tracks stacked vertically possible (on circular diagrams: radially stacked), would typically represent the same sequence region

Building up a diagram: top down approach

Top down approach: create a diagram object and then add tracks and features (code example: https://biopython-cn.readthedocs.io/zh_CN/latest/en/chr17.html)

  • load sequence

  • create empty diagram

  • add empty track

  • add empty featrue set

  • in your SeqRecord: take each gene SeqFeature object and use it to generate a feature on the diagram, for example coloring them blue and light blue

  • create output file

    • draw: creates the shapes using ReportLab objects

    • write: output possible in several file formats


Bottom up approach: create the different objects directly and then combine them

  • Create a FeatureSet for each separate set of features you want to display, and add Bio.SeqFeature objects to them.

  • Create a GraphSet for each graph you want to display, and add graph data to them.

  • Create a Track for each track you want on the diagram, and add GraphSets and FeatureSets to the tracks you require.

  • Create a Diagram, and add the Tracks to it.

  • Tell the Diagram to draw the image.

  • Write the image to a file.