Standard Datasets
Relevant source files
The following files were used as context for generating this wiki page:
Standard Datasets in DGL-LifeSci provide a unified interface for accessing common benchmarks in molecular machine learning, including properties like solubility, toxicity, and protein-ligand binding affinity. These datasets are structured to facilitate the transition from raw chemical formats (SMILES, SDF, PDB) to graph-based representations suitable for deep learning.
The module provides automated utilities for downloading data, extracting archives, and caching pre-processed DGLGraph objects to accelerate subsequent training runs. By leveraging RDKit for cheminformatics operations, the system supports sophisticated featurization and data cleaning, ensuring that only valid molecular structures are used for modeling.
Architecture and Base Classes
The dataset system is built on a hierarchical structure where specific benchmarks inherit from general-purpose base classes. The most prominent base class is MoleculeCSVDataset, which handles tabular data where molecules are represented as SMILES strings.
MoleculeCSVDataset
This class manages the lifecycle of a CSV-based dataset, including loading from a pandas.DataFrame, identifying task columns, and filtering invalid SMILES. It includes logic for binary masking of missing labels, which is critical for multi-task datasets where not every molecule has been tested against every target.
The diagram shows the data flow from a raw CSV file to a ready-to-use Dataset object, highlighting the caching mechanism.
Molecular Property Benchmarks
DGL-LifeSci implements several standard benchmarks from the MoleculeNet suite and other sources.
Physical Chemistry and Toxicity
Datasets such as ESOL and Tox21 represent single-task regression and multi-task classification respectively.
- ESOL: Contains 1,128 compounds with measured log solubility. Sources: python/dgllife/data/esol.py:16-30
- Tox21: Qualitative toxicity measurements for ~8,000 compounds across 12 targets. Sources: python/dgllife/data/tox21.py:15-25
- MUV: A collection of 17 challenging tasks for approximately 90,000 compounds designed for virtual screening validation. Sources: python/dgllife/data/muv.py:16-25
Quantum Chemistry: Tencent Alchemy
The TencentAlchemyDataset provides 12 quantum mechanical properties for over 130,000 organic molecules. Unlike SMILES-based datasets, it often relies on 3D coordinates provided in SDF files and constructs complete graphs where edges represent distances between all atom pairs.
Sources: python/dgllife/data/alchemy.py:143-160
| Dataset | Type | Task Count | Primary Format |
|---|---|---|---|
| ESOL | Regression | 1 | SMILES |
| Tox21 | Classification | 12 | SMILES |
| MUV | Classification | 17 | SMILES |
| Alchemy | Regression | 12 | SDF (3D) |
Structure-Based Datasets: PDBBind
The PDBBind dataset represents a shift from molecular graphs to protein-ligand complex graphs. It provides 3D Cartesian coordinates for both ligands and their target proteins.
Complex Processing Logic
The PDBBind class handles the complex task of loading two different molecular entities (ligand in SDF/Mol2 format and protein in PDB format), sanitizing them, and optionally extracting binding pockets. The final representation is often a DGLHeteroGraph aware of the protein-ligand binding geometry.
Sources: python/dgllife/data/pdbbind.py:23-65
Sequence of events during PDBBind initialization, involving parallel loading and geometry-aware graph construction.
Featurization and Configuration
Datasets are highly configurable through several key parameters:
- smiles_to_graph: A callable that defines how the molecular graph is built (e.g.,
smiles_to_bigraph). - node_featurizer: Defines the initial atom features (e.g.,
CanonicalAtomFeaturizer). - edge_featurizer: Defines bond features.
- load_full: A boolean flag available in classes like
ESOLandMUVthat, when True, returns additional metadata (e.g., molecular weight, compound IDs) alongside the graph and labels.
Sources: python/dgllife/data/esol.py:100-115, python/dgllife/data/csv_dataset.py:45-55
Task Positive Weights
For classification datasets like MUV and Tox21, the task_pos_weights method is provided to calculate the ratio of negative to positive samples per task. This is used to compute weighted loss functions to address class imbalance.
Sources: python/dgllife/data/csv_dataset.py:158-185
Summary
The standard datasets in DGL-LifeSci offer a robust infrastructure for reproducible research. By automating the pipeline from raw file download to DGLGraph caching, and providing base classes like MoleculeCSVDataset, the project enables researchers to quickly benchmark models across diverse chemical and biological tasks.