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.

Environment setup

The environment is managed with poetry. We recommend setting up a virtual environment. The code was tested in Python 3.10.

pip install poetry
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)

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.0.1.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

cmonge-0.0.1-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cmonge-0.0.1.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.6.0

File hashes

Hashes for cmonge-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5683cf63558f7a70770b495b6334f60687263b93069a3a4203b645b2bd8afd0b
MD5 63738c2d932725fe1ad4a5cd3c980bf0
BLAKE2b-256 d6fe88177785ef4fec60788458f11b35a67d3d2da991c27c1cc13b4b619a3107

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cmonge-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 39.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.6.0

File hashes

Hashes for cmonge-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 565121b63940590b01bc85ae22b4878b7abcf9bf63dd1eb7529355db8aaf7113
MD5 aa0c251a8458c252184b42f15204fe74
BLAKE2b-256 5c4f887f3f596dc21d8de34d91867c7c318fe750458c04a13d98e5623a78689a

See more details on using hashes here.

Supported by

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