Skip to content

Commit

Permalink
[DGL-LifeSci] Documentation (dmlc#1414)
Browse files Browse the repository at this point in the history
* Update

* Update

* Update
  • Loading branch information
mufeili authored Apr 2, 2020
1 parent 7e0893e commit d3560b7
Show file tree
Hide file tree
Showing 30 changed files with 1,243 additions and 246 deletions.
2 changes: 2 additions & 0 deletions apps/life_sci/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# DGL-LifeSci

[Documentation](https://lifesci.dgl.ai/index.html) | [Discussion Forum](https://discuss.dgl.ai)

## Introduction

Deep learning on graphs has been an arising trend in the past few years. There are a lot of graphs in
Expand Down
68 changes: 41 additions & 27 deletions apps/life_sci/docs/source/api/data.rst
Original file line number Diff line number Diff line change
@@ -1,47 +1,61 @@
.. _apidata:

dgllife.data
============
Datasets
========

TBD by Murphy
.. contents:: Contents
:local:

dgllife.data.alchemy
--------------------
Molecular Property Prediction
-----------------------------

.. automodule:: dgllife.data.alchemy
:members:
Tox21
`````

.. autoclass:: dgllife.data.Tox21
:members: task_pos_weights, __getitem__, __len__
:show-inheritance:

dgllife.data.csv_dataset
------------------------
Alchemy for Quantum Chemistry
`````````````````````````````

.. automodule:: dgllife.data.csv_dataset
:members:
.. autoclass:: dgllife.data.TencentAlchemyDataset
:members: set_mean_and_std, __getitem__, __len__

Pubmed Aromaticity
``````````````````

dgllife.data.pdbbind
---------------------
.. autoclass:: dgllife.data.PubChemBioAssayAromaticity
:members: __getitem__, __len__
:show-inheritance:

.. automodule:: dgllife.data.pdbbind
:members:
Adapting to New Datasets with CSV
`````````````````````````````````

.. autoclass:: dgllife.data.MoleculeCSVDataset
:members: __getitem__, __len__

dgllife.data.pubchem_aromaticity
---------------------------------
Reaction Prediction
-------------------

.. automodule:: dgllife.data.pubchem_aromaticity
:members:
USPTO
`````

.. autoclass:: dgllife.data.USPTO
:members: __getitem__, __len__
:show-inheritance:

dgllife.data.tox21
---------------------------------
Adapting to New Datasets for Weisfeiler-Lehman Networks
```````````````````````````````````````````````````````

.. automodule:: dgllife.data.tox21
:members:
.. autoclass:: dgllife.data.WLNReactionDataset
:members: __getitem__, __len__

Protein-Ligand Binding Affinity Prediction
------------------------------------------

dgllife.data.uspto
---------------------------------
PDBBind
```````

.. automodule:: dgllife.data.uspto
:members:
.. autoclass:: dgllife.data.PDBBind
:members: __getitem__, __len__
39 changes: 21 additions & 18 deletions apps/life_sci/docs/source/api/model.gnn.rst
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
.. _apimodelgnn:

dgllife.model.gnn
==================
Graph Neural Networks for Updating Node/Edge Representations
============================================================

TBD by Murphy
All models based on graph neural networks start with updating node/edge representations.
We introduce various GNN models implemented in DGL-LifeSci for representation update.

dgllife.model.gnn.attentivefp
-------------------------------------------
.. contents:: Contents
:local:

AttentiveFP
-----------
.. automodule:: dgllife.model.gnn.attentivefp
:members:


dgllife.model.gnn.gat
----------------------------
GAT
---
.. automodule:: dgllife.model.gnn.gat
:members:

dgllife.model.gnn.gcn
----------------------------
GCN
---
.. automodule:: dgllife.model.gnn.gcn
:members:

dgllife.model.gnn.mgcn
----------------------------
MGCN
----
.. automodule:: dgllife.model.gnn.mgcn
:members:

dgllife.model.gnn.mpnn
----------------------------
MPNN
----
.. automodule:: dgllife.model.gnn.mpnn
:members:

dgllife.model.gnn.schnet
----------------------------
SchNet
------
.. automodule:: dgllife.model.gnn.schnet
:members:

dgllife.model.gnn.wln
----------------------------
WLN
---
.. automodule:: dgllife.model.gnn.wln
:members:
66 changes: 66 additions & 0 deletions apps/life_sci/docs/source/api/model.pretrain.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.. _apimodelpretrain:

Pre-trained Models
==================

We provide multiple pre-trained models for users to use without the need of training from scratch.

Example Usage
-------------

Property Prediction
```````````````````

.. code-block:: python
from dgllife.data import Tox21
from dgllife.model import load_pretrained
from dgllife.utils import smiles_to_bigraph, CanonicalAtomFeaturizer
dataset = Tox21(smiles_to_bigraph, CanonicalAtomFeaturizer())
model = load_pretrained('GCN_Tox21') # Pretrained model loaded
model.eval()
smiles, g, label, mask = dataset[0]
feats = g.ndata.pop('h')
label_pred = model(g, feats)
print(smiles) # CCOc1ccc2nc(S(N)(=O)=O)sc2c1
print(label_pred[:, mask != 0]) # Mask non-existing labels
# tensor([[ 1.4190, -0.1820, 1.2974, 1.4416, 0.6914,
# 2.0957, 0.5919, 0.7715, 1.7273, 0.2070]])
Generative Models

.. code-block:: python
from dgllife.model import load_pretrained
model = load_pretrained('DGMG_ZINC_canonical')
model.eval()
smiles = []
for i in range(4):
smiles.append(model(rdkit_mol=True))
print(smiles)
# ['CC1CCC2C(CCC3C2C(NC2=CC(Cl)=CC=C2N)S3(=O)=O)O1',
# 'O=C1SC2N=CN=C(NC(SC3=CC=CC=N3)C1=CC=CO)C=2C1=CCCC1',
# 'CC1C=CC(=CC=1)C(=O)NN=C(C)C1=CC=CC2=CC=CC=C21',
# 'CCN(CC1=CC=CC=C1F)CC1CCCN(C)C1']
If you are running the code block above in Jupyter notebook, you can also visualize the molecules generated with

.. code-block:: python
from IPython.display import SVG
from rdkit import Chem
from rdkit.Chem import Draw
mols = [Chem.MolFromSmiles(s) for s in smiles]
SVG(Draw.MolsToGridImage(mols, molsPerRow=4, subImgSize=(180, 150), useSVG=True))
.. image:: https://data.dgl.ai/dgllife/dgmg/dgmg_model_zoo_example2.png

API
---

.. autofunction:: dgllife.model.load_pretrained
29 changes: 16 additions & 13 deletions apps/life_sci/docs/source/api/model.readout.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
.. _apimodelreadout:

dgllife.model.readout
========================
Readout for Computing Graph Representations
===========================================

TBD by Murphy
After updating node/edge representations with graph neural networks (GNNs), a common operation is to compute
graph representations out of updated node/edge representations. For example, we need to compute molecular
representations out of atom/bond representations in molecular property prediction. We call the various modules
for computing graph-level representations **readout** as in Neural Message Passing for Quantum Chemistry and this
section lists the readout modules implemented in DGL-LifeSci.

dgllife.model.readout.attentivefp_readout
------------------------------------------
.. contents:: Contents
:local:

AttentiveFP Readout
-------------------
.. automodule:: dgllife.model.readout.attentivefp_readout
:members:



dgllife.model.readout.mlp_readout
------------------------------------------
MLP Readout
-----------
.. automodule:: dgllife.model.readout.mlp_readout
:members:



dgllife.model.readout.weighted_sum_and_max
--------------------------------------------
Weighted Sum and Max Readout
----------------------------
.. automodule:: dgllife.model.readout.weighted_sum_and_max
:members:
8 changes: 0 additions & 8 deletions apps/life_sci/docs/source/api/model.rst

This file was deleted.

82 changes: 49 additions & 33 deletions apps/life_sci/docs/source/api/model.zoo.rst
Original file line number Diff line number Diff line change
@@ -1,61 +1,77 @@
.. _apimodelzoo:

dgllife.model.model_zoo
=============================
Model Zoo
=========

TBD by Murphy
This section introduces complete models for various downstream tasks.

dgllife.model.model_zoo.attentivefp_predictor
-----------------------------------------------
.. contents:: Contents
:local:

Building Blocks
---------------

MLP Predictor
`````````````
.. automodule:: dgllife.model.model_zoo.mlp_predictor
:members:

Molecular Property Prediction
-----------------------------

AttentiveFP Predictor
`````````````````````
.. automodule:: dgllife.model.model_zoo.attentivefp_predictor
:members:

dgllife.model.model_zoo.gat_predictor
-------------------------------------------
GAT Predictor
`````````````
.. automodule:: dgllife.model.model_zoo.gat_predictor
:members:

dgllife.model.model_zoo.gcn_predictor
-------------------------------------------
GCN Predictor
`````````````
.. automodule:: dgllife.model.model_zoo.gcn_predictor
:members:

dgllife.model.model_zoo.mgcn_predictor
-------------------------------------------
MGCN Predictor
``````````````
.. automodule:: dgllife.model.model_zoo.mgcn_predictor
:members:

dgllife.model.model_zoo.mlp_predictor
-------------------------------------------
.. automodule:: dgllife.model.model_zoo.mlp_predictor
:members:

dgllife.model.model_zoo.mpnn_predictor
-------------------------------------------
MPNN Predictor
``````````````
.. automodule:: dgllife.model.model_zoo.mpnn_predictor
:members:

dgllife.model.model_zoo.schnet_predictor
-------------------------------------------
SchNet Predictor
````````````````
.. automodule:: dgllife.model.model_zoo.schnet_predictor
:members:

dgllife.model.model_zoo.wln_reaction_center
-------------------------------------------
.. automodule:: dgllife.model.model_zoo.wln_reaction_center
:members:
Generative Models
-----------------

dgllife.model.model_zoo.acnn
-------------------------------------------
.. automodule:: dgllife.model.model_zoo.acnn
:members:

dgllife.model.model_zoo.dgmg
-------------------------------------------
DGMG
````
.. automodule:: dgllife.model.model_zoo.dgmg
:members:

dgllife.model.model_zoo.jtnn
-------------------------------------------
JTNN
````
.. autoclass:: dgllife.model.model_zoo.jtnn.DGLJTNNVAE
:members:

Reaction Prediction

WLN for Reaction Center Prediction
``````````````````````````````````
.. automodule:: dgllife.model.model_zoo.wln_reaction_center
:members:

Protein-Ligand Binding Affinity Prediction

ACNN
````
.. automodule:: dgllife.model.model_zoo.acnn
:members:
Loading

0 comments on commit d3560b7

Please sign in to comment.