Welcome to Graphein’s documentation!

This package provides functionality for producing a number of types of graph-based representations of proteins. We provide compatibility with standard geometric deep learning library formats (currently: NetworkX nx.Graph, pytorch_geometric.data.Data and dgl.DGLGraph), as well as graph objects designed for ease of use with popular deep learning libraries.

The repository can be found at a-r-j/graphein

Note

This is an early-stage project and a lot more documentation and functionality is planned to be included. If you are a structural biologist or machine learning researcher in computational biology, my inbox is always open for suggestions and assistance!

Binder PyPI version supported python versions Docs DOI:10.1101/2020.07.15.204701 Project Status: Active – The project has reached a stable, usable state and is being actively developed. CodeFactor Quality Gate Status Bugs Maintainability Rating Reliability Rating License: MIT Code style: black


Documentation | Paper | Tutorials | Installation

Protein & Interactomic Graph Library

This package provides functionality for producing geometric representations of protein and RNA structures, and biological interaction networks. We provide compatibility with standard PyData formats, as well as graph objects designed for ease of use with popular deep learning libraries.

What’s New?

| 1.2.0 |Protein Graph Visualisation! | Open In Colab

Example usage

Graphein provides both a programmatic API and a command-line interface for constructing graphs.

CLI

Graphein configs can be specified as .yaml files to batch process graphs from the command line.

Docs

graphein -c config.yaml -p path/to/pdbs -o path/to/output

Creating a Protein Graph

Tutorial (Residue-level) | Tutorial (Atomic) | Docs | Open In Colab | Open In Colab | |

Creating a Protein Graph from the AlphaFold Protein Structure Database

| | | |—|—| | Tutorial | Docs | | Open In Colab|

Creating a Protein Mesh

from graphein.protein.config import ProteinMeshConfig
from graphein.protein.meshes import create_mesh

config = ProteinMeshConfig()
verts, faces, aux = create_mesh(pdb_code="3eiy", config=config)

Creating Molecular Graphs

Graphein can create molecular graphs from SMILES strings as well as .sdf, .mol2, and .pdb files.

Creating an RNA Graph

from graphein.rna.graphs import construct_rna_graph
# Build the graph from a dotbracket & optional sequence
rna = construct_rna_graph(dotbracket='..(((((..(((...)))..)))))...',
                          sequence='UUGGAGUACACAACCUGUACACUCUUUC')

Creating a Protein-Protein Interaction Graph

| | | |—|—| | Tutorial | Docs | | Open In Colab|

from graphein.ppi.config import PPIGraphConfig
from graphein.ppi.graphs import compute_ppi_graph
from graphein.ppi.edges import add_string_edges, add_biogrid_edges

config = PPIGraphConfig()
protein_list = ["CDC42", "CDK1", "KIF23", "PLK1", "RAC2", "RACGAP1", "RHOA", "RHOB"]

g = compute_ppi_graph(config=config,
                      protein_list=protein_list,
                      edge_construction_funcs=[add_string_edges, add_biogrid_edges]
                     )

Creating a Gene Regulatory Network Graph

| | | |—|—| |Tutorial | Docs | | Open In Colab |

from functools import partial

from graphein.grn.config import GRNGraphConfig
from graphein.grn.graphs import compute_grn_graph
from graphein.grn.edges import add_regnetwork_edges, add_trrust_edges

config = GRNGraphConfig()
gene_list = ["AATF", "MYC", "USF1", "SP1", "TP53", "DUSP1"]

g = compute_grn_graph(
    gene_list=gene_list,
    edge_construction_funcs=[
        partial(add_trrust_edges, trrust_filtering_funcs=config.trrust_config.filtering_functions),
        partial(add_regnetwork_edges, regnetwork_filtering_funcs=config.regnetwork_config.filtering_functions),
    ],
)

Installation

Pip

The simplest install is via pip. N.B. this does not install ML/DL libraries which are required for conversion to their data formats and for generating protein structure meshes with PyTorch 3D. Further details

pip install graphein # For base install
pip install graphein[extras] # For additional featurisation dependencies
pip install graphein[dev] # For dev dependencies
pip install graphein[all] # To get the lot

Conda environment

The dev environment includes GPU Builds (CUDA 11.1) for each of the deep learning libraries integrated into graphein.

git clone https://www.github.com/a-r-j/graphein
cd graphein
conda env create -f environment-dev.yml
uv sync --all-extras

A lighter install can be performed with:

git clone https://www.github.com/a-r-j/graphein
cd graphein
conda env create -f environment.yml
uv sync

Dockerfile

We provide two docker-compose files for CPU (docker-compose.cpu.yml) and GPU usage (docker-compose.yml) locally. For GPU usage please ensure that you have NVIDIA Container Toolkit installed. Ensure that you install the locally mounted volume after entering the container (uv sync --all-extras or pip install -e ".[dev,extras]"). This will also set up the dev environment locally.

To build (GPU) run:

docker-compose up -d --build # start the container
docker-compose down # stop the container

Citing Graphein

Please consider citing graphein if it proves useful in your work.

@inproceedings{jamasb2022graphein,
  title={Graphein - a Python Library for Geometric Deep Learning and Network Analysis on Biomolecular Structures and Interaction Networks},
  author={Arian Rokkum Jamasb and Ramon Vi{\~n}as Torn{\'e} and Eric J Ma and Yuanqi Du and Charles Harris and Kexin Huang and Dominic Hall and Pietro Lio and Tom Leon Blundell},
  booktitle={Advances in Neural Information Processing Systems},
  editor={Alice H. Oh and Alekh Agarwal and Danielle Belgrave and Kyunghyun Cho},
  year={2022},
  url={https://openreview.net/forum?id=9xRZlV6GfOX}
}

If Graphein proves useful to your work, please consider citing:

@inproceedings{jamasb2022graphein,
   title={Graphein - a Python Library for Geometric Deep Learning and Network Analysis on Biomolecular Structures and Interaction Networks},
   author={Arian Rokkum Jamasb and Ramon Vi{\~n}as Torn{\'e} and Eric J Ma and Yuanqi Du and Charles Harris and Kexin Huang and Dominic Hall and Pietro Lio and Tom Leon Blundell},
   booktitle={Advances in Neural Information Processing Systems},
   editor={Alice H. Oh and Alekh Agarwal and Danielle Belgrave and Kyunghyun Cho},
   year={2022},
   url={https://openreview.net/forum?id=9xRZlV6GfOX}
}

Indices and tables