Skip to main content

A library to quickly build QSAR models

Project description

Lazy QSAR

A library to build QSAR models fastly

Installation

git clone https://github.com/ersilia-os/lazy-qsar.git
cd lazy-qsar
python -m pip install -e .

Usage

TLDR

  1. Choose one of the available descriptors of small molecules.
  2. Fit a model using FLAML AutoML. FLAML will search several estimators, which can lead to memory issues. Restrict the list on a case-by-case basis.
  3. Get the validation of the model on the test set.

Example for Binary Classifications

Get the data

You can find example data in the fantastic Therapeutic Data Commons portal.

from tdc.single_pred import Tox
data = Tox(name = 'hERG')
split = data.get_split()

Here we are selecting the hERG blockade toxicity dataset. Let's refactor data for convenience.

# refactor fetched data in a convenient format
smiles_train = list(split["train"]["Drug"])
y_train = list(split["train"]["Y"])
smiles_valid = list(split["valid"]["Drug"])
y_valid = list(split["valid"]["Y"])

Build a model

Now we can train a model based on Morgan fingerprints.

import lazyqsar as lq


model = lq.MorganBinaryClassifier() 
# time_budget (in seconds) and estimator_list can be passed as parameters of the classifier. Defaults to 20s and all the available estimators in FLAML.
model.fit(smiles_train, y_train)

Validate its performance

from sklearn.metrics import roc_curve, auc
y_hat = model.predict_proba(smiles_valid)[:,1]
fpr, tpr, _ = roc_curve(y_valid, y_hat)
print("AUROC", auc(fpr, tpr))

Example for Regressions

Currently, only Morgan Descriptors and Ersilia Embeddings are available for regression models

Get the data

You can find example data in the fantastic Therapeutic Data Commons portal.

from tdc.single_pred import Tox
data = Tox(name = 'LD50_Zhu')
split = data.get_split()

Here we are selecting the Acute Toxicity dataset. Let's refactor data for convenience.

# refactor fetched data in a convenient format
smiles_train = list(split["train"]["Drug"])
y_train = list(split["train"]["Y"])
smiles_valid = list(split["valid"]["Drug"])
y_valid = list(split["valid"]["Y"])

Build a model

Now we can train a model based on Morgan fingerprints.

import lazyqsar as lq

model = lq.MorganBinaryClassifier() 
# time_budget (in seconds) and estimator_list can be passed as parameters of the classifier. Defaults to 20s and all the available estimators in FLAML.
model.fit(smiles_train, y_train)

Validate its performance

from sklearn.metrics import roc_curve, auc
y_hat = model.predict(smiles_valid)
mae = mean_absolute_error(y_valid, y_hat)
r2 = r2_score(y_valid, y_hat)
print("MAE", mae, "R2", r2)

Benchmark

The pipeline has been validated using the Therapeutic Data Commons ADMET datasets. More information about its results can be found in the /benchmark folder.

Disclaimer

This library is only intended for quick-and-dirty QSAR modeling. For a more complete automated QSAR modeling, please refer to Zaira Chem

About us

Learn about the Ersilia Open Source Initiative!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lazyqsar-0.4.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

lazyqsar-0.4-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file lazyqsar-0.4.tar.gz.

File metadata

  • Download URL: lazyqsar-0.4.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.16

File hashes

Hashes for lazyqsar-0.4.tar.gz
Algorithm Hash digest
SHA256 a8d034f7be4bc168d5d00150d54f1a35bb83e306d98e70377a4df70927b9b8b9
MD5 f8e6cdecf470cc8891abaa284c35bcf2
BLAKE2b-256 afb672763d2522e94cdb59aa6233733b761391302f9ac654657e33bf5b587126

See more details on using hashes here.

File details

Details for the file lazyqsar-0.4-py3-none-any.whl.

File metadata

  • Download URL: lazyqsar-0.4-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.16

File hashes

Hashes for lazyqsar-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 97fbafae929a893da9f4c40bc85bd8e06be73739307b1de88fc1890d102ddb33
MD5 d5c55c3665ea8ae0901755a9fcd67e04
BLAKE2b-256 35be802ebeff455a1f1adef93944f17224dd1aed51825534909ef20b36f939b3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page