Skip to main content

CLOP-DiT

Structured-metadata-conditioned single-cell latent generation via contrastive language–omics pretraining and diffusion transformers.

PyPI DOI

CLOP-DiT is a three-stage pipeline that samples single-cell expression embeddings conditioned on a structured five-field text prompt (cell type, tissue, organism, marker genes, disease context). The first stage is a prototype-aware contrastive aligner that maps frozen BiomedBERT text embeddings and frozen scGPT cell embeddings into a shared 512-dimensional latent space. The second stage is a 1-D Diffusion Transformer trained with conditional flow matching and classifier-free guidance, which samples a latent vector from a Gaussian prior toward the conditioned region of that space. The third stage is the frozen scGPT decoder, used to map the generated latent back to per-gene expression for downstream inspection.

The training corpus is 220,304 cells from 80 publicly available Gene Expression Omnibus (GEO) datasets, deduplicated to 69 evaluation cell types covering human and mouse tumour-microenvironment and developmental contexts.

Reported results

The headline metrics, evaluated on 69 deduplicated cell types:

Method KNN-1 Steering DivR LinAcc
Real data 0.890 – 1.000 0.942
CLOP-DiT, high-fidelity setting (CFG = 2.0) 0.369 0.810 0.513 0.511
CLOP-DiT, high-diversity setting (CFG = 1.0) 0.288 0.807 0.929 0.357
Embedding-VAE baseline 0.112 0.547 0.744 0.189
Gaussian baseline 0.011 0.466 2.277 0.009

KNN-1 is reported over the 69-class problem with random chance ≈ 0.0145; CLOP-DiT at CFG = 2.0 is therefore about 25× above random. DivR ideal = 1.0.

The reported strength of CLOP-DiT is controllable structured-metadata-conditioned generation. The reported limitations are that within-type variance and gene–gene correlation are only weakly preserved, and that a Gaussian mean-matching baseline outperforms CLOP-DiT on the nine shared distributional metrics.

Installation

The model code is published on PyPI as clop-dit; the import name is clop_dit.

pip install clop-dit

The training, inference and figure scripts live in this repository. To run them, install from a clone; the code targets Python 3.10 and the full dependency list is in requirements.txt.

conda create -n clopdit python=3.10
conda activate clopdit
pip install -e .

The training and evaluation experiments were carried out with PyTorch 2.1, CUDA 12.0, scGPT v0.2.1, and Hugging Face Transformers 4.36 on a single NVIDIA RTX 5090 Laptop GPU.

Generating cells from a text prompt

Once the trained checkpoints are placed under models/, a single text prompt can be sampled and decoded with the inference entry point:

python scripts/inference/05_inference.py \
    --prompt "CD8+ cytotoxic T cells from human lung adenocarcinoma" \
    --num_cells 500 --cfg_scale 2.0 --decode_expression \
    --output generated_cells.h5ad

Training the contrastive aligner and the diffusion transformer from cached embeddings:

python scripts/training/04a_train_clop.py --config configs/clop.yaml
python scripts/training/04b_train_dit.py --config configs/dit.yaml

Data

The training and validation data are derived entirely from public Gene Expression Omnibus (GEO) records. Each accession is resolvable at https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSExxxxxx.

The deterministic preprocessing pipeline included in this repository (quality control, highly-variable-gene selection, scGPT encoding, study-level stratified split, and deduplication) can rebuild the analysis cache from those GEO records.

The trained model checkpoints (the CLOP aligner and the DiT generator) and the preprocessed embedding cache are not redistributed in this repository because of single-cell data licensing and file-size constraints. Both are available from the co-corresponding authors on reasonable request.

Citation

If you use CLOP-DiT, please cite the article:

Fu Z, Liu Y, Wang J, Wang S. CLOP-DiT: Structured-metadata-conditioned single-cell latent generation via contrastive language-omics pretraining and Diffusion Transformers. Array. 2026;30:100934. https://doi.org/10.1016/j.array.2026.100934

@article{fu2026clopdit,
  author  = {Fu, Zeyu and Liu, Yiyao and Wang, Junping and Wang, Song},
  title   = {CLOP-DiT: Structured-metadata-conditioned single-cell latent generation via contrastive language-omics pretraining and Diffusion Transformers},
  journal = {Array},
  volume  = {30},
  pages   = {100934},
  year    = {2026},
  doi     = {10.1016/j.array.2026.100934}
}

GitHub's "Cite this repository" button reads the same record from CITATION.cff.

License

Released under the MIT License — see LICENSE.

Contact

Zeyu Fu — fuzeyu09@gmail.com

Metadata

Release files for clop-dit 1.1.1

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

Source distribution (sdist)

Source distribution for clop-dit 1.1.1
File Size Uploaded Provenance Actions
clop_dit-1.1.1.tar.gz 333.3 kB With provenance Details for clop_dit-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clop-dit 1.1.1
File Interpreter ABI Platform Actions
clop_dit-1.1.1-py3-none-any.whl Python 3 none any Details for clop_dit-1.1.1-py3-none-any.whl

Total release size: 708.6 kB

Release files / clop_dit-1.1.1.tar.gz

Download URL clop_dit-1.1.1.tar.gz
Size 333.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d68f6bcfadf2b6d7cb5586a8a1fc46dc55bc519272e73452760e2b7a0a023731
BLAKE2b-256 checksum
How to use checksums
f8609d4d74e2f6f6bbe41bfa8dc497f6292711520b22062716e70c1f7fb78136
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 / clop_dit-1.1.1-py3-none-any.whl

Download URL clop_dit-1.1.1-py3-none-any.whl
Size 375.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ae555edb64fff0f6983194cc391912489e1f9f0ff48428070ede89eeae03140
BLAKE2b-256 checksum
How to use checksums
1c03bc50b29761f23895ddcd14e0352696d34674e5e6468f0f4d1dd343054486
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 clop-dit 1.1.1

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 clop_dit-1.1.1.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

1.1.1 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