CUE (Chemical Uncertainty-aware Embedding) is a multi-modal molecular representation framework for drug selectivity prediction. CUE integrates molecular fingerprints and 2D molecular structure image embeddings, and combines them through Loss Trajectory Analysis for Uncertainty (LTAU)-based weighted fusion. The fusion weights are determined from modality-specific uncertainty, allowing the model to adaptively emphasize the more reliable modality for each molecule.
Create the Conda environment using the provided environment.yml file:
conda env create -f environment.yml
conda activate cueRequired: CUE uses the pretrained MolScribe encoder to extract molecular image features from 2D molecular structure images. Download the swin_base_char_aux_1m680k.pth checkpoint from the MolScribe repository, and place it at:
./cue/molscribe/ckpts/swin_base_char_aux_1m680k.pth
Run the 5-fold cross-validation pipeline with:
bash scripts/run.shDuring training, a logs directory is automatically created. Log files are organized by dataset name, target column, and experiment version.
logs/{DATA_NAME}/{TARGET_COL}/{VERSION}/{TARGET_COL}.log
After training, all output artifacts are saved under:
results/{DATA_NAME}/{TARGET_COL}/{VERSION}/CUE/
Details of output directory
results/DIS/PI/v1/CUE/
├── config.json # Training and evaluation configuration
├── predictions_all.csv # Test predictions concatenated across all five folds
├── metrics.csv # Cross-validation metrics summarized across folds
├── fold1/ # Fold-specific output directory
│ ├── predictions.csv # Test predictions for the current fold
│ ├── checkpoints/ # Modality-specific MLP checkpoints and feature scalers
│ │ ├── mlp_fp.pth # FP modality-specific MLP checkpoint
│ │ ├── mlp_img.pth # IMG modality-specific MLP checkpoint
│ │ ├── scaler_fp.pkl # Feature scaler fitted on FP features
│ │ └── scaler_img.pkl # Feature scaler fitted on IMG features
│ ├── ltau/ # LTAU estimator artifacts
│ │ ├── fp/ # FP-specific LTAU estimator directory
│ │ │ └── estimator.pkl # LTAU estimator for the FP modality
│ │ └── img/ # IMG-specific LTAU estimator directory
│ │ └── estimator.pkl # LTAU estimator for the IMG modality
│ ├── fusion/ # Sample-wise uncertainty and fusion outputs
│ │ ├── train_fusion.csv # Training-set uncertainty values, fusion weights, and losses
│ │ ├── va_fusion.csv # Validation-set uncertainty values, fusion weights, and losses
│ │ └── test_fusion.csv # Test-set uncertainty values, fusion weights, and losses
│ ├── emb/ # Unified embedding arrays
│ │ ├── train_emb.npy # Unified embeddings for the training set
│ │ ├── va_emb.npy # Unified embeddings for the validation set
│ │ └── test_emb.npy # Unified embeddings for the test set
│ └── regressors/ # Downstream selectivity regressor artifacts
│ ├── MLP.pth # Downstream MLP regressor checkpoint
│ ├── label_normalizer.pkl # Target label normalizer
│ └── loss_mlp.png # Training and validation loss curve of the downstream MLP
├── fold2/ # Same structure as fold1
├── fold3/ # Same structure as fold1
├── fold4/ # Same structure as fold1
└── fold5/ # Same structure as fold1
To predict selectivity scores for new molecules represented by SMILES strings, run:
bash scripts/predict.shThe prediction script loads the trained modality-specific MLP encoders, LTAU estimators, feature scalers, and downstream MLP regressor from the saved checkpoint directory.
The input file should be provided as a CSV file containing a SMILES column. An additional molecule identifier column, such as Compound, ID, or compound_chembl_id, may be included for tracking individual compounds. If no identifier column is provided, molecule identifiers are automatically assigned using the CID_{index} format.
compound_chembl_id,SMILES
CHEMBL10,C[S+]([O-])c1ccc(-c2nc(-c3ccc(F)cc3)c(-c3ccncc3)[nH]2)cc1
CHEMBL101253,Clc1ccc(Nc2nnc(Cc3ccncc3)c3ccccc23)cc1
CHEMBL103667,Cc1ccc(-n2nc(C(C)(C)C)cc2NC(=O)Nc2ccc(OCCN3CCOCC3)c3ccccc23)cc1The training dataset format includes additional selectivity target columns (e.g.,
PI,Ssel,WS2,RS2), but these are not required for prediction — only theSMILEScolumn is used.
Before running prediction, configure the following variables in scripts/predict.sh:
| Variable | Description |
|---|---|
INPUT_FILE |
Path to the input CSV file containing molecular SMILES strings |
SMILES_COL |
Name of the SMILES column in the input CSV file |
TARGET_COLS |
Selectivity metrics to predict; these should match the targets used during training |
DATA_NAMES |
Dataset name associated with the trained model, such as DIS or INH |
VERSION |
Experiment version corresponding to the trained checkpoint |
MODEL_NAME |
Model directory name; the default value is CUE |
OUTPUT_BASE |
Output directory for saving prediction results |
DEVICE |
Computing device used for inference, such as cuda:0 or cpu |
SPECIFIC_FOLD |
Optional argument for performing prediction with a single fold checkpoint |
For each (DATA_NAME, TARGET_COL) pair, the prediction script generates one CSV file:
prediction_{DATA_NAME}_{TARGET_COL}_{VERSION}_{MODEL_NAME}.csv
The output file contains the predicted selectivity scores for the input molecules, together with fold-wise predictions, modality-specific uncertainty values (u_fp, u_img), and modality fusion weights (w_fp, w_img).
Description of training configuration
Training and evaluation settings are defined in scripts/run.sh.
| Parameter | Default Value | Description |
|---|---|---|
VERSION |
"v1" |
Experiment version identifier |
TARGET_COLS |
("PI" "Ssel" "WS2" "RS2") |
Selectivity metrics used as prediction targets |
DATA_NAMES |
("DIS" "INH") |
Dataset names used for training and evaluation |
LABEL_MODE |
"none" |
Label normalization method: zscore, robust, minmax, or none |
DEVICE |
"cuda:0" |
Computing device |
SEED |
2025 |
Random seed for reproducibility |
| Parameter | Default Value | Description |
|---|---|---|
LTAU_K |
5 |
Number of nearest neighbors used for LTAU-based uncertainty estimation |
LTAU_BINS |
5000 |
Number of histogram bins used to construct empirical error distributions |
TEMPERATURE |
1.0 |
Optional temperature parameter for uncertainty-to-weight scaling |
| Parameter | Default Value | Description |
|---|---|---|
HIDDEN_DIM |
32 |
Latent embedding dimension of each modality-specific MLP |
NUM_EPOCHS |
1000 |
Number of pretraining epochs |
LEARNING_RATE |
1e-4 |
Learning rate for modality-specific MLP pretraining |
BATCH_SIZE |
256 |
Batch size for modality-specific MLP pretraining |
SAVE_EVERY |
1 |
Checkpoint and trajectory save interval |
| Parameter | Default Value | Description |
|---|---|---|
REG_HIDDEN_DIM_1 |
16 |
First hidden layer dimension of the downstream MLP |
REG_HIDDEN_DIM_2 |
16 |
Second hidden layer dimension of the downstream MLP |
REG_HIDDEN_DIM_3 |
8 |
Third hidden layer dimension of the downstream MLP |
REG_NUM_EPOCHS |
500 |
Number of downstream regressor training epochs |
REG_LEARNING_RATE |
1e-3 |
Learning rate for the downstream MLP regressor |
REG_BATCH_SIZE |
256 |
Batch size for downstream regressor training |
REG_SAVE_EVERY |
1 |
Checkpoint save interval for the downstream MLP |
Variables
| Variable / Path | Paper Notation | Description |
|---|---|---|
mlp_fp |
Modality-specific MLP for the FP modality | |
mlp_img |
Modality-specific MLP for the IMG modality | |
X, X_tr, X_va, X_te
|
|
Molecular input sets represented by SMILES strings |
y, y_tr, y_va, y_te
|
Selectivity score vectors | |
raw_fp |
— | Raw molecular fingerprint feature vector |
raw_img |
— | Raw molecular image feature vector |
emb_fp |
FP modality-specific embedding | |
emb_img |
IMG modality-specific embedding | |
uni, uni_tr, uni_va, uni_te
|
Unified embedding obtained by uncertainty-aware fusion | |
W, W_tr, W_va, W_te
|
Modality fusion weights | |
u, u_tr, u_va, u_te
|
Modality-specific uncertainty values | |
loss_trajectories |
Sample-wise loss trajectories collected during modality-specific MLP training | |
loss_trajectory_i |
Loss trajectory of sample |
|
sample_error |
Prediction error of sample |
|
shared_bin_edges |
Shared histogram bin edges used for empirical error distribution construction | |
reference_pdfs |
Reference empirical error distributions | |
reference_embeddings |
Reference embeddings used for nearest-neighbor search | |
neighbor_indices |
Indices of the k-nearest reference embeddings for query molecule |
|
neighbor_ref_pdf |
Reference empirical error distributions associated with the nearest neighbors | |
query_pdf |
Aggregated empirical error distribution for a query molecule |
- Jin Hyuk Kim
- Gyeong Hwan Kim
- Hyeon Jun Park
- Jonghwan Choi
For questions or issues, please contact:
- Email: rlawlsgurjh@gmail.com