{"id":21280587,"url":"https://github.com/borgwardtlab/conformalamr","last_synced_at":"2025-03-15T14:11:43.826Z","repository":{"id":259629075,"uuid":"879069158","full_name":"BorgwardtLab/ConformalAMR","owner":"BorgwardtLab","description":"Main repository for \"Antimicrobial drug recommendation from MALDI-TOF MS with statistical guarantees using conformal prediction\"","archived":false,"fork":false,"pushed_at":"2024-11-05T17:38:53.000Z","size":18821,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T04:14:00.772Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BorgwardtLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-26T22:07:41.000Z","updated_at":"2024-11-05T17:38:59.000Z","dependencies_parsed_at":"2024-11-21T10:47:23.365Z","dependency_job_id":null,"html_url":"https://github.com/BorgwardtLab/ConformalAMR","commit_stats":null,"previous_names":["borgwardtlab/conformalamr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FConformalAMR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FConformalAMR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FConformalAMR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FConformalAMR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BorgwardtLab","download_url":"https://codeload.github.com/BorgwardtLab/ConformalAMR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243738987,"owners_count":20340002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T10:37:14.918Z","updated_at":"2025-03-15T14:11:43.809Z","avatar_url":"https://github.com/BorgwardtLab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConformalAMR\n\nThis repository contains the code used to conduct experiments presented in the paper _Antimicrobial drug recommendation from MALDI-TOF mass spectrometry with statistical guarantees using conformal prediction_, by Nina Corvelo Benz, Lucas Miranda, Dexiong Chen, Janko Sattler, and Karsten Borgwardt.\n\n### Abstract\n\nAntimicrobial resistance (AMR) is a global health challenge, complicating the treatment of\nbacterial infections and leading to higher patient morbidity and mortality. Rapid and reliable identification of resistant pathogens is crucial to guide early and effective therapeutic interventions. However, traditional culture-based methods are time-consuming, highlighting the need for faster predictive approaches. Machine learning models trained on MALDI-TOF mass spectrometry data, readily collected\nin most clinics for fast species identification, offer promise but face limitations in clinical applicability, particularly due to their lack of comprehensive, statistically valid uncertainty estimates. Here, we introduce a novel AMR prediction framework that addresses this gap with a novel knowledge graphenhanced conformal predictor. Conformal prediction (CP) constructs prediction sets with statistical\ncoverage guarantees, ensuring that bacterial resistance to a certain antibiotic is flagged with a specified\nerror rate. \n\n![Conformal framework](images/pipeline.png \"Conformal prediction pipeline.\")\n\nOur proposed conformal predictor constructs improved prediction sets over standard CP approaches by using a knowledge graph capturing the interdependencies in antibiotic resistance patterns.\n\n![Conformal performance](images/conformal.png \"Our knowledge-graph-enhanced conformal predictor leads to a lower FDR than non-enhanced baselines for a fixed confidence score.\")\n\nIn addition, we introduce a novel classifier framework that improves upon previous multimodal models by incorporating multigraph-based antibiotic representations using state-of-the-art self-supervised\nmethods. Besides increasing resistance detection for most tested species-drug combinations, the presented architecture, termed ResMLP-GNN, overcomes the limitations of previous efforts and supports\nmulti-drug antibiotics that are highly relevant in clinical practice. We successfully evaluated our approach on a set of highly-relevant antibiotics, commonly used in clinics to treat infections with Klebsiella pneumoniae and Escherichia coli\n\n![ROC and PR curves](images/curves.png \"ResMLP-GNN reaches SOTA performance when predicting antimicrobial resistance from MALDI-TOF and drug structure.\")\n\n### Installation\n\nWe provide `pyproject.toml` and `poetry.lock` files for reproducible installation of the environment used in our experiments using [poetry](https://python-poetry.org/). We recommend doing this within a conda/mamba isolated environment, running `Python^=3.11`. To install the environment, just run the following commands (assuming you have poetry up and running):\n\n```bash\n\nmamba create -n ConformalAMR python=3.11\npoetry install\n\n```\n\nThis should install both the required dependencies, and the conformal_amr package as such.\n\n### Training base ResAMR-GNN models\n\nTo train the base ResAMR-GNN models, you can run the following command:\n\n```bash\n\npoetry run python scripts/train_ResAMR_classifier.py --driams_dataset A --driams_long_table data/DRIAMS_combined_long_table_multidrug.csv --drugs_df data/DRIAMS_Mole-BERT_drug_embeddings.csv --spectra_matrix path/to/spectra/DRIAMS-A/spectra_binned_6000_all_multidrug.npy --output_folder results\n\n```\n\nWhere `A` can be replaced by `B` or `C` or `D` to train on the respective DRIAMS datasets, and the spectra matrix is generated using the `notebooks/Process_DRIAMS_data.ipynb.py` notebook, upon downloading the DRIAMS dataset.\n\n### Finetuning ResMLP-GNN models\n\nTo finetune a base ResMLP-GNN model on a fixed species-drug combination, you can run the following command:\n\n```bash\n\npoetry run python scripts/finetune_ResAMR_classifier.py --pretrained_checkpoints_folder /path/to/pretrained/base/models --driams_dataset A --driams_long_table data/DRIAMS_combined_long_table_multidrug.csv --drugs_df data/DRIAMS_Mole-BERT_drug_embeddings.csv --spectra_matrix path/to/spectra/DRIAMS-A/spectra_binned_6000_all_multidrug.npy --splits_file path/to/splits/file --n_epochs 150 --output_folder results --species_drug_combination 'Escherichia coli_Ceftriaxone' --freeze_drug_emb\n    \n```\n\nWhere `A` can be replaced by `B` or `C` or `D` to train on the respective DRIAMS datasets, the pretrained checkpoints and the splits files are generated after training the base models, and 'Escherichia coli_Ceftriaxone' can be replaced by any other species-drug combination of interest.\n\n### Evaluating the conformal predictor described in the paper\n\nTo evaluate knowledge-graph enhanced conformal predictor with the hyperparameters described in the paper, you can simply run:\n\n```bash\n\npoetry run python scripts/evaluate_conformal.py\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborgwardtlab%2Fconformalamr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborgwardtlab%2Fconformalamr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborgwardtlab%2Fconformalamr/lists"}