A package for robust Applicability Domain (AD) analysis in chemoinformatics and QSAR modeling.
Applicability Domain analysis defines the boundaries within which a QSAR model's predictions can be trusted, by comparing new (test) compounds against the chemical space covered by the training set. This package implements multiple AD metrics (DModX, Hotelling's
- Operating System: Developed and tested exclusively on Ubuntu Linux (tested on Ubuntu 24.04 LTS and 26.04 LTS). Compatibility with macOS (likely functional via Conda) and Windows has not been tested and is provided without warranty.
- Python 3.10: the project is built for this specific Python version.
- Conda: a package and environment management system, highly recommended.
- Create a Conda environment using the
environment.ymlfile:
conda env create -f environment.yml
conda activate adtest_framework- Install the package in editable/development mode. This makes the
adtestCLI command available:
pip install -e .ADtest is driven entirely through a YAML configuration file — there is no direct-CLI-flags mode. Each YAML defines one or more datasets to process (train/test paths, descriptors, AD model, and clustering/cross-validation settings), and the pipeline runs end-to-end: data loading, descriptor calculation, AD model fitting, (optional) clustered cross-validation for OOF thresholds, and report generation (YAML + DOCX + diagnostic plots).
adtest -c run -cfg <path_to_config>.yaml| Flag | Required | Description |
|---|---|---|
-c, --command |
Yes | Command to execute. Currently only run is supported. |
-cfg, --config |
Yes | Path to the YAML configuration file describing the dataset(s) and analysis settings. |
-o, --output |
No | Base output directory for results, logs, plots, and reports (default: results/). Each dataset/endpoint gets its own subdirectory: <output>/<endpoint>/. |
-q, --quiet |
No | Suppress standard logging output. |
adtest -c run -cfg ad_ames_test.yamlFor each dataset defined in the YAML, ADtest produces, under <output>/<dataset_name>/:
<prefix>.yaml— machine-readable report: analysis setup, dataset summary, raw and OOF AD thresholds, and external test set performance (AD coverage and prediction-error rates inside/outside the AD, per thresholding strategy).<prefix>.docx— human-readable report with the same information formatted as tables.<prefix>_test_raw_outliers.csv/<prefix>_test_oof_outliers.csv/<prefix>_test_combined_outliers.csv— full per-compound outlier tables (raw AD metrics, per-metric outlier flags, and total flag counts) for the raw and OOF thresholding strategies.<prefix>_AD_test_results.xlsx— multi-sheet Excel workbook containing the combined outlier results and summaries.- Diagnostic plots (PCA score plots, fold disjointness, traffic-light validation plots), unless
generate_plots: falseis set in the config. <prefix>.log— full run log.
The YAML config accepts (per dataset entry under datasets:):
name,train_path,test_path,id_col,smiles_col,activity_coldescriptors(rdkitorfps),model(pca;plsis not supported for this workflow)n_components,alpha(percentile for AD thresholds)use_qsar,qsar_model(algorithm + params) orprediction_column(pre-computed predictions)cluster_analysis(enables clustered CV for OOF thresholds),cluster_algorithm(scaffoldsonly supported here),cluster_descriptors,n_clusters,n_splits,atc_levelgenerate_plots,quiet
See the example YAMLs in the repository for a complete reference.
Because raw intermediate result files and trained QSAR model archives are large, they are archived under a single Zenodo DOI rather than hosted directly in this GitHub repository. To reproduce all tables and figures from the manuscript locally from scratch, run the core pipeline across all benchmark endpoints and execute the post-processing scripts located in postprocessing/ from the root directory of the repository.
- Execute the master benchmark YAML configuration (
ad_final_cv_analysis_files.yaml) to generate per-endpoint outputs underresults/<ENDPOINT>/:
adtest -c run -cfg ad_final_cv_analysis_files.yaml -o results/- Create the aggregated directories expected by the post-processing scripts and gather the per-endpoint YAML reports and combined outlier CSVs:
mkdir -p results/final_analysis/yaml_dir
mkdir -p results/final_analysis/outlier_tables
mkdir -p results/final_analysis/figures
cp results/*/*.yaml results/final_analysis/yaml_dir/
cp results/*/*_test_combined_outliers.csv results/final_analysis/outlier_tables/Run the following scripts in order from the root directory of the package:
-
Aggregate Raw vs. OOF Coverage, Relative Risk (RR), and Enrichment Factor (EF):
python postprocessing/ad_ood_analysis.py
-
Reads:
results/final_analysis/yaml_dir/*.yaml -
Generates:
results/final_analysis/outlier_tables/ad_ood_comparison.csv(long-format table comparing%Outside,%ErrIn,%ErrOut,RR, andEFacross In-domain and Out-of-domain endpoints).
-
Reads:
-
Compute Threshold-Free ROC-AUC Metrics:
python postprocessing/ad_auc_analysis.py
-
Reads:
results/final_analysis/outlier_tables/*_test_combined_outliers.csvandad_ood_comparison.csv -
Generates:
results/final_analysis/outlier_tables/ad_auc_table.csvandad_full_comparison_with_auc.csv(addsAUC_flagcountand per-metric continuous ROC-AUCs).
-
Reads:
-
Generate Master Comparison Tables & Main Figures (Figures 1 & 2):
python postprocessing/generate_ad_figures.py
-
Reads:
results/final_analysis/yaml_dir/*.yamlandresults/final_analysis/outlier_tables/*_test_combined_outliers.csv -
Generates (in
results/final_analysis/figures/):-
ad_full_comparison_with_auc_mcc_f1.csv&ad_group_summary_final.csv(summary statistics with MCC and F1) -
fig1_per_metric_AUC_by_domain.png(horizontal bar chart of individual AD metric discriminative power) -
fig2A_group_summary_in_domain.png&fig2B_group_summary_ood.png(Mean ± SEM bar charts for%Outside,RR, andEF)
-
-
Reads:
-
Verify Chemical Domain Shift (
$S_{\mathrm{max}}$ Structural Overlap):python postprocessing/ad_domain_shift_proof.py
-
Reads:
ad_final_cv_analysis_files.yamland the raw training/test dataset files -
Generates (in
results/final_analysis/figures/):domain_shift_smax_values.csvandsupfig1_domain_shift_smax_boxplot.png(Mann–Whitney$U$ verification of Max Tanimoto similarity between In-domain and Out-of-domain benchmarks).
-
Reads:
-
Generate Per-Endpoint Dumbbell Shift Plots (Supplementary Figures 2–5):
python postprocessing/generate_dumbbell_plots.py
-
Reads:
results/final_analysis/figures/ad_full_comparison_with_auc_mcc_f1.csv -
Generates (in
results/final_analysis/figures/): 2-panel horizontal dumbbell plots showing Raw$\rightarrow$ OOF shifts per endpoint (supfig2_pctOutside_dumbbell.png,supfig3_RR_dumbbell.png,supfig4_EF_outside_dumbbell.png,supfig5_AUC_dumbbell.png).
-
Reads:
-
Extract Representative Compound Case Studies (AMES & AChE):
python postprocessing/extract_case_study_structures.py
-
Reads:
results/final_analysis/outlier_tables/(AMES and AChE outlier tables) and the AChE training set -
Generates:
results/final_analysis/AMES_case_studies_table_n6.xlsx,results/final_analysis/AChE_case_studies_table_n6.xlsx, and 2D molecular structure PNGs inresults/final_analysis/case_study_images/.
-
Reads: