A reproducible Applied Pharmaceutical Bioinformatics project for modelling molecular binding affinity from SMILES strings. The target is Ki (nM), transformed to log10(Ki) for regression and thresholded for activity classification.
The repository is structured as a code-first PhD-application portfolio project: clean source modules, reproducible environment files, a runnable smoke check, and a notebook workflow. It avoids inflated claims: random cross-validation is useful internal validation, not proof of prospective drug-discovery performance.
| Item | Detail |
|---|---|
| Research task | QSAR-style prediction of Ki from molecular structure |
| Dataset | 7,562 SMILES/Ki records supplied for an exam project |
| Curation | RDKit parsing, largest-fragment selection, canonical SMILES, median aggregation of repeats |
| Final modelling set | 4,820 unique canonical molecules |
| Descriptors | ECFP4, MACCS keys, RDKit descriptors, custom SMARTS-derived structural features |
| Best regression model | ExtraTrees regressor, R² = 0.722 ± 0.055 on log10(Ki) |
| Main limitation | Random CV does not prove scaffold-level generalisation |
.
├── data/ # example data; full exam dataset can be added locally
├── notebooks/ # notebook workflow location
├── src/apb_ki_modelling/ # reusable cleaning and descriptor code
├── scripts/ # smoke check and notebook execution helpers
├── environment.yml
├── requirements.txt
├── pyproject.toml
└── Makefile
- Load raw SMILES and Ki values.
- Remove missing and non-positive Ki values.
- Parse molecules with RDKit.
- For salts and multi-fragment records, keep the largest covalent fragment.
- Convert molecules to canonical isomeric SMILES.
- Aggregate repeated canonical molecules using median Ki.
- Transform Ki to
log10(Ki)for regression. - Generate ECFP4, MACCS, RDKit, and custom descriptors.
- Compare regression and classification models using 10-fold cross-validation.
- Run descriptor ablation to test where predictive signal comes from.
| Step | Result |
|---|---|
| Raw records | 7,562 |
| Valid Ki records after cleaning | 7,556 |
| Invalid RDKit SMILES | 0 |
| Multi-fragment SMILES | 552 |
| Unique canonical molecules after aggregation | 4,820 |
| Model | R² | MSE |
|---|---|---|
| ExtraTrees regressor | 0.722 ± 0.055 | 0.476 ± 0.102 |
| HistGradientBoosting regressor | 0.694 ± 0.065 | 0.524 ± 0.124 |
| Random Forest regressor | 0.669 ± 0.055 | 0.569 ± 0.106 |
| Ridge regression | 0.463 ± 0.106 | 0.909 ± 0.116 |
| Threshold | Best model by AUC | AUC | F1 |
|---|---|---|---|
| Ki < 1000 nM | HistGradientBoosting / ExtraTrees | 0.942 ± 0.013 / 0.942 ± 0.018 | 0.966 ± 0.005 / 0.965 ± 0.006 |
| Ki < median Ki | ExtraTrees | 0.891 ± 0.017 | 0.802 ± 0.025 |
The Ki < 1000 nM task is chemically interpretable but imbalanced: about 90% of canonical molecules are active. The median split is less chemically meaningful but gives a more honest classifier stress test.
| Descriptor set | Features | R² mean | MSE mean |
|---|---|---|---|
| ECFP4 + MACCS + RDKit + custom | 1236 | 0.721753 | 0.475985 |
| ECFP4 + RDKit core | 1037 | 0.707132 | 0.502200 |
| ECFP4 only | 1024 | 0.696819 | 0.520654 |
| RDKit core only | 13 | 0.504880 | 0.851078 |
ECFP4 carries most of the signal. The extended descriptor set helps, but the gain is incremental, not transformative.
Use Conda or Mamba. RDKit is the dependency most likely to break in a casual pip-only setup.
mamba env create -f environment.yml
mamba activate apb-ki-modelling
make smokeRun the notebook after adding it to notebooks/Ki_modelling.ipynb:
make notebookRandom 10-fold cross-validation after duplicate aggregation is acceptable for an exam project, but it can still leak analogue-series information across folds. A research-grade next step would use Bemis-Murcko scaffold splitting, external validation, uncertainty estimates, and error analysis by chemical series.
The dataset was supplied for an exam project. The code is reusable; dataset reuse outside the course context may require checking the original data rights.