Julia package for visualising genomic data
Author kdyrhage
13 Stars
Updated Last
2 Years Ago
Started In
October 2018


Julia package for visualising genomic data.


pkg> add GenomicMaps


There are currently three plotting functions: drawgenome (see example below), drawplasmid (for small circular plasmids), and compareregions for showing synteny and sequence similarity between genomes or regions.

Genome maps


Hover over a gene to see annotations.

Example map

using GenomicAnnotations
using GenomicMaps

# You can add any kind of annotation that you want to display.
# Here, I add COG annotation:
function addcogs!(chr, filename)
    cogs = split.(readlines(filename), Ref('\t'))
    i = 1
    for gene in @genes(chr, :feature == "CDS")
        if gene.locus_tag == cogs[i][1]
            if occursin(r"\w", cogs[i][2])
                gene.cog = cogs[i][2]
            i += 1

# Colour scheme for COG categories:
cogcolours = Dict("B"=>RGB{Float64}(1.0,0.630714,0.576563),

# First download annotations for E. coli:
download("", "ecoli.gbk.gz")

# Then read the annotations and add COGs:
chr = readgbk("ecoli.gbk.gz")[1]
addcogs!(chr, "ecoli_cogs.tsv")

# The output can be customised, see src/initialise.jl for all options. Here I
# provide a function that will be run on each gene to determine its colour:
colourby_cog = g -> unique(String.(split(get(g, :cog, ""), "")))
    outfile = "ecoli.svg",
    colourmap = cogcolours,
    colourfunction = colourby_cog,
    annotate = true,
    nbreaks = 40)


Some keywords that can be given to drawgenome to customise the output are:

  • genetextfunction: determines the text shown above each gene. Can be either a Function that is executed for each gene, or a Symbol, in which case it defaults to g -> get(g, genetextfunction, "").
  • colourfunction: a function that is executed for each gene to determine how to colour it. Currently only categorical colouring is supported, so continuous data has to be binned.
  • colourmap: a Dict mapping categories => colours. When using categorical data to colour genes, it can be left empty, but if continuous data (say, expression levels) are used it has to be set manually.
  • defaultcolour: the default colour that is used for genes that do not have a specified colour in colourmap.
  • nbreaks: an Int determining how many lines will be used to display the genome).
  • drawingsize: determines the size of the output. Can be a String such as "A4", "A0landscape", "1000x1000", or a Tuple (e.g. (1000, 1000)).
  • legend: can be :categorical, :continuous, or :none. ... and more (see src/initialise.jl)

Plasmid maps

Example plasmid

using GenomicAnnotations

download("", "pKUNFF306.gbk")
chr = readgbk("pKUNFF306.gbk")[1]

### Create an array containing annotations
annotations = [get(gene, :gene, gene.product) for gene in @genes(chr, CDS)]
replace!(annotations, "hypothetical protein" => "")

### Create a Dict with Genes as keys and colors as values
cdict = Dict()
for gene in @genes(chr, CDS, :product != "hypothetical protein")
    cdict[gene.locus_tag] = RGBA(.5,.5,.5,.5)

### Create a Dict with gene cluster annotations
genegroups = Dict(14:17 => (text = "Lantibiotic resistance", placement = :inner),
                  10:13 => (text = "Lantibiotic biogenesis and transport", placement = :outer))

drawplasmid(chr; outfile = "pKUNFF306.png",
                 drawingsize = (1100, 1000),
                 annotations = annotations,
                 colors = cdict,
                 genegroups = genegroups,
                 title = "pKUNFF306")

Used By Packages

No packages found.