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
- Better error handling
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pykegg-0.1.6.tar.gz.
File metadata
- Download URL: pykegg-0.1.6.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d70be0dec36317a014d932ae727a88c56f823dd00dc3db8133a89cd45d586bc
|
|
| MD5 |
b69f7bdfc1676a0dba887d0887c4e3c0
|
|
| BLAKE2b-256 |
ec774c47e39eb85d03a49d2d04f68230304fc56d483747029cd4d1d088a08a81
|
File details
Details for the file pykegg-0.1.6-py3-none-any.whl.
File metadata
- Download URL: pykegg-0.1.6-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39bac4e03ba371897cfa821f193a289982494d69cfc3d12b4eab746b4b01d490
|
|
| MD5 |
85953cb363b22e0adc6cda958147acc8
|
|
| BLAKE2b-256 |
1634569d2fa18ad8c8ee4c0fa305be3a04c077b8043a95c66663dc7d6b773613
|