torchdrug

A powerful and flexible machine learning platform for drug discovery

https://github.com/deepgraphlearning/torchdrug

Science Score: 41.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 17 committers (11.8%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.9%) to scientific vocabulary

Keywords

deep-learning drug-discovery graph-neural-networks pytorch
Last synced: 10 months ago · JSON representation ·

Repository

A powerful and flexible machine learning platform for drug discovery

Basic Info
  • Host: GitHub
  • Owner: DeepGraphLearning
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Homepage: https://torchdrug.ai/
  • Size: 2.63 MB
Statistics
  • Stars: 1,499
  • Watchers: 28
  • Forks: 205
  • Open Issues: 121
  • Releases: 4
Topics
deep-learning drug-discovery graph-neural-networks pytorch
Created almost 5 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.md

TorchDrug

with TorchProtein

Open in Colab Contributions License Apache-2.0 PyPI downloads TorchDrug Twitter

Docs | Tutorials | Benchmarks | Papers Implemented

TorchDrug is a PyTorch-based machine learning toolbox designed for several purposes.

  • Easy implementation of graph operations in a PyTorchic style with GPU support
  • Being friendly to practitioners with minimal knowledge about drug discovery
  • Rapid prototyping of machine learning research

Installation

TorchDrug can be installed on either Linux, Windows or macOS. It is compatible with 3.7 <= Python <= 3.10 and PyTorch >= 1.8.0.

From Conda

bash conda install torchdrug -c milagraph -c conda-forge -c pytorch -c pyg

From Pip

bash pip install torch==1.9.0 pip install torch-scatter torch-cluster -f https://pytorch-geometric.com/whl/torch-1.9.0+cu102.html pip install torchdrug

To install torch-scatter for other PyTorch or CUDA versions, please see the instructions in https://github.com/rusty1s/pytorch_scatter

From Source

bash git clone https://github.com/DeepGraphLearning/torchdrug cd torchdrug pip install -r requirements.txt python setup.py install

Windows (PowerShell)

We need to first install the build tools for Visual Studio. We then install the following modules in PowerShell.

powershell Install-Module Pscx -AllowClobber Install-Module VSSetup

Initialize Visual Studio in PowerShell with the following commands. We may setup this for all PowerShell sessions by writing it to the PowerShell profile. Change the library path according to your own case.

powershell Import-VisualStudioVars -Architecture x64 $env:LIB += ";C:\Program Files\Python37\libs"

Apple Silicon (M1/M2 Chips)

We need PyTorch >= 1.13 to run TorchDrug on Apple silicon. For torch-scatter and torch-cluster, they can be compiled from their sources. Note TorchDrug doesn't support mps devices.

bash pip install torch==1.13.0 pip install git+https://github.com/rusty1s/pytorch_scatter.git pip install git+https://github.com/rusty1s/pytorch_cluster.git pip install torchdrug

Quick Start

TorchDrug is designed for humans and focused on graph structured data. It enables easy implementation of graph operations in machine learning models. All the operations in TorchDrug are backed by PyTorch framework, and support GPU acceleration and auto differentiation.

```python from torchdrug import data

edgelist = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]] graph = data.Graph(edgelist, num_node=6) graph = graph.cuda()

the subgraph induced by nodes 2, 3 & 4

subgraph = graph.subgraph([2, 3, 4]) ```

Molecules are also supported in TorchDrug. You can get the desired molecule properties without any domain knowledge.

python mol = data.Molecule.from_smiles("CCOC(=O)N", atom_feature="default", bond_feature="default") print(mol.node_feature) print(mol.atom_type) print(mol.to_scaffold())

You may also register custom node, edge or graph attributes. They will be automatically processed during indexing operations.

python with mol.edge(): mol.is_CC_bond = (mol.edge_list[:, :2] == td.CARBON).all(dim=-1) sub_mol = mol.subgraph(mol.atom_type != td.NITROGEN) print(sub_mol.is_CC_bond)

TorchDrug provides a wide range of common datasets and building blocks for drug discovery. With minimal code, you can apply standard models to solve your own problem.

```python import torch from torchdrug import datasets

dataset = datasets.Tox21() dataset[0].visualize() lengths = [int(0.8 * len(dataset)), int(0.1 * len(dataset))] lengths += [len(dataset) - sum(lengths)] trainset, validset, testset = torch.utils.data.randomsplit(dataset, lengths) ```

```python from torchdrug import models, tasks

model = models.GIN(dataset.nodefeaturedim, hidden_dims=[256, 256, 256, 256]) task = tasks.PropertyPrediction(model, task=dataset.tasks) ```

Training and inference are accelerated by multiple CPUs or GPUs. This can be seamlessly switched in TorchDrug by just a line of code. ```python from torchdrug import core

Single CPU / Multiple CPUs / Distributed CPUs

solver = core.Engine(task, trainset, validset, test_set, optimizer)

Single GPU

solver = core.Engine(task, trainset, validset, test_set, optimizer, gpus=[0])

Multiple GPUs

solver = core.Engine(task, trainset, validset, test_set, optimizer, gpus=[0, 1, 2, 3])

Distributed GPUs

solver = core.Engine(task, trainset, validset, test_set, optimizer, gpus=[0, 1, 2, 3, 0, 1, 2, 3]) ```

Experiments can be easily tracked and managed through Weights & Biases platform. python solver = core.Engine(task, train_set, valid_set, test_set, optimizer, logger="wandb")

Contributing

Everyone is welcome to contribute to the development of TorchDrug. Please refer to contributing guidelines for more details.

License

TorchDrug is released under Apache-2.0 License.

Owner

  • Name: MilaGraph
  • Login: DeepGraphLearning
  • Kind: organization
  • Email: tangjianpku@gmail.com
  • Location: Montreal

Research group led by Prof. Jian Tang at Mila-Quebec AI Institute (https://mila.quebec/) focusing on graph representation learning and graph neural networks.

Citation (CITATION)

@article{zhu2022torchdrug,
      title={TorchDrug: A Powerful and Flexible Machine Learning Platform for Drug Discovery}, 
      author={Zhu, Zhaocheng and Shi, Chence and Zhang, Zuobai and Liu, Shengchao and Xu, Minghao and Yuan, Xinyu and Zhang, Yangtian and Chen, Junkun and Cai, Huiyu and Lu, Jiarui and Ma, Chang and Liu, Runcheng and Xhonneux, Louis-Pascal and Qu, Meng and Tang, Jian},
      journal={arXiv preprint arXiv:2202.08320},
      year={2022}
}

GitHub Events

Total
  • Issues event: 7
  • Watch event: 97
  • Issue comment event: 12
  • Pull request event: 2
  • Fork event: 14
Last Year
  • Issues event: 7
  • Watch event: 97
  • Issue comment event: 12
  • Pull request event: 2
  • Fork event: 14

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 111
  • Total Committers: 17
  • Avg Commits per committer: 6.529
  • Development Distribution Score (DDS): 0.369
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Zhaocheng Zhu h****l@1****m 70
oxer 1****5@f****n 22
Hiroshi Kajino h****9@g****m 2
Manan Goel m****9@g****m 2
Chence Shi c****i@p****n 2
Jannis Born j****b@z****m 2
Joseph Spisak s****o@g****m 1
Jimmy Yao j****h@g****m 1
Michael Galkin m****n@g****m 1
James Myatt j****s@j****k 1
Cody Scandore c****e@g****m 1
Charles Tapley Hoyt c****t@g****m 1
Saurav Maheshkar s****r@g****m 1
Shoufa Chen s****n@1****m 1
UESTC-DaShenZi 1****0@q****m 1
Will Connell w****3@g****m 1
juntae k****9@n****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 97
  • Total pull requests: 20
  • Average time to close issues: about 1 month
  • Average time to close pull requests: about 1 month
  • Total issue authors: 71
  • Total pull request authors: 16
  • Average comments per issue: 2.66
  • Average comments per pull request: 1.75
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 5
  • Pull requests: 5
  • Average time to close issues: 4 days
  • Average time to close pull requests: 1 minute
  • Issue authors: 5
  • Pull request authors: 5
  • Average comments per issue: 0.4
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • schinto (11)
  • scintiller (4)
  • Yongrui-Wang (3)
  • jannisborn (3)
  • JianBin-Liu (3)
  • Drlittlelab (2)
  • KiddoZhu (2)
  • ChifengWoo (2)
  • DreamMemory001 (2)
  • rmurphy2718 (2)
  • Oxer11 (2)
  • voidpunk (2)
  • jwzhi (1)
  • Samek24 (1)
  • fonseca-dfm (1)
Pull Request Authors
  • 950288 (2)
  • OPAYA (2)
  • Shashank1202 (2)
  • rymndhng (2)
  • DaShenZi721 (2)
  • benjaminwfriedman (2)
  • cthoyt (2)
  • UmarZein (2)
  • manangoel99 (2)
  • Mrz-zz (1)
  • JiahaoYao (1)
  • mrzzmrzz (1)
  • jspisak (1)
  • kanojikajino (1)
  • jannisborn (1)
Top Labels
Issue Labels
bug (12) enhancement (7) installation (5) compatibility (4) duplicate (4) documentation (3) question (1) help wanted (1)
Pull Request Labels

Dependencies

requirements.txt pypi
  • decorator *
  • jinja2 *
  • matplotlib *
  • networkx *
  • ninja *
  • numpy >=1.11
  • rdkit-pypi *
  • torch >=1.8.0
  • torch-scatter >=2.0.8
  • tqdm *
setup.py pypi
  • decorator *
  • jinja2 *
  • matplotlib *
  • networkx *
  • ninja *
  • numpy >=1.11
  • rdkit-pypi >=2020.9
  • torch >=1.8.0
  • torch-scatter >=2.0.8
  • tqdm *
docker/Dockerfile docker
  • pytorch/pytorch 1.8.1-cuda11.1-cudnn8-devel build