File size: 7,541 Bytes
ac679a1
b6472ef
169d23e
ac679a1
5b5646a
ac679a1
 
 
 
 
 
 
 
1ee1eca
 
3b30db5
 
 
 
 
 
 
2ac89de
3b30db5
2ac89de
 
 
 
 
 
 
 
 
3b30db5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ac89de
 
 
 
 
 
 
 
 
 
 
19e0336
2ac89de
 
 
 
 
 
 
 
 
 
3b30db5
 
 
 
 
 
 
 
ac679a1
 
 
 
 
 
d306d9f
ac679a1
 
 
 
 
 
5b5646a
 
 
ac679a1
 
888a2ef
04fae7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c6bb32
ec60e4b
 
 
04fae7a
 
 
 
 
ec60e4b
 
 
04fae7a
ec60e4b
 
 
 
 
 
 
 
 
04fae7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b5646a
04fae7a
5b5646a
04fae7a
 
 
 
 
 
 
5b5646a
04fae7a
5b5646a
04fae7a
5b5646a
68da5c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
version: 1.0.0
license: cc-by-sa-4.0
task_categories:
- tabular-classification
language:
- en
pretty_name: MolData
size_categories:
- 1M<n<10M
tags:
- drug discovery
- bioassay
dataset_summary: A comprehensive disease and target-based dataset with roughly 170 million drug screening results from 1.4 million
  unique molecules and 600 assays which are collected from PubChem to accelerate molecular machine learning for better drug discovery.
citation: "@article{KeshavarziArshadi2022,\n title = {MolData,  a molecular benchmark\
  \ for disease and target based machine learning},\n volume = {14},\n ISSN = {1758-2946},\n\
  \ url = {http://dx.doi.org/10.1186/s13321-022-00590-y},\n DOI = {10.1186/s13321-022-00590-y},\n\
  \ number = {1},\n journal = {Journal of Cheminformatics},\n publisher = {Springer\
  \ Science and Business Media LLC},\n author = {Keshavarzi Arshadi,  Arash and Salem,\
  \  Milad and Firouzbakht,  Arash and Yuan,  Jiann Shiun},\n year = {2022},\n month\
  \ = mar \n}"
dataset_info:
- config_name: MolData
  features:
  - name: SMILES
    dtype: string
  - name: PUBCHEM_CID
    dtype: int64
  - name: split
    dtype: string
  - name: AID
    dtype: string
  - name: Y
    dtype: int64
    description: 'Binary classification (0/1)   '
  splits:
  - name: train
    num_bytes: 12634275804
    num_examples: 138547273
  - name: test
    num_bytes: 1578698654
    num_examples: 17069726
  - name: validation
    num_bytes: 1254512486
    num_examples: 12728449
  download_size: 5293486933
  dataset_size: 15467486944
- config_name: default
  features:
  - name: SMILES
    dtype: string
  - name: PUBCHEM_CID
    dtype: int64
  - name: split
    dtype: string
  - name: AID
    dtype: string
  - name: Y
    dtype: int64
  splits:
  - name: train
    num_bytes: 12634275804
    num_examples: 138547273
  - name: test
    num_bytes: 1578698654
    num_examples: 17069726
  - name: validation
    num_bytes: 1254512486
    num_examples: 12728449
  download_size: 5293486933
  dataset_size: 15467486944
configs:
- config_name: MolData
  data_files:
  - split: train
    path: MolData/train-*
  - split: test
    path: MolData/test-*
  - split: validation
    path: MolData/validation-*
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: test
    path: data/test-*
  - split: validation
    path: data/validation-*
---

# MolData

[MolData](https://jcheminf.biomedcentral.com/articles/10.1186/s13321-022-00590-y) is a comprehensive disease and target-based dataset collected from PubChem.
The dataset contains 1.4 million unique molecules, and it is one the largest efforts to date for democratizing the molecular machine learning.
This is a mirror of the [Official Github repo](https://github.com/LumosBio/MolData/tree/main/Data) where the dataset was uploaded in 2021.


## Preprocessing

We utilized the raw data uploaded on [Github](https://github.com/LumosBio/MolData) and performed several preprocessing:
1. Sanitize the molecules using RDKit and MolVS (standardize SMILES format)
2. Formatting (from wide form to long form)
3. Rename the columns
4. Split the dataset (train, test, validation)

If you would like to try these processes with the original dataset, 
please follow the instructions in the [preprocessing script](https://huggingface.co/datasets/maomlab/MolData/blob/main/MolData_preprocessing.py) file located in our MolData repository.



## Quickstart Usage

### Load a dataset in python
Each subset can be loaded into python using the Huggingface [datasets](https://huggingface.co/docs/datasets/index) library.
First, from the command line install the `datasets` library

    $ pip install datasets

then, from within python load the datasets library

    >>> import datasets
   
and load the `MolData` datasets, e.g.,

    >>> MolData = datasets.load_dataset("maomlab/MolData", name = "MolData")
        Generating train split: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 138547273/138547273 [02:07<00:00, 1088043.12 examples/s]
        Generating test split: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 17069726/17069726 [00:16<00:00, 1037407.67 examples/s]
        Generating validation split: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12728449/12728449 [00:11<00:00, 1093675.24 examples/s]

and inspecting the loaded dataset

    >>> MolData
    DatasetDict({
    train: Dataset({
        features: ['SMILES', 'PUBCHEM_CID', 'split', 'AID', 'Y'],
        num_rows: 138547273
    })
    test: Dataset({
        features: ['SMILES', 'PUBCHEM_CID', 'split', 'AID', 'Y'],
        num_rows: 17069726
    })
    validation: Dataset({
        features: ['SMILES', 'PUBCHEM_CID', 'split', 'AID', 'Y'],
        num_rows: 12728449
    })
})

### Use a dataset to train a model
One way to use the dataset is through the [MolFlux](https://exscientia.github.io/molflux/) package developed by Exscientia.
First, from the command line, install `MolFlux` library with `catboost` and `rdkit` support

    pip install 'molflux[catboost,rdkit]'

then load, featurize, split, fit, and evaluate the catboost model

    import json
    from datasets import load_dataset
    from molflux.datasets import featurise_dataset
    from molflux.features import load_from_dicts as load_representations_from_dicts
    from molflux.splits import load_from_dict as load_split_from_dict
    from molflux.modelzoo import load_from_dict as load_model_from_dict
    from molflux.metrics import load_suite

Split and evaluate the catboost model
    
    split_dataset = load_dataset('maomlab/MolData', name = 'MolData')
    
    split_featurised_dataset = featurise_dataset(
      split_dataset,
      column = "SMILES",
      representations = load_representations_from_dicts([{"name": "morgan"}, {"name": "maccs_rdkit"}]))
    
    model = load_model_from_dict({
        "name": "cat_boost_classifier",
        "config": {
            "x_features": ['SMILES::morgan', 'SMILES::maccs_rdkit'],
            "y_features": ['Y']}})
    
    model.train(split_featurised_dataset["train"])
    preds = model.predict(split_featurised_dataset["test"])
    
    classification_suite = load_suite("classification")
    
    scores = classification_suite.compute(
        references=split_featurised_dataset["test"]['Y'],
        predictions=preds["cat_boost_classifier::Y"])


### Citation
@article{KeshavarziArshadi2022,
 title = {MolData,  a molecular benchmark for disease and target based machine learning},
 volume = {14},
 ISSN = {1758-2946},
 url = {http://dx.doi.org/10.1186/s13321-022-00590-y},
 DOI = {10.1186/s13321-022-00590-y},
 number = {1},
 journal = {Journal of Cheminformatics},
 publisher = {Springer Science and Business Media LLC},
 author = {Keshavarzi Arshadi,  Arash and Salem,  Milad and Firouzbakht,  Arash and Yuan,  Jiann Shiun},
 year = {2022},
 month = mar 
}