{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/contrastive-mixture-of-posteriors-for","title":"Contrastive Mixture of Posteriors for Counterfactual Inference, Data Integration and Fairness","arxiv_id":"2106.08161","date":"2021-06-15","proceeding":"NeurIPS 2021 12","authors":["Adam Foster","Árpi Vezér","Craig A Glastonbury","Páidí Creed","Sam Abujudeh","Aaron Sim"],"abstract":"Learning meaningful representations of data that can address challenges such as batch effect correction and counterfactual inference is a central problem in many domains including computational biology. Adopting a Conditional VAE framework, we show that marginal independence between the representation and a condition variable plays a key role in both of these challenges. We propose the Contrastive Mixture of Posteriors (CoMP) method that uses a novel misalignment penalty defined in terms of mixtures of the variational posteriors to enforce this independence in latent space. We show that CoMP has attractive theoretical properties compared to previous approaches, and we prove counterfactual identifiability of CoMP under additional assumptions. We demonstrate state-of-the-art performance on a set of challenging tasks including aligning human tumour samples with cancer cell-lines, predicting transcriptome-level perturbation responses, and batch correction on single-cell RNA sequencing data. We also find parallels to fair representation learning and demonstrate that CoMP is competitive on a common task in the field.","url_abs":"https://arxiv.org/abs/2106.08161v4","url_pdf":"https://arxiv.org/pdf/2106.08161v4.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"contrastive-mixture-of-posteriors-for","repo_url":"https://github.com/benevolentai/comp","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"counterfactual-inference","task_name":"Counterfactual Inference"},{"task_slug":"data-integration","task_name":"Data Integration"},{"task_slug":"fairness","task_name":"Fairness"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":null,"task_name":"counterfactual"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2106.08161","atlas_url":"https://app.syntology.ai/?focus=2106.08161","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2106.08161"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/BenevolentAI/CoMP","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/benevolentai/comp","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":1,"ran_draft_wrong":1,"unverified":9},"by_repo_kind":{"official":{"samples":11,"ran":2,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"4998f98685b3316e","entry":"COMP","repo":"benevolentai/comp","repo_kind":"official","path":"comp/pl/comp.py","file_url":"https://github.com/benevolentai/comp/blob/HEAD/comp/pl/comp.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4998f98685b3316e"}},{"code_sha256_prefix":"2b0137d425c7aa5a","entry":"pairwise_label_mask","repo":"benevolentai/comp","repo_kind":"official","path":"comp/pl/comp.py","file_url":"https://github.com/benevolentai/comp/blob/HEAD/comp/pl/comp.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2b0137d425c7aa5a"}},{"code_sha256_prefix":"668862ba4850b32a","entry":"calc_input_dims","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/nn/utils.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/nn/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"668862ba4850b32a"}},{"code_sha256_prefix":"bac34fce94abe980","entry":"compute_mmd","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/metrics.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/metrics.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bac34fce94abe980"}},{"code_sha256_prefix":"559e347a0c942932","entry":"create_trainer","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/pl/trainer.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/pl/trainer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"559e347a0c942932"}},{"code_sha256_prefix":"465676336daf89fe","entry":"get_umap_params","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/metric_handlers.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/metric_handlers.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"465676336daf89fe"}},{"code_sha256_prefix":"b72cee35d4fa12ca","entry":"knn_metric","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/metrics.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/metrics.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b72cee35d4fa12ca"}},{"code_sha256_prefix":"3c7fe7b3de9552ce","entry":"make_subset_penalty_v2","repo":"benevolentai/comp","repo_kind":"official","path":"comp/pl/comp.py","file_url":"https://github.com/benevolentai/comp/blob/HEAD/comp/pl/comp.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3c7fe7b3de9552ce"}},{"code_sha256_prefix":"6af69a37e94494a8","entry":"mmd","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/nn/loss.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/nn/loss.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6af69a37e94494a8"}},{"code_sha256_prefix":"90dbb0df2db2c052","entry":"predict","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/metric_handlers.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/metric_handlers.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"90dbb0df2db2c052"}},{"code_sha256_prefix":"71f33c01ffedd50d","entry":"silhouette_coeff","repo":"BenevolentAI/CoMP","repo_kind":"official","path":"comp/metrics.py","file_url":"https://github.com/BenevolentAI/CoMP/blob/HEAD/comp/metrics.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"71f33c01ffedd50d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}