All Projects → pybel → pybel

pybel / pybel

Licence: MIT license
🌶️ An ecosystem in Python for working with the Biological Expression Language (BEL)

Programming Languages

python
139335 projects - #7 most used programming language
Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to pybel

doctoral-thesis
📖 Generation and Applications of Knowledge Graphs in Systems and Networks Biology
Stars: ✭ 26 (-73.74%)
Mutual labels:  systems-biology, biological-expression-language, networks-biology
TIGER
Python toolbox to evaluate graph vulnerability and robustness (CIKM 2021)
Stars: ✭ 103 (+4.04%)
Mutual labels:  networks
Erdos.jl
A library for graph analysis written Julia.
Stars: ✭ 37 (-62.63%)
Mutual labels:  networks
bio2bel
A Python framework for integrating biological databases and structured data sources in Biological Expression Language (BEL)
Stars: ✭ 16 (-83.84%)
Mutual labels:  biological-expression-language
nxontology
NetworkX-based Python library for representing ontologies
Stars: ✭ 45 (-54.55%)
Mutual labels:  networks
pyobo
📛 A Python package for using ontologies, terminologies, and biomedical nomenclatures
Stars: ✭ 32 (-67.68%)
Mutual labels:  bioregistry
MRFcov
Markov random fields with covariates
Stars: ✭ 21 (-78.79%)
Mutual labels:  networks
SBMLToolkit.jl
SBML differential equation and chemical reaction model (Gillespie simulations) for Julia's SciML ModelingToolkit
Stars: ✭ 25 (-74.75%)
Mutual labels:  systems-biology
newt
A web application to visualize and edit pathway models
Stars: ✭ 46 (-53.54%)
Mutual labels:  systems-biology
cobrame
A COBRApy extension for genome-scale models of metabolism and expression (ME-models)
Stars: ✭ 30 (-69.7%)
Mutual labels:  systems-biology
graphml-tutorials
Tutorials for Machine Learning on Graphs
Stars: ✭ 125 (+26.26%)
Mutual labels:  networks
chise.js
A web application to visualize and edit the pathway models represented by SBGN Process Description Notation
Stars: ✭ 15 (-84.85%)
Mutual labels:  systems-biology
EscherConverter
A standalone program that reads files created with the graphical network editor Escher and converts them to files in community standard formats.
Stars: ✭ 14 (-85.86%)
Mutual labels:  systems-biology
workshop omics integration
Workshop in omics integration and systems biology
Stars: ✭ 32 (-67.68%)
Mutual labels:  systems-biology
cytoscape-sbgn-stylesheet
View biological networks via Cytoscape.js and sbgn-ml
Stars: ✭ 47 (-52.53%)
Mutual labels:  networks
simon-frontend
💹 SIMON is powerful, flexible, open-source and easy to use machine learning knowledge discovery platform 💻
Stars: ✭ 114 (+15.15%)
Mutual labels:  systems-biology
ecell4 base
An integrated software environment for multi-algorithm, multi-timescale, multi-spatial-representation simulation of various cellular phenomena
Stars: ✭ 61 (-38.38%)
Mutual labels:  systems-biology
bioregistry
📮 An integrative registry of biological databases, ontologies, and nomenclatures.
Stars: ✭ 43 (-56.57%)
Mutual labels:  bioregistry
colomoto-docker
The CoLoMoTo Interactive Notebook: Accessible and Reproducible Computational Analyses for Qualitative Biological Networks
Stars: ✭ 15 (-84.85%)
Mutual labels:  systems-biology
biomappings
🗺️ Community curated and predicted equivalences and related mappings between named biological entities that are not available from primary sources.
Stars: ✭ 24 (-75.76%)
Mutual labels:  bioregistry

PyBEL zenodo Build Status Development Coverage Status Development Documentation Status Powered by the Bioregistry Code style: black

PyBEL is a pure Python package for parsing and handling biological networks encoded in the Biological Expression Language (BEL).

It facilitates data interchange between data formats like NetworkX, Node-Link JSON, JGIF, CSV, SIF, Cytoscape, CX, INDRA, and GraphDati; database systems like SQL and Neo4J; and web services like NDEx, BioDati Studio, and BEL Commons. It also provides exports for analytical tools like HiPathia, Drug2ways and SPIA; machine learning tools like PyKEEN and OpenBioLink; and others.

Its companion package, PyBEL Tools, contains a suite of functions and pipelines for analyzing the resulting biological networks.

We realize that we have a name conflict with the python wrapper for the cheminformatics package, OpenBabel. If you're looking for their python wrapper, see here.

Citation

If you find PyBEL useful for your work, please consider citing:

[1]Hoyt, C. T., et al. (2017). PyBEL: a Computational Framework for Biological Expression Language. Bioinformatics, 34(December), 1–2.

Installation Current version on PyPI Stable Supported Python Versions MIT License

PyBEL can be installed easily from PyPI with the following code in your favorite shell:

$ pip install pybel

or from the latest code on GitHub with:

$ pip install git+https://github.com/pybel/pybel.git

See the installation documentation for more advanced instructions. Also, check the change log at CHANGELOG.rst.

Getting Started

More examples can be found in the documentation and in the PyBEL Notebooks repository.

Compiling and Saving a BEL Graph

This example illustrates how the a BEL document from the Human Brain Pharmacome project can be loaded and compiled directly from GitHub.

>>> import pybel
>>> url = 'https://raw.githubusercontent.com/pharmacome/conib/master/hbp_knowledge/proteostasis/kim2013.bel'
>>> graph = pybel.from_bel_script_url(url)

Other functions for loading BEL content from many formats can be found in the I/O documentation. Note that PyBEL can handle BEL 1.0 and BEL 2.0+ simultaneously.

After you have a BEL graph, there are numerous ways to save it. The pybel.dump function knows how to output it in many formats based on the file extension you give. For all of the possibilities, check the I/O documentation.

>>> import pybel
>>> graph = ...
>>> # write as BEL
>>> pybel.dump(graph, 'my_graph.bel')
>>> # write as Node-Link JSON for network viewers like D3
>>> pybel.dump(graph, 'my_graph.bel.nodelink.json')
>>> # write as GraphDati JSON for BioDati
>>> pybel.dump(graph, 'my_graph.bel.graphdati.json')
>>> # write as CX JSON for NDEx
>>> pybel.dump(graph, 'my_graph.bel.cx.json')
>>> # write as INDRA JSON for INDRA
>>> pybel.dump(graph, 'my_graph.indra.json')

Summarizing the Contents of the Graph

The BELGraph object has several "dispatches" which are properties that organize its various functionalities. One is the BELGraph.summarize dispatch, which allows for printing summaries to the console.

These examples will use the RAS Model from EMMAA, so you'll have to be sure to pip install indra first. The graph can be acquired and summarized with BELGraph.summarize.statistics() as in:

>>> import pybel
>>> graph = pybel.from_emmaa('rasmodel', date='2020-05-29-17-31-58')  # Needs
>>> graph.summarize.statistics()
---------------------  -------------------
Name                   rasmodel
Version                2020-05-29-17-31-58
Number of Nodes        126
Number of Namespaces   5
Number of Edges        206
Number of Annotations  4
Number of Citations    1
Number of Authors      0
Network Density        1.31E-02
Number of Components   1
Number of Warnings     0
---------------------  -------------------

The number of nodes of each type can be summarized with BELGraph.summarize.nodes() as in:

>>> graph.summarize.nodes(examples=False)
Type (3)        Count
------------  -------
Protein            97
Complex            27
Abundance           2

The number of nodes with each namespace can be summarized with BELGraph.summarize.namespaces() as in:

>>> graph.summarize.namespaces(examples=False)
Namespace (4)      Count
---------------  -------
HGNC                  94
FPLX                   3
CHEBI                  1
TEXT                   1

The edges can be summarized with BELGraph.summarize.edges() as in:

>>> graph.summarize.edges(examples=False)
Edge Type (12)                       Count
---------------------------------  -------
Protein increases Protein               64
Protein hasVariant Protein              48
Protein partOf Complex                  47
Complex increases Protein               20
Protein decreases Protein                9
Complex directlyIncreases Protein        8
Protein increases Complex                3
Abundance partOf Complex                 3
Protein increases Abundance              1
Complex partOf Complex                   1
Protein decreases Abundance              1
Abundance decreases Protein              1

Grounding the Graph

Not all BEL graphs contain both the name and identifier for each entity. Some even use non-standard prefixes (also called namespaces in BEL). Usually, BEL graphs are validated against controlled vocabularies, so the following demo shows how to add the corresponding identifiers to all nodes.

from urllib.request import urlretrieve

url = 'https://github.com/cthoyt/selventa-knowledge/blob/master/selventa_knowledge/large_corpus.bel.nodelink.json.gz'
urlretrieve(url, 'large_corpus.bel.nodelink.json.gz')

import pybel
graph = pybel.load('large_corpus.bel.nodelink.json.gz')

import pybel.grounding
grounded_graph = pybel.grounding.ground(graph)

Note: you have to install pyobo for this to work and be running Python 3.7+.

Displaying a BEL Graph in Jupyter

After installing jinja2 and ipython, BEL graphs can be displayed in Jupyter notebooks.

>>> from pybel.examples import sialic_acid_graph
>>> from pybel.io.jupyter import to_jupyter
>>> to_jupyter(sialic_acid_graph)

Using the Parser

If you don't want to use the pybel.BELGraph data structure and just want to turn BEL statements into JSON for your own purposes, you can directly use the pybel.parse() function.

>>> import pybel
>>> pybel.parse('p(hgnc:4617 ! GSK3B) regulates p(hgnc:6893 ! MAPT)')
{'source': {'function': 'Protein', 'concept': {'namespace': 'hgnc', 'identifier': '4617', 'name': 'GSK3B'}}, 'relation': 'regulates', 'target': {'function': 'Protein', 'concept': {'namespace': 'hgnc', 'identifier': '6893', 'name': 'MAPT'}}}

This functionality can also be exposed through a Flask-based web application with python -m pybel.apps.parser after installing flask with pip install flask. Note that the first run requires about a ~2 second delay to generate the parser, after which each parse is very fast.

Using the CLI

PyBEL also installs a command line interface with the command pybel for simple utilities such as data conversion. In this example, a BEL document is compiled then exported to GraphML for viewing in Cytoscape.

$ pybel compile ~/Desktop/example.bel
$ pybel serialize ~/Desktop/example.bel --graphml ~/Desktop/example.graphml

In Cytoscape, open with Import > Network > From File.

Contributing

Contributions, whether filing an issue, making a pull request, or forking, are appreciated. See CONTRIBUTING.rst for more information on getting involved.

Acknowledgements

Support

The development of PyBEL has been supported by several projects/organizations (in alphabetical order):

Funding

Logo

The PyBEL logo was designed by Scott Colby.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].