Skip to main content

Visualizing and analyzing KEGG information in Python

Project description

pykegg

Analyze and visualize KEGG information using network approach.

Using biopython, igraph and plotnine, parse the KGML into igraph and easily plot the relevant information contained in KEGG Pathway in Python environment.

import requests_cache
import numpy as np
from PIL import Image
import pykegg
import matplotlib as mpl

## Be sure to cache all the downloaded files to avoid recursive querying
requests_cache.install_cache('pykegg_cache')
g = pykegg.KGML_graph(pid="hsa03460")

## Export as igraph
gra = g.get_graph()
print(gra)

## Overlay to raw image
nds = g.get_nodes()
nds = nds[nds.original_type=="gene"]
nds["lfc"] = np.arange(-2,2,0.01)[0:nds.shape[0]]
cmap_grad = mpl.colors.LinearSegmentedColormap.from_list("cmap_grad", ["yellow","green"])
norm = mpl.colors.Normalize(vmin=min(nds.lfc), vmax=max(nds.lfc))
nds["color"] = [
        mpl.colors.to_hex(cmap_grad(norm(x))) if x is not None else None
        for x in nds.lfc
    ]
Image.fromarray(pykegg.overlay_opencv_image(nds, pid="hsa03460"))

## Plot using plotnine
# options.figure_size = (7,5)
pykegg.plot_kegg_pathway_plotnine(g, node_x_nudge=25, label_size=5, show_label="gene")

Documentation

https://pykegg.readthedocs.io/

TODO

  • The function for converting identifiers (especially for ENTREZID <-> SYMBOL) without connection to servers, like using genomic-features.
  • Parallel edge support by nudging x and y position

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykegg-0.1.2.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pykegg-0.1.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file pykegg-0.1.2.tar.gz.

File metadata

  • Download URL: pykegg-0.1.2.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for pykegg-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b29fb4ef97f09e7b01b4e4c9f052c86f4f744fd0c71be8574dc67b5f29899e8d
MD5 833b8108f5ed2c5d77529ec1d049760f
BLAKE2b-256 7b1a0364f0cc87ff56b6711e96db1c628595d9135bb8720a1f7eb0482698de45

See more details on using hashes here.

File details

Details for the file pykegg-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pykegg-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for pykegg-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8a69ee1b8c530be6b5d755479b86d05460da24012e4e9dd5797d211cb0aa757
MD5 591f66dfe6797a6e99e88f196adf92fe
BLAKE2b-256 43493e34613b9b27a2c866791bb7887c2a54d7d12feaeb8b37d1e5791902c711

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page