Enrichment analysis and visualisation toolkit for KEGG pathways
Project description
keggtools
Library for KEGG pathway enrichment analysis.
Installation
keggtools
only supports python
version greater than or equal 3.6
.
Dependencies
graphviz
python
dependencies
requests
tqdm
pydot
scipy
Installation of python
dependencies:
python3 -m pip install requests tqdm pydot scipy
Installation keggtools
package using pip
:
python3 -m pip install keggtools
To get a more detailed list of install options, please read the INSTALL.md
API
Download and Parsing
from keggtools.resolver import KEGGPathwayResolver
from keggtools.const import IMMUNE_SYSTEM_PATHWAYS
ORGANISM_ID = "hsa"
resolver = KEGGPathwayResolver(org=ORGANISM_ID)
# Select first immune system pathway as example
pathway_id = list(IMMUNE_SYSTEM_PATHWAYS.keys())[1]
# Resolve pathway
pathway = resolver.get_pathway(code=pathway_id)
print(pathway)
Enrichment and Testing
from keggtools.analysis import KEGGPathwayAnalysis
# Init analysis with organism code
analysis = KEGGPathwayAnalysis(org=ORGANISM_ID)
# Study genes as list of entrez gene id's
study_genes = []
analysis.run_analysis(gene_list=study_genes)
# to_dataframe method requires pandas installation
result = analysis.to_dataframe()
print(result.head())
Rendering
import pydot
from keggtools.render import KEGGPathwayRenderer
# Load and parse pathway
pathway = KEGGPathwayResolver(org=ORGANISM_ID).get_pathway(pathway_id)
renderer = KEGGPathwayRenderer(kegg_pathway=pathway)
# Render to dot graph
dot_string = renderer.raw_render()
# Export dot graph as png
graphs = pydot.graph_from_dot_data(dot_string)[0]
graph.write_png("./output.png")
Development
Dev installation
Fast install with virtualenv
for development.
python3 -m virtualenv venv
source ./venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
Testing
Run unittest to verify keggtools
installation
# Install pytest
python3 -m pip install pytest
# Run unittest for package
pytest -p keggtools --show-capture=log
Alternatively, the Makefile
can be used:
make unittest
Static code analysis
Static code analysis using mypy
# Install mypy
python3 -m pip install mypy
# Or install full development requirements
pip install -r dev_requirements.txt
Run static code analysis with mypy
mypy setup.py
python3 setup.py install
mypy -p keggtools
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
keggtools-0.5.0.tar.gz
(17.4 kB
view hashes)
Built Distribution
keggtools-0.5.0-py3-none-any.whl
(20.8 kB
view hashes)
Close
Hashes for keggtools-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdaa3b322bc82ef4d1c1e2fedde121e7fb811eff1d66a5c039bee47d72244506 |
|
MD5 | 62d884f9c414e5e88a92d226361db1be |
|
BLAKE2b-256 | 9aedf58774f36749175539575bc9fa9534fea54ad934d42d376be966747d6e22 |