Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Can phenotypic activity be predicted without experimental readouts?

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.

Layout

.
├── 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.

Environment

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).

Before running

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.

Data prerequisites

  • 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's download_data.sh). The first run computes TVN from it (~20-25 min) and caches the result to data/_bbbc_tvn_wells_nocellcount.parquet.
  • Everything else is downloaded automatically: the official BBBC036v1 train/validation/test split from the suinleelab/CellCLIP Hugging 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 to data/ after the first run.

Running the notebooks

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.

  1. 01_prepare_bbbc036v1.ipynb — builds data/bbbc036v1_standardized.parquet: TVN-corrected, compound-level morphology and the is_active / is_active_and_toxic / is_active_not_toxic labels from copairs permutation tests. The slow part is TVN (~20-25 min without the cache); the permutation tests are cached under data/_bbbc_*_null_cache/.
  2. 02_prepare_jumpcp.ipynb — builds data/jumpcp_standardized.parquet the same way, using JUMP-RR's published activity p-values and computing toxicity ourselves. It also splits off source_7, a curated bioactive library screened at 0.625 µM instead of 10 µM, into data/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.
  3. 03_train_and_compare_bbbc036v1.ipynb, 03_train_and_compare_jumpcp.ipynb and 03_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. Writes results/{dataset}/. Morphology and CellCount are 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.
  4. 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. Draws plot5_activity_assessment (mAP vs corrected p-value for both datasets, as in the copairs paper), 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 and source_7's cross-validation splits; these are the lighter bars in plot2 and plot4. 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). Writes results/activity_sensitivity/. Takes ~2 h, mostly the JUMP-CP CV.
  5. 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. Writes results/toxicity_sensitivity/. Takes ~45 min.
  6. 06_physchem_descriptor_importance.ipynb — what the PhysChem model relies on. Draws plot6_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.
  7. 07_plots_and_tables.ipynb — draws plot1 to plot4 and tables/table1_consolidated.tex from the CSVs of notebooks 3 and 4. In plot2 and plot4 each representation has three bars, for activity at q < 0.05 (the main results), 0.01 and 0.001. Takes seconds.
  8. 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 in plot7_probe_comparison. Writes results/splits_and_probes/. Takes ~1-1.5 h, mostly the JUMP-CP CV.

Regenerating the figures only

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.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages