MetDraw: Automated mapping for genome-scale metabolic models

MetDraw creates visualizations of genome-scale, metabolic models. These "reaction maps" can be used to visualize high-throughput expression data using the companion program MetColor.

Table of Contents


MetDraw and MetColor are Python scripts. The software can be used as standalone programs (metdraw and metcolor), or as Python modules for integration with other software.

The current version of MetDraw (1.0.0) is available for download here.

MetDraw requires Python 2.7 (download) and Graphviz 2.28 (download).

Testing MetDraw

The MetDraw distribution includes a testing script to check the path settings, Python version, and Graphviz version on the system. To run the test script from the MetDraw "src" directory, type ~/metdraw/src$ python Platform information: Operating System: Darwin Operating Platform: Darwin-10.8.0-i386-64bit Python information: Version: 2.7.5 Path setup Looking for Looking for Graphviz Graphviz is installed. Checking Graphviz version: Your version [dot - graphviz version 2.28.0 (20110509.1545)] is compatible with MetDraw. MetDraw is installed properly.

Running MetDraw

MetDraw can be run from the command line with the command $ python

For help with the program, use the -h switch: $ python -h usage: metdraw [-h] [--version] [--count_mets] [-M MET_FILE] [--show] [-q Q] [--Ln LN] [-o OUTPUT] [-p PARAM] file Draw maps of metabolic reactions. positional arguments: file input reaction file optional arguments: -h, --help show this help message and exit --version show version --count_mets create a metabolite count file -M MET_FILE, --mets MET_FILE use a metabolite count file to set minors --show show model structure -q Q graphviz output suppression level --Ln LN graphviz iteration limit -o OUTPUT, --output OUTPUT output file format -p PARAM, --param PARAM layout parameters

Input: SBML file

MetDraw accepts an SBML file of a metabolic reconstruction as input. MetDraw requires:

Output formats

MetDraw can export any file format supported by Graphviz (a list is available here). However, only the SVG image format is compatible for MetColor; this is the default output.

Using metabolite count files

MetDraw classifies each metabolite as either "major" or "minor". Minor metabolites are those that appear in many reactions and should be re-drawn for each reaction (ATP, water, NADPH, H+, etc.). MetDraw will attempt to identify minor metabolites based on the metabolite connectivity counts; however, it is better if the user makes these designations.

MetDraw can export a list of reaction counts for each metabolite: $python --count_mets model.xml

This creates a file model.xml.mets with the following structure: N1 Met1 N2 Met2 N3 Met3 <snip>

Metabolite Met1 participates in N1 reactions, etc. To designate a metabolite as a minor, prefix the name with an asterisk *. N1 *Met1 N2 *Met2 N3 Met3 <snip> This designates Met1 and Met2 as minor metabolites.

After identifying the minors, a metabolite count file can be passed to MetDraw with the --mets switch. $ python model.xml --mets model.xml.mets


MetDraw uses several parameters to control the map drawing process.
COMPARTMENT_FONTSIZE128Font size for compartment labels.
SUBSYSTEM_FONTSIZE64Font size for subsystem labels.
CLUSTER_SUBSYSTEMSFalseIf True, draw and label each subsystem separately.
SUBSYSTEM_BORDER_STYLE'solid'Border style for clustered subsystems.
CLONE_LEVEL8Metabolites in a subsystem participating in more than CLONE_LEVEL reactions will be cloned.
LINK_CLONESFalseIf True, connect cloned metabolites with a line.
CLUSTER_MINORSFalseIf True, attempt to draw minor metabolites in a reaction close together.
SHOW_MINORSTrueIf True, draw minor metabolites for each reaction. If False, draw only major metabolites.
SHOW_EXCHANGESFalseIf True, draw transport and exchange reactions for each compartment.
MAX_MINORS1000Maximum number of minors that can be drawn for each reaction. If a reaction has more minors, all metabolite names will be listed, but only MAX_MINORS circles will be drawn.
COMPACTFalseIf True, attempt to draw reactions more compactly.
METABOLITE_LABEL_TRANSFORMlambda x: xPython function applied to each metabolite id to create the label id. The default transformation leaves the name unchanged.
REACTION_LABEL_TRANSFORMlambda x: xPython function applied to each metabolite id to create the label id. The default transformation leaves the name unchanged.
{'color'     : 'darkorange4',
 'style'     : 'filled',
 'fillcolor' : 'orange',
 'fontsize'  : 12,
 'width'     : 0.35,
 'fixedsize' : 'true',
 'shape'     : 'circle'}
Graphviz parameters for major metabolites.
{'color'     : 'darkorange4',
 'style'     : 'filled',
 'fillcolor' : 'orange',
 'fontsize'  : 10,
 'width'     : 0.2,
 'fixedsize' : 'true',
 'shape'     : 'circle'}
Graphviz parameters for minor metabolites.
{'color' : 'purple',
 'fontcolor' : 'grey',
 'fontsize' : 12,
 'penwidth' : 8}
Graphviz parameters for edges.
{'label' : '',
 'shape' : 'point',
 'width' : 0,
 'color' : 'transparent'}
Graphviz parameters for unseen nodes.

Parameters can be set using the --param switch. This argument accepts a string with a comma-separated list of parameter assignments. For example, to show exchange reactions and set MAX_MINORS to 12, use $ python model.xml --param 'SHOW_EXCHANGES=True, MAX_MINORS=12'

The parameter string is evaluated as Python code, so the following conventions apply:

Running MetColor

MetColor can be run from the command line with the command $ python

For help with the program, use the -h switch: $ python -h usage: metcolor [-h] [--version] [--header] mapfile datafile Color maps of metabolic reactions. positional arguments: mapfile input SVG map file datafile input CSV data file optional arguments: -h, --help show this help message and exit --version show_version --header datafile begins with column headings

The mapfile input to MetColor is an SVG map generated by MetDraw. MetDraw encodes the reaction ids into the id attribute for each path, so subsequent edits to the SVG file will not effect MetColor. The datafile is a comma separated value (CSV) file with the following structure: RxnID1 Data1 Data2 ... RxnID2 Data1 Data2 ... <snip>

Each row contains data for multiple conditions for a single reaction. MetColor will create a separate file for each column of data.


The test directory in the MetDraw distribution contains a sample genome-scale model of E. coli from Orth et al., 2011 (ecoli2011.xml), a metabolite counts file with minor metabolite assignments (ecoli2011.xml.mets), and the resulting map (ecoli2011.xml.svg). This map was generated with the following command: python ecoli2011.xml -M ecoli2011.xml.mets --show --Ln 5000 --output svg -p'CLUSTER_SUBSYSTEMS=True, METABOLITE_LABEL_TRANSFORM=lambda x: x[2:-2], REACTION_LABEL_TRANSFORM=lambda x: x[2:]'

Note for Windows users: if running the above command from the Windows command prompt, change the single quotes (') to double quotes (").

The reaction ids in the model were prefixed with 'R_', so the REACTION_LABEL_TRANSFORM option was used to remove these from the display. A similar transformation was used to remove the prefix and compartment suffix from the metabolite ids.

The file ecoli_deltaG.csv contains Gibbs free energy calculations for several reactions in the model. These were applied to the SVG map to create the file with the command python ecoli_deltaG.csv --header

Contact Us

Bug reports and requests can be created on the project's Bitbucket site.

Questions, comments, and suggestions can be sent to Paul Jensen.

MetDraw is maintained by the Computational Systems Biology Laboratory, Department of Biomedical Engineering, University of Virginia.