Plotting

Plot a Ligand Interaction Network — prolif.plotting.network

New in version 0.3.2.

class prolif.plotting.network.LigNetwork(df, lig_mol, match3D=True, kekulize=False, molsize=35, rotation=0, carbon=0.16)[source]

Creates a ligand interaction diagram

Parameters
  • df (pandas.DataFrame) – Dataframe with a 4-level index (ligand, protein, interaction, atom) and a weight column for values

  • lig_mol (rdkit.Chem.rdChem.Mol) – Ligand molecule

  • match3D (bool) – If True, generates 2D coordines that are constrained to fit the 3D conformation of the ligand as best as possible. Else, generate 2D coordinates from scratch

  • kekulize (bool) – Kekulize the ligand

  • molsize (int) – Multiply the coordinates by this number to create a bigger and more readable depiction

  • rotation (int) – Rotate the structure on the XY plane

  • carbon (float) – Size of the carbon atom dots on the depiction. Use 0 to hide the carbon dots

COLORS

Dictionnary of colors used in the diagram. Subdivided in several dictionaries:

  • “interactions”: mapping between interactions types and colors

  • “atoms”: mapping between atom symbol and colors

  • “residues”: mapping between residues types and colors

Type

dict

RESIDUE_TYPES

Mapping between residue names (3 letter code) and types. The types are then used to define how each residue should be colored.

Type

dict

Notes

You can customize the diagram by tweaking LigNetwork.COLORS and LigNetwork.RESIDUE_TYPES by adding or modifying the dictionaries inplace.

display(**kwargs)[source]

Prepare and display the network

classmethod from_ifp(ifp, lig, kind='aggregate', frame=0, threshold=0.3, **kwargs)[source]

Helper method to create a ligand interaction diagram from an IFP DataFrame obtained with fp.to_dataframe(return_atoms=True)

Notes

Two kinds of diagrams can be rendered: either for a designated frame or by aggregating the results on the whole IFP and optionnally discarding interactions that occur less frequently than a threshold. In the latter case (aggregate), only the most frequent ligand atom interaction is rendered.

Parameters
  • ifp (pandas.DataFrame) – The result of fp.to_dataframe(return_atoms=True)

  • lig (rdkit.Chem.rdChem.Mol) – Ligand molecule

  • kind (str) – One of “aggregate” or “frame”

  • frame (int or str) – Frame number, as read in ifp.index. Only applicable for kind="frame"

  • threshold (float) – Frequency threshold, between 0 and 1. Only applicable for kind="aggregate"

  • kwargs (object) – Other arguments passed to the LigNetwork class

save(fp, **kwargs)[source]

Save the network to an HTML file

Parameters

fp (str or file-like object) – Name of the output file, or file-like object

show(filename, **kwargs)[source]

Save the network as HTML and display the resulting file