Code for the paper Can phenotypic activity be predicted without experimental readouts? (arXiv:2610.07997; ML4Molecules workshop, NeurIPS 2026).
We test whether molecular encoders pretrained on Cell Painting data (CLOOME, CellCLIP) predict
phenotypic activity better than simple structure-based representations, while controlling for two
confounds: test compounds the encoders already saw during pretraining, and activity that is really
just cytotoxicity. The analysis covers two Cell Painting screens, BBBC036v1 and JUMP-CP, plus
JUMP-CP's source_7 bioactive library as a third, independent population.
.
├── notebooks/ 01-08, run in order (see below)
├── data/ raw inputs, standardized tables and caches (created on first run, not tracked)
├── results/ one folder per dataset (notebook 3) and per follow-up analysis (notebooks 4-6, 8)
├── figures/ plots from notebooks 4, 6, 7 and 8
├── tables/ LaTeX table from notebook 7
├── plot_style.py shared matplotlib style
└── environment.yml
The paper itself is not included here; see arXiv:2610.07997.
conda env create -f environment.yml
conda activate chemical-surrogate-limits
environment.yml pins the versions the pipeline was last run with (python=3.10,
rdkit=2025.03.3, pytorch=2.8.0, copairs=0.5.5, ...). The RDKit version matters: PhysChem uses
the full Descriptors._descList, which has 217 descriptors in 2025.03 but 210 in older releases.
No GPU is needed. The main pipeline (notebooks 1-3 and 7, from raw data to the main results) runs in a couple of hours on a laptop; the slowest single step is CellCLIP's embedding on CPU (see below).
Run the notebooks from inside notebooks/ (Jupyter's default when you open them there): they find
the repository root from their working directory, so no paths need editing. All inputs, caches and
standardized tables go to data/.
Notebook 3 computes the CLOOME and CellCLIP embeddings itself from the public checkpoints
(anasanchezf/cloome and suinleelab/CellCLIP on Hugging Face) and caches them to
data/_{dataset}_cloome_cache.parquet and data/_{dataset}_cellclip_cache.parquet. This needs
internet access the first time, and CellCLIP's BERT encoder takes tens of minutes on CPU for
JUMP-CP's ~24k compounds. Caches found under outputs/full_pipeline/ are used instead if present.
- BBBC036v1 well-level profiles: notebook 1 expects
data/train_set_30kcpds_normalized_profiles.csv.gz(Bray et al.'s ~30,000-compound Cell Painting screen, CellProfiler features, ~2 GB). It is not downloaded automatically: get it from the CPMolGAN Google Drive folder (or with CPMolGAN'sdownload_data.sh). The first run computes TVN from it (~20-25 min) and caches the result todata/_bbbc_tvn_wells_nocellcount.parquet. - Everything else is downloaded automatically: the official BBBC036v1 train/validation/test
split from the
suinleelab/CellCLIPHugging Face repo (notebooks 1-2), JUMP-RR's corrected activity p-values from Zenodo and JUMP-CP profiles and metadata from the Cell Painting Gallery S3 bucket (notebook 2), and the CLOOME and CellCLIP checkpoints (notebook 3). Everything is cached todata/after the first run.
Run them in numeric order. Each notebook writes its outputs to disk, so any of them can be rerun on its own once its inputs exist.
01_prepare_bbbc036v1.ipynb— buildsdata/bbbc036v1_standardized.parquet: TVN-corrected, compound-level morphology and theis_active/is_active_and_toxic/is_active_not_toxiclabels fromcopairspermutation tests. The slow part is TVN (~20-25 min without the cache); the permutation tests are cached underdata/_bbbc_*_null_cache/.02_prepare_jumpcp.ipynb— buildsdata/jumpcp_standardized.parquetthe same way, using JUMP-RR's published activity p-values and computing toxicity ourselves. It also splits offsource_7, a curated bioactive library screened at 0.625 µM instead of 10 µM, intodata/jumpcp_bioactive_standardized.parquet, so that it does not mix into the main population's batch split. Downloads JUMP-CP profiles from S3, so it is the longest notebook on a slow connection.03_train_and_compare_bbbc036v1.ipynb,03_train_and_compare_jumpcp.ipynband03_train_and_compare_jumpcp_bioactive.ipynb— the main experiment, one notebook per population. Computes the CLOOME and CellCLIP embeddings, builds the chemical split (Butina clustering on Tanimoto distance) and the batch split, runs 5×5 repeated grouped cross-validation (plus the official split for BBBC036v1) for every representation and target, and compares representations with a repeated-measures Tukey HSD. Writesresults/{dataset}/.MorphologyandCellCountare computed too, for reference; the paper compares six representations: PhysChem, LogP, MorganFP, CLOOME, CellCLIP and the not-pretrained MLP. This is the slowest step: about 45-50 min for BBBC036v1's cross-validation, longer for JUMP-CP.04_activity_label_sensitivity.ipynb— why 91.3% of BBBC036v1 is called active, against about 11% of JUMP-CP, and whether the results hold with stricter activity labels. Drawsplot5_activity_assessment(mAP vs corrected p-value for both datasets, as in thecopairspaper), then refits the six representations with activity at q < 0.01 and q < 0.001 (toxicity unchanged) on BBBC036v1's official split and on JUMP-CP's andsource_7's cross-validation splits; these are the lighter bars inplot2andplot4. Also saves, as data only, a null-size sweep and a DMSO calibration. Needs the raw BBBC036v1 CSV for one TVN refit (~35 min the first time, then cached). Writesresults/activity_sensitivity/. Takes ~2 h, mostly the JUMP-CP CV.05_toxicity_label_sensitivity.ipynb— how the cell-count toxicity proxy behaves: how many toxic calls are cell-count decreases, how many actives are called toxic at q < 0.05 / 0.01 / 0.001, and the representation comparison with toxicity at those thresholds (BBBC036v1 official split, JUMP-CP chemical-split CV). Numbers only, no figure. Writesresults/toxicity_sensitivity/. Takes ~45 min.06_physchem_descriptor_importance.ipynb— what the PhysChem model relies on. Drawsplot6_physchem_descriptors: the same probe on a growing set of interpretable descriptors (LogP;- size; + polarity and H-bonding; + basic amines) against all 217. Also saves per-family results,
coefficients and hit rates by LogP and basic amines. Writes
results/physchem_descriptors/. Takes ~10 min.
- size; + polarity and H-bonding; + basic amines) against all 217. Also saves per-family results,
coefficients and hit rates by LogP and basic amines. Writes
07_plots_and_tables.ipynb— drawsplot1toplot4andtables/table1_consolidated.texfrom the CSVs of notebooks 3 and 4. Inplot2andplot4each representation has three bars, for activity at q < 0.05 (the main results), 0.01 and 0.001. Takes seconds.08_split_characterization_and_nonlinear_probes.ipynb— two checks. First, BBBC036v1's official, chemical and plate splits compared train vs test (nearest-neighbour Tanimoto similarity, label prevalence, LogP / molecular weight / TPSA). Second, notebook 3's MLP trained on the frozen CLOOME, CellCLIP and PhysChem representations instead of a linear probe, drawn inplot7_probe_comparison. Writesresults/splits_and_probes/. Takes ~1-1.5 h, mostly the JUMP-CP CV.
The result CSVs are included, so the figures and table can be redrawn without rerunning the
analysis. Notebook 7 draws plot1-plot4 and the table from results/, and the last section of
notebook 8 draws plot7 from results/splits_and_probes/linear_vs_mlp_probe.csv. plot5 and
plot6 (notebooks 4 and 6) need the data/ tables.