Interactive Visualisation with Plotly#

Graphein provides several visualisation utilities for interacting with protein structure graphs.

Visualisation API Reference

Open In Colab

[1]:
# Install Graphein if necessary
# !pip install graphein

Creating graphs#

First, we’ll create two graphs to work with based on PDB: 3EIY: a simple_graph (\(C\alpha\) backbone with peptide bonds) and a complex_graph (\(C\alpha\) backbone with peptide bonds, hydrogen bonds and ionic interactions).

[2]:
from graphein.protein.graphs import construct_graph
from graphein.protein.config import ProteinGraphConfig
from graphein.protein.edges.distance import add_hydrogen_bond_interactions, add_ionic_interactions, add_peptide_bonds

# Create backbone graph
config = ProteinGraphConfig()
simple_graph = construct_graph(config, pdb_code="3eiy")

# Create backbone graph with additional interactions
edge_funcs = [add_hydrogen_bond_interactions, add_ionic_interactions, add_peptide_bonds]
config = ProteinGraphConfig(edge_construction_functions= edge_funcs)
complex_graph = construct_graph(config, pdb_code="3eiy")
DEBUG:graphein.protein.graphs:Deprotonating protein. This removes H atoms from the pdb_df dataframe
DEBUG:graphein.protein.graphs:Detected 174 total nodes
DEBUG:graphein.protein.features.nodes.amino_acid:Reading meiler embeddings from: /Users/arianjamasb/github/graphein/graphein/protein/features/nodes/meiler_embeddings.csv
174
DEBUG:graphein.protein.graphs:Deprotonating protein. This removes H atoms from the pdb_df dataframe
DEBUG:graphein.protein.graphs:Detected 174 total nodes
INFO:graphein.protein.edges.distance:Found 75 hbond interactions.
INFO:graphein.protein.edges.distance:Found 7 hbond interactions.
INFO:graphein.protein.edges.distance:Found 1308 ionic interactions.
174

Distance Matrix and Contact Map#

Distance matrices are a representation of protein structure. They take the form of an \(N \times N\) matrix, where \(N\) is, typically, the length of the sequence. The entries of the matrix correspond to the euclidean distance (in Å) between the residues. Distance matrices are also computable for atom-level graphs, though these are of course much larger.

Distance matrices and contact maps can be visualised with `plot_distance_matrix() <https://graphein.ai/modules/graphein.protein.html#graphein.protein.visualisation.plot_distance_matrix>`__

[3]:
from graphein.protein.visualisation import plot_distance_matrix

plot_distance_matrix(simple_graph)

One can construct a contact map by thresholding the distance matrix to some arbirary distance (10 Å in our example).

[4]:
contact_map = (simple_graph.graph["dist_mat"] > 10).astype(int) # Threshold distance matrix
plot_distance_matrix(g=simple_graph, dist_mat=contact_map) # Plot contact map

Distance Landscape#

We can also visualise the distance matrix as a landscape in 3D using `plot_distance_landscape() <https://graphein.ai/modules/graphein.protein.html#graphein.protein.visualisation.plot_distance_landscape>`__. In this plot, the distance is represented by both the colour and the height of the peaks.

[5]:
from graphein.protein.visualisation import plot_distance_landscape

plot_distance_landscape(simple_graph)