Skip to main content

MCC: Momentum Contrastive Coupling

PyPI DOI Project page License: MIT

Project page: https://peterponyu.github.io/MCCVAE/

Publication status: Published in Biomedical Signal Processing and Control.

Fu, Z., Chen, C., Zhang, K. (2026). Islands and bridges: Momentum contrastive coupling unifies discrete and continuous structure in single-cell omics. Biomedical Signal Processing and Control, 122, 110376. DOI · ScienceDirect

MCC is a deep learning framework for single-cell genomics analysis. It combines a Momentum Contrastive (MoCo) module with an information-bottleneck coupling within a Variational Autoencoder (VAE) framework.

Features

  • Momentum Contrastive Learning: Uses MoCo with InfoNCE loss, momentum-updated encoders, and memory queues for contrastive representation learning.
  • Information Bottleneck Coupling: Compresses and refines latent codes through a low-dimensional bottleneck layer.
  • Dual Reconstruction Pathways: Two reconstruction paths - direct from primary latent representation and through the information bottleneck.
  • Multiple Modalities: Supports scRNA-seq and scATAC-seq data.

Installation

Install the package from PyPI:

pip install mccvae
# benchmark metrics and graph baselines
pip install "mccvae[all]"

To run the web interface, install from source:

  1. Clone the repository:
    git clone https://github.com/PeterPonyu/MCCVAE.git
    cd MCCVAE
    
  2. Install the required dependencies:
    pip install -r requirements.txt
    

UI

Visualization training

python start_servers.py

Usage

Use the Agent class to train models and extract latent representations.

import scanpy as sc
from mccvae import Agent

# Load data
adata = sc.read_h5ad("your_data.h5ad")

# Initialize agent
agent = Agent(
    adata=adata,
    layer="counts",
    latent_dim=10,
    use_moco=True,
    irecon=1.
)

# Train
agent.fit(epochs=1000)

# Extract representations
latent_representations = agent.get_latent()       # Shape: (n_cells, latent_dim)
bottleneck_embeddings = agent.get_bottleneck()    # Shape: (n_cells, i_dim)
refined_embeddings = agent.get_refined()          # Shape: (n_cells, latent_dim)

Embeddings:

  • get_latent(): Primary latent representations (z) with dimension latent_dim
  • get_bottleneck() or get_iembed(): Compressed bottleneck (l_e) with dimension i_dim
  • get_refined(): Refined representations (l_d) with dimension latent_dim

Architecture

The framework consists of three components:

VAE Backbone

  • Query Encoder: Maps input to latent representation z
  • Decoder: Reconstructs data from latent representations
  • Loss: Negative binomial reconstruction + KL divergence

MoCo Component

  • Momentum Encoder: Parameters updated via exponential moving average
  • Memory Queue: FIFO mechanism for negative samples
  • InfoNCE Loss: Contrastive loss with L2-normalized embeddings

Coupling Component

  • Information Bottleneck: z → l_e → l_d pathway
    • l_e: Compressed representation via bottleneck_encoder (dimension: i_dim)
    • l_d: Refined representation via bottleneck_decoder (dimension: latent_dim)
  • Secondary Reconstruction: Reconstruction through l_d

Loss Function

The MCC objective combines four loss components:

L_MCC = L_NB + β·L_KLD + α·L_MoCo + γ·L_Cou
  • L_NB: Negative binomial reconstruction loss (z → reconstruction)
  • L_KLD: KL divergence regularization
  • L_MoCo: InfoNCE contrastive loss
  • L_Cou: Coupling reconstruction loss (z → l_e → l_d → reconstruction)

Citation

If you use MCCVAE, please cite:

@article{fu2026islands,
  title = {Islands and bridges: Momentum contrastive coupling unifies discrete and continuous structure in single-cell omics},
  author = {Fu, Zeyu and Chen, Chunlin and Zhang, Keyang},
  journal = {Biomedical Signal Processing and Control},
  volume = {122},
  pages = {110376},
  year = {2026},
  doi = {10.1016/j.bspc.2026.110376}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for mccvae 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mccvae 0.0.2
File Size Uploaded Provenance Actions
mccvae-0.0.2.tar.gz 106.4 kB With provenance Details for mccvae-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mccvae 0.0.2
File Interpreter ABI Platform Actions
mccvae-0.0.2-py3-none-any.whl Python 3 none any Details for mccvae-0.0.2-py3-none-any.whl

Total release size: 241.6 kB

Release files / mccvae-0.0.2.tar.gz

Download URL mccvae-0.0.2.tar.gz
Size 106.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3dfb52566a74e65089cfa783b576043452e9060ef0760d45912b058bac2eb420
BLAKE2b-256 checksum
How to use checksums
4de40ea3e9350e1a80a0e3b18f0b396adf7bb05b2c03b68fd4a35b69b25e3481
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / mccvae-0.0.2-py3-none-any.whl

Download URL mccvae-0.0.2-py3-none-any.whl
Size 135.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbf20a97faa75806792dc6ab714338bcea06b195ad7d7915c42a5c3176dd9d9b
BLAKE2b-256 checksum
How to use checksums
925de077912e045688a202f6ff06b2760f1719d7fe387422f8cc5bd9c36c81b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for mccvae 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mccvae-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page