Skip to main content

Extension of the Monge Gap to learn conditional optimal transport maps

Project description

Conditional Monge Gap

CI License: MIT

An extension of the Monge Gap, an approach to estimate transport maps conditionally on arbitrary context vectors. It is based on a two-step training procedure combining an encoder-decoder architecture with an OT estimator. The model is applied to 4i and scRNA-seq datasets.

Installation from PyPI

You can install this package as follows

pip install cmonge

Development setup & installation

The package environment is managed by poetry. The code was tested in Python 3.10.

pip install poetry
git clone git@github.com:AI4SCR/conditional-monge.git
cd cmonge
poetry install -v

If the installation was successful you can run the tests using pytest

poetry shell # activate env
pytest

Data

The preprocessed version of the Sciplex3 and 4i datasets can be downloaded here.

Example usage

You can find example config in configs/conditional-monge-sciplex.yml. To train an autoencoder model:

from cmonge.datasets.conditional_loader import ConditionalDataModule
from cmonge.trainers.ae_trainer import AETrainerModule
from cmonge.utils import load_config


config_path = Path("configs/conditional-monge-sciplex.yml")
config = load_config(config_path)
config.data.ae = True

datamodule = ConditionalDataModule(config.data, config.condition)
ae_trainer = AETrainerModule(config.ae)

ae_trainer.train(datamodule)
ae_trainer.evaluate(datamodule)

To train a conditional monge model:

from cmonge.datasets.conditional_loader import ConditionalDataModule
from cmonge.trainers.conditional_monge_trainer import ConditionalMongeTrainer
from cmonge.utils import load_config

config_path = Path("configs/conditional-monge-sciplex.yml")
logger_path = Path("logs")
config = load_config(config_path)

datamodule = ConditionalDataModule(config.data, config.condition)
trainer = ConditionalMongeTrainer(jobid=1, logger_path=logger_path, config=config.model, datamodule=datamodule)

trainer.train(datamodule)
trainer.evaluate(datamodule)

Older checkpoints loading

If you want to load model weights of older checkpoints (cmonge-{moa, rdkit}-ood or cmonge-{moa, rdkit}-homogeneous), make sure you are on the tag cmonge_checkpoint_loading.

git checkout cmonge_checkpoint_loading

Citation

If you use the package, please cite:

@inproceedings{
  harsanyi2024learning,
  title={Learning Drug Perturbations via Conditional Map Estimators},
  author={Benedek Harsanyi and Marianna Rapsomaniki and Jannis Born},
  booktitle={ICLR 2024 Workshop on Machine Learning for Genomics Explorations},
  year={2024},
  url={https://openreview.net/forum?id=FE7lRuwmfI}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmonge-0.1.1.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmonge-0.1.1-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file cmonge-0.1.1.tar.gz.

File metadata

  • Download URL: cmonge-0.1.1.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

File hashes

Hashes for cmonge-0.1.1.tar.gz
Algorithm Hash digest
SHA256 87ac63dd3e4720b1f00b5affd7cfb8d95d546add6c7e3265fc3bcf78d1c24a22
MD5 f89c9d38313358aa68efabfe66ec000a
BLAKE2b-256 c92887a4ddf375dfe1dc25948d7f88672179d83e8a8c8b46bc1972719eb4653a

See more details on using hashes here.

File details

Details for the file cmonge-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cmonge-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

File hashes

Hashes for cmonge-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d6b3e46d6f9dfa374feeedcf68c6a6fde0e5490a5115081c403b9261fcc0900
MD5 c3869d7c59b04942d1c053296d2a6523
BLAKE2b-256 aabda4022753103c6301dc0fc8bf52771fbd63a17824b1bda63cbefc73d6765c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page