gene-loci-comparison


Namegene-loci-comparison JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/MrTomRod/gene_loci_comparison
SummaryCreate fancy (bokeh) gene locus plots from GenBank files
upload_time2024-04-29 10:53:40
maintainerNone
docs_urlNone
authorThomas Roder
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Gene Loci Comparison

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

This repository extends the functionality of the excellent [DnaFeaturesViewer](https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/)

## Setup

```shell
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](tests/output/locus/test_single_locus_pgap.html)
- [multiple loci with synchronized panning](tests/output/loci/test_multiple_bokeh.html)

### Single locus, specify colors

```python
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()
```

![](tests/output/locus/test_custom_colors.svg)

### Multiple loci

```python
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()
```

![](tests/output/loci/test_multiple.svg)

### Multiple loci, autoreversed

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

![](tests/output/loci/test_multiple_auto_reverse.svg)

### Multiple loci, with GC content

Change plotting method from `plot_multiple` to `plot_multiple_gc`.

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

```

![](tests/output/loci/test_multiple_auto_reverse_gc.svg)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MrTomRod/gene_loci_comparison",
    "name": "gene-loci-comparison",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Thomas Roder",
    "author_email": "roder.thomas@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/15/65/9c07b2512f48855b72a5a37ed872c3fee1dea2d350e86c8f172067857d7e/gene_loci_comparison-0.0.4.tar.gz",
    "platform": null,
    "description": "# Gene Loci Comparison\n\nCreate fancy (bokeh) gene locus plots from GenBank files!\n\nThis repository extends the functionality of the excellent [DnaFeaturesViewer](https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/)\n\n## Setup\n\n```shell\npip install git+https://github.com/MrTomRod/gene_loci_comparison.git\n```\n\n## Examples\n\n### Bokeh\n\nThis library can also create interactive html/javascript-based plots. Open these files in your browser:\n\n- [single locus](tests/output/locus/test_single_locus_pgap.html)\n- [multiple loci with synchronized panning](tests/output/loci/test_multiple_bokeh.html)\n\n### Single locus, specify colors\n\n```python\nfrom gene_loci_comparison import Locus, Loci\nimport matplotlib\nimport matplotlib.pyplot as plt\n\nmatplotlib.rcParams['font.family'] = \"PT Sans Narrow\"\n\nlocus = Locus(gbk_file='/path/to/file.gbk', locus_tag='FAM3257_001019')\n\nlocus_to_color = dict(\n    FAM3257_001014='#1271c3',\n    FAM3257_001015='#3171c3',\n    FAM3257_001016='#5d71c3',\n    FAM3257_001017='#9371c3',\n    FAM3257_001018='#b171c3',\n    FAM3257_001019='#cb71c3',\n    FAM3257_001020='#ea71c3',\n    FAM3257_001021='#fd71c3',\n    # FAM3257_001021='#fd71c3'  # last gene: white (default color)\n)\n\nlocus.colorize(locus_to_color)\n\nax, _ = locus.plot(figure_width=12)\n\nplt.show()\n```\n\n![](tests/output/locus/test_custom_colors.svg)\n\n### Multiple loci\n\n```python\nfrom gene_loci_comparison import Loci\nimport matplotlib\n\nmatplotlib.rcParams['font.family'] = \"PT Sans Narrow\"\n\n# Each locus is made from a gbk-file, a gene identifier and a title (optional)\nloci_of_interest = [\n    dict(gbk='/path/to/file1.gbk', gene='FAM3257_00934', title='title1'),\n    dict(gbk='/path/to/file2.gbk', gene='FAM3257_000019', title='title2'),\n    dict(gbk='/path/to/file3.gbk', gene='FAM3257_001020', title='title3'),\n]\n\n# Highlight selected genes\nlocus_to_color_dict = {locus['gene']: '#1984ff' for locus in loci_of_interest}\n\n# Generate loci object\nloci = Loci.generate(\n    loci_of_interest,\n    locus_to_color_dict=locus_to_color_dict\n)\n\nplot = loci.plot(auto_reverse=False)\n\nplot.show()\n```\n\n![](tests/output/loci/test_multiple.svg)\n\n### Multiple loci, autoreversed\n\nTo automatically reverse loci based on the direction of the selected genes. Simply set `auto_reverse` to `True`.\n\n![](tests/output/loci/test_multiple_auto_reverse.svg)\n\n### Multiple loci, with GC content\n\nChange plotting method from `plot_multiple` to `plot_multiple_gc`.\n\n```python\nplot = loci.plot_gc(\n    auto_reverse=True,\n    window_bp=200\n)\n\n```\n\n![](tests/output/loci/test_multiple_auto_reverse_gc.svg)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Create fancy (bokeh) gene locus plots from GenBank files",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/MrTomRod/gene_loci_comparison"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15659c07b2512f48855b72a5a37ed872c3fee1dea2d350e86c8f172067857d7e",
                "md5": "f64fc735aa9c54393bdbe0434ac55e9e",
                "sha256": "b09c6d634c17a6e11f47e0f8db7515fecb64b9318ff8a343a29955971cfdcce1"
            },
            "downloads": -1,
            "filename": "gene_loci_comparison-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f64fc735aa9c54393bdbe0434ac55e9e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10469,
            "upload_time": "2024-04-29T10:53:40",
            "upload_time_iso_8601": "2024-04-29T10:53:40.464979Z",
            "url": "https://files.pythonhosted.org/packages/15/65/9c07b2512f48855b72a5a37ed872c3fee1dea2d350e86c8f172067857d7e/gene_loci_comparison-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 10:53:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MrTomRod",
    "github_project": "gene_loci_comparison",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "gene-loci-comparison"
}
        
Elapsed time: 1.35665s