Git Product home page Git Product logo

gene-loci-comparison's Introduction

Gene Loci Comparison

Create fancy (bokeh) gene locus plots from GenBank files!

This repository extends the functionality of the excellent DnaFeaturesViewer

Setup

pip install git+https://github.com/MrTomRod/gene_loci_comparison.git

Examples

Bokeh

This library can also create interactive html/javascript-based plots. Open these files in your browser:

Single locus, specify colors

from gene_loci_comparison import Locus, Loci
import matplotlib
import matplotlib.pyplot as plt

matplotlib.rcParams['font.family'] = "PT Sans Narrow"

locus = Locus(gbk_file='/path/to/file.gbk', locus_tag='FAM3257_001019')

locus_to_color = dict(
    FAM3257_001014='#1271c3',
    FAM3257_001015='#3171c3',
    FAM3257_001016='#5d71c3',
    FAM3257_001017='#9371c3',
    FAM3257_001018='#b171c3',
    FAM3257_001019='#cb71c3',
    FAM3257_001020='#ea71c3',
    FAM3257_001021='#fd71c3',
    # FAM3257_001021='#fd71c3'  # last gene: white (default color)
)

locus.colorize(locus_to_color)

ax, _ = locus.plot(figure_width=12)

plt.show()

Multiple loci

from gene_loci_comparison import Loci
import matplotlib

matplotlib.rcParams['font.family'] = "PT Sans Narrow"

# Each locus is made from a gbk-file, a gene identifier and a title (optional)
loci_of_interest = [
    dict(gbk='/path/to/file1.gbk', gene='FAM3257_00934', title='title1'),
    dict(gbk='/path/to/file2.gbk', gene='FAM3257_000019', title='title2'),
    dict(gbk='/path/to/file3.gbk', gene='FAM3257_001020', title='title3'),
]

# Highlight selected genes
locus_to_color_dict = {locus['gene']: '#1984ff' for locus in loci_of_interest}

# Generate loci object
loci = Loci.generate(
    loci_of_interest,
    locus_to_color_dict=locus_to_color_dict
)

plot = loci.plot(auto_reverse=False)

plot.show()

Multiple loci, autoreversed

To automatically reverse loci based on the direction of the selected genes. Simply set auto_reverse to True.

Multiple loci, with GC content

Change plotting method from plot_multiple to plot_multiple_gc.

plot = loci.plot_gc(
    auto_reverse=True,
    window_bp=200
)

gene-loci-comparison's People

Contributors

mrtomrod avatar

Stargazers

 avatar

Watchers

 avatar

gene-loci-comparison's Issues

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.