Plot the GO hierarchy with goatools go_plot
March 12, 2026 ยท View on GitHub
- Plot six GO terms in a file (a different color for each) and their ancestors:
- Plot one GO term and its ancestors:
- Plot two GO terms and their ancestors:
- Plot two GO terms (a different color for each) and their ancestors:
Plot six GO terms (listed in a file) using different colors and their ancestors
The colorized GO terms use the colors from the lightbright color palette and an orange (#ffe5b4) from the favorite pink based oranges color palette.
The file, go_heartjogging6.txt, contains the GO terms and user-defined colors:
#fad2fa GO:0072359 # BP 643 D04 circulatory system development (magenta)
#d2fafa GO:0003007 # BP 197 D04 heart morphogenesis (blue)
#fafad2 GO:0035050 # BP 26 D05 embryonic heart tube development (yellow)
#ffe5b4 GO:0003304 # BP 0 D06 myocardial epithelial involution involved in heart jogging (orange)
#e6fad2 GO:0061371 # BP 11 D06 determination of heart left/right asymmetry (green)
#d2d2fa GO:0003146 # BP 6 D07 heart jogging (purple)
Six different-colored GO terms without relationships
The six GO IDs listed in go_heartjogging6.txt and their ancestors up to the root GO are plotted.
goatools go_plot --go_file=tests/data/go_plot/go_heartjogging6.txt -o heartjogging6_r0.png

Six different-colored GO terms with relationships
The -r argument causes relationships to be plotted.
goatools go_plot --go_file=tests/data/go_plot/go_heartjogging6.txt -r -o heartjogging6_r1.png

Plot one GO term and its ancestors
Plot one term and all ancestors using the 'is_a' attribute.
goatools go_plot GO:0003304

Plot one GO term and its ancestors (with relationships)
Plot one term and all ancestors using the 'is_a' attribute and all relationships (-r).
The 'part_of' relationships are represented by dashed magenta arrows.
goatools go_plot GO:0003304 -r

Plot two GO terms and their ancestors
Plot two terms and all ancestors using the 'is_a' attribute.
goatools go_plot GO:0003304 GO:0003146 -o heart_jogging.png

Plot two GO terms and their ancestors (with relationships)
Plot two terms and all ancestors using the 'is_a' attribute and all relationships (-r).
The 'part_of' relationships are represented by dashed magenta arrows.
goatools go_plot GO:0003304 GO:0003146 -r -o heart_jogging_r1.png

Plot two GO terms (listed in a file) using different colors and their ancestors
Plot two terms and all ancestors using the 'is_a' attribute. The heart jogging GO term, GO:0003146, is colored in ice.
The file, go_file1.txt, contains the GO terms and user-defined colors:
GO:0003304
GO:0003146 #d6fffa http://klaash.github.io/xkcdcolorpicker/#ice
goatools go_plot --go_file=tests/data/go_plot/go_file1.txt -o heart_jogging_ice_gofile1.png

Plot two GO terms using different colors and their ancestors
Plot two terms and all ancestors using the 'is_a' attribute.
The heart jogging GO term, GO:0003146, is colored in ice.
goatools go_plot GO:0003304 GO:0003146#d6fffa -o heart_jogging_ice.png

Plot two GO terms using different colors and their ancestors (with relationships)
Plot two terms ('heart jogging' (GO:0003146) colored in ice) and all ancestors using the 'is_a' attribute and all relationships (-r).
The 'part_of' relationships are represented by dashed magenta arrows.
goatools go_plot GO:0003304 GO:0003146#d6fffa -r -o heart_jogging_ice_r1.png

Chage orietation of plot output
With graphviz, it is possible to change the orientation of the graph output, which may be convenient for large graphs.
Options are TB, LR, BT and RL mirroring GraphViz
# top -> bottom (default)
goatools go_plot GO:0000010 -o orientation_TB.png --obo=tests/data/mini_obo.obo --rankdir=TB

# left -> right
goatools go_plot GO:0000010 -o orientation_LR.png --obo=tests/data/mini_obo.obo --rankdir=LR

Copyright (C) 2010-2018, DV Klopfenstein, Haibao Tang et al. All rights reserved.