Giter Club home page Giter Club logo

genomicmaps.jl's Introduction

GenomicMaps.jl

Julia package for visualising genomic data.

Installation

julia>]
pkg> add GenomicMaps

Usage

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

Example

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]
            end
            i += 1
        end
    end
end


# Colour scheme for COG categories:
cogcolours = Dict("B"=>RGB{Float64}(1.0,0.630714,0.576563),
     "M"=>RGB{Float64}(0.756869,0.916499,0.965176),
     "I"=>RGB{Float64}(0.187839,0.54561,0.252343),
     "X"=>RGB{Float64}(0.540006,0.493982,0.813567),
     "Y"=>RGB{Float64}(0.0973617,0.285282,0.5329),
     "Z"=>RGB{Float64}(0.0418427,0.156645,0.341597),
     "L"=>RGB{Float64}(0.426131,0.0441442,0.0465628),
     "O"=>RGB{Float64}(0.518954,0.802339,0.930272),
     "F"=>RGB{Float64}(0.587882,0.865532,0.51112),
     "Q"=>RGB{Float64}(0.0,0.225356,0.101282),
     "D"=>RGB{Float64}(0.862653,0.958477,0.981395),
     "V"=>RGB{Float64}(0.188382,0.529206,0.795898),
     "U"=>RGB{Float64}(0.277786,0.635283,0.863472),
     "E"=>RGB{Float64}(0.711814,0.932724,0.629136),
     "T"=>RGB{Float64}(0.394211,0.72627,0.90426),
     "H"=>RGB{Float64}(0.32729,0.673206,0.326717),
     "P"=>RGB{Float64}(0.0232916,0.395886,0.180144),
     "G"=>RGB{Float64}(0.459895,0.779462,0.41097),
     "N"=>RGB{Float64}(0.641543,0.865092,0.94902),
     "K"=>RGB{Float64}(0.825431,0.118066,0.106858),
     "C"=>RGB{Float64}(0.835916,0.980813,0.770886),
     "R"=>RGB{Float64}(0.807625,0.787968,0.949453),
     "W"=>RGB{Float64}(0.137797,0.411028,0.686187),
     "A"=>RGB{Float64}(1.0,0.808314,0.771835),
     "S"=>RGB{Float64}(0.236943,0.0166779,0.407047),
     "J"=>RGB{Float64}(1.0,0.389569,0.336934))


# First download annotations for E. coli:
download("ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/005/845/GCA_000005845.2_ASM584v2/GCA_000005845.2_ASM584v2_genomic.gbff.gz", "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, ""), "")))
drawgenome(chr;
    outfile = "ecoli.svg",
    colourmap = cogcolours,
    colourfunction = colourby_cog,
    annotate = true,
    nbreaks = 40)

Customisation

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("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nucleotide&id=1899346924&rettype=gb&retmode=text", "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)
end

### 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")

genomicmaps.jl's People

Contributors

kdyrhage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

genomicmaps.jl's Issues

Unable to add GenomicMaps

The example code begins with

using GenomicAnnotations
using GenomicMaps

which means that the two packages must first be installed. I am unable to install GenomicMaps on Julia 1.1.0 on Windows and Linux.

(v1.1) pkg> add GenomicMaps
ERROR: The following package names could not be resolved:
 * GenomicMaps (not found in project, manifest or registry)
Please specify by known `name=uuid`.

The error message is the same under both OS. Below is the version info for Windows.

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7 CPU         870  @ 2.93GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, nehalem)
Environment:
  JULIA_EDITOR = "C:\Users\aalexandersson\AppData\Local\atom\app-1.29.0\atom.exe" -a
  JULIA_NUM_THREADS = 4

installing in julia 1.10 issue

I tried to install the package in Julia 1.10,
but when I follow the example I get the following error:


Closest candidates are:
  genearrow(::Any, ::Any, ::Any, ::Any, ::Any)
   @ GenomicMaps ~/.julia/packages/GenomicMaps/UAicD/src/shapes.jl:6


Stacktrace:
 [1] striped(f::typeof(GenomicMaps.genearrow), p::Dict{Any, Any}, start::Luxor.Point, stop::Luxor.Point, colours::Vector{String}; kwargs::@Kwargs{})
   @ GenomicMaps ~/.julia/packages/GenomicMaps/UAicD/src/shapes.jl:165
 [2] striped
   @ ~/.julia/packages/GenomicMaps/UAicD/src/shapes.jl:154 [inlined]
 [3] drawgene(p::Dict{Any, Any}, gene::Gene; colours::Vector{String})
   @ GenomicMaps ~/.julia/packages/GenomicMaps/UAicD/src/drawstretch.jl:89
 [4] drawgenome(chr::GenomicAnnotations.Record{Gene}; kwargs::@Kwargs{outfile::String, colourmap::Dict{String, RGB{Float64}}, colourfunction::var"#31#32", annotate::Bool, nbreaks::Int64})
   @ GenomicMaps ~/.julia/packages/GenomicMaps/UAicD/src/drawstretch.jl:20
 [5] top-level scope
   @ In[14]:4

How can I solve this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.