https://github.com/genentech/perturb-ot
Cross-modality matching and prediction with labeled Gromov-Wasserstein Optimal Transport.
https://github.com/genentech/perturb-ot
Last synced: about 1 year ago
JSON representation
Cross-modality matching and prediction with labeled Gromov-Wasserstein Optimal Transport.
- Host: GitHub
- URL: https://github.com/genentech/perturb-ot
- Owner: Genentech
- License: other
- Created: 2024-04-18T23:53:14.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-06T16:14:05.000Z (about 2 years ago)
- Last Synced: 2024-05-06T17:36:55.270Z (about 2 years ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 38 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Perturb-OT
Cross-modality matching and prediction of **perturb**ation response with labeled Gromov-Wasserstein **O**ptimal **T**ransport.

## Repository layout
```
├── .gitignore
├── README.md
├── perturbot
│ ├── cv # Cross-validation experiments
│ └── perturbot
│ ├── match
│ │ ├── ot_labels.py # Label-constrained Entropic Optimal Transport
│ │ ├── ott_egwl.py # Label-constrained Entropic Gromov-Wasserstein
│ │ ├── cot_labels.py # Label-constrained Co-OT (Redko et al., 2020)
│ │ └── cot_feature.py # Feature-feature OT based on Co-OT concept
│ ├── predict
│ └── eval
├── scvi-tools # forked `scvi-tools` with label adaptation
└── ott # forked `ott` with label adaptation
```
## Installation
`perturbot/` uses the modified `scvi-tools` and `ott` submodules which can be installed with `pip install`.
```bash
cd scvi-tools/
pip install .
cd ../ott/
pip install .
cd ../perturbot
pip install .
```
## Usage
```python
import numpy as np
from sklearn.decomposition import PCA
from perturbot.match import (
get_coupling_cotl,
get_coupling_cotl_sinkhorn,
get_coupling_egw_labels_ott,
get_coupling_egw_all_ott,
get_coupling_eot_ott,
get_coupling_leot_ott,
get_coupling_egw_ott,
get_coupling_cot,
get_coupling_cot_sinkhorn,
get_coupling_gw_labels,
get_coupling_fot,
)
from perturbot.predict import train_mlp
# Generate data
n_samples = 300
labels = [0,1,2,3]
X_dict = {k: np.random.rand(n_samples,1000) for k in labels}
Y_dict = {k: np.random.rand(n_samples,2000) for k in labels}
pca = PCA(n_components=50)
X_reduced = {k: pca.fit_transform(X_dict[k]) for k in labels}
Y_reduced = {k: pca.fit_transform(Y_dict[k]) for k in labels}
# Learn matching in the latent space
T_dict, log = get_coupling_egw_labels_ott((X_reduced, Y_reduced)) # Other get_coupling_X methods be used
# Train MLP based on matching
model, pred_log = train_mlp((X_dict, Y_dict), T_dict)
# Learn feature-feature matching
T_feature, fm_log = get_coupling_fot((X_dict, Y_dict), T_dict)
```
See [documentation](https://genentech.github.io/Perturb-OT/) and [manuscript](https://arxiv.org/abs/2405.00838) for more details.
## Support
Please submit issues or reach out to jayoung_ryu@g.harvard.edu.
## Authors and acknowledgment
Jayoung Ryu, Romain Lopez, & Charlotte Bunne
## Citation
If you have used Perturb-OT for your work, please cite:
```
@misc{ryu2024crossmodality,
title={Cross-modality Matching and Prediction of Perturbation Responses with Labeled Gromov-Wasserstein Optimal Transport},
author={Jayoung Ryu and Romain Lopez and Charlotte Bunne and Aviv Regev},
year={2024},
eprint={2405.00838},
archivePrefix={arXiv},
primaryClass={q-bio.GN}
}
```