Building a causality-aware single-cell RNA-seq foundation model via context-specific causal regulation modeling

GitHub Hugging Face License Safetensors

scCAFM is a foundation model for large-scale single-cell RNA-seq analysis that jointly learns context-specific gene-regulatory structure and transferable gene and cell representations. Its two-stage design combines a Structure Foundation Module (SFM) for causal regulatory modeling with an Embedding Foundation Module (EFM) guided by the structure learned by SFM.

Model repository: kaichenxu/scCAFM
Source code: Catchxu/scCAFM

Overview

Many single-cell foundation models primarily capture associative gene relationships or summarize regulation at the dataset or cell-type level. scCAFM is designed to model regulatory context at cellular resolution while learning representations that can transfer to downstream biological analyses.

Overview of the scCAFM framework

Highlights

  • Context-specific regulatory modeling: represents gene-regulatory structure in a compact latent factor space.
  • Mixture-of-Experts structure learning: allows distinct experts to capture heterogeneous regulatory contexts.
  • Structure-guided representation learning: uses SFM-derived causal ordering to guide EFM pretraining.
  • Cell- and gene-level outputs: supports downstream analyses that require transferable embeddings and regulatory structure.
  • Cross-species resources: includes shared assets for Homo sapiens and Mus musculus workflows.

Model architecture

Structure Foundation Module (SFM)

SFM learns context-aware structural representations of gene regulation. A Mixture-of-Experts architecture captures distinct regulatory contexts without fitting an independent causal model for every cell. The resulting structural factors and causal gene ordering guide EFM pretraining.

Embedding Foundation Module (EFM)

EFM learns gene and cell embeddings using the causal ordering produced by a frozen SFM. These representations are intended for downstream supervised and unsupervised analyses, including perturbation-response modeling, trajectory and lineage analysis, and phenotype-associated prediction tasks.

Single-cell expression + biological priors
                    β”‚
                    β–Ό
         Shared vocabulary and tokenization
                    β”‚
                    β–Ό
     Structure Foundation Module (SFM)
                    β”‚
     Context-specific regulatory structure
                    β”‚
                    β–Ό
     Embedding Foundation Module (EFM)
                    β”‚
                    β–Ό
          Gene and cell representations

Checkpoint summary

Component Tensors Parameters Precision Weight file
SFM 199 135,393,926 F32 models/sfm/sfm_model.safetensors
EFM 181 149,029,941 F32 models/efm/efm_model.safetensors
Shared vocabulary 1 15,571,200 F32 tokenizer/vocab.safetensors
Total 381 299,995,067 F32 model.safetensors.index.json

The root Safetensors index describes the complete release while preserving the modular SFM, EFM, and tokenizer layout.

Installation

scCAFM requires Python 3.10–3.14; Python 3.12.9 is recommended. Install the package from the source repository:

git clone https://github.com/Catchxu/scCAFM.git
cd scCAFM
pip install .

For the pinned Python 3.12 environment:

pip install ".[py312]"

GPU-specific packages, including FlashAttention, must be selected for the local CUDA, PyTorch, compiler, and GPU environment. See the source repository for FA2/FA4 configuration and validation instructions.

Download the model assets

Install or update the Hugging Face CLI, then download this repository into the package's assets directory:

pip install -U huggingface_hub
hf download kaichenxu/scCAFM --local-dir assets

The resulting layout is:

assets/
β”œβ”€β”€ release.json
β”œβ”€β”€ model.safetensors.index.json
β”œβ”€β”€ resources/
β”‚   β”œβ”€β”€ human_tfs.csv
β”‚   β”œβ”€β”€ mouse_tfs.csv
β”‚   β”œβ”€β”€ OmniPath.csv
β”‚   └── homologous.csv
β”œβ”€β”€ tokenizer/
β”‚   β”œβ”€β”€ cond_dict.json
β”‚   β”œβ”€β”€ vocab.json
β”‚   └── vocab.safetensors
└── models/
    β”œβ”€β”€ sfm/
    β”‚   β”œβ”€β”€ sfm_config.json
    β”‚   └── sfm_model.safetensors
    └── efm/
        β”œβ”€β”€ efm_config.json
        └── efm_model.safetensors

release.json is the machine-readable manifest for resolving shared resources, tokenizer assets, module configurations, and checkpoints.

Repository contents

Path Description
model.safetensors.index.json Root index for Safetensors discovery and tensor-to-checkpoint mapping
release.json Versioned manifest describing the release layout
resources/human_tfs.csv Human transcription-factor resource
resources/mouse_tfs.csv Mouse transcription-factor resource
resources/OmniPath.csv Prior-knowledge interactions derived from OmniPath
resources/homologous.csv Cross-species homology resource
tokenizer/cond_dict.json Condition vocabulary
tokenizer/vocab.json Shared gene vocabulary
tokenizer/vocab.safetensors Tensor representation of the shared vocabulary
models/sfm/ SFM configuration and pretrained weights
models/efm/ EFM configuration and pretrained weights

Intended use

scCAFM is intended for research applications involving single-cell transcriptomics, including:

  • context-specific gene-regulatory network analysis;
  • gene and cell representation learning;
  • perturbation-response and phenotype-associated modeling;
  • developmental trajectory and lineage analysis;
  • comparative analyses across supported human and mouse resources.

Limitations and responsible use

  • scCAFM is a research model and is not intended for clinical diagnosis or treatment decisions.
  • Model-derived causal relationships are computational hypotheses and should be validated with appropriate experimental or orthogonal evidence.
  • Performance may vary across tissues, technologies, preprocessing pipelines, species, and biological contexts that differ from the training setting.
  • Downstream users are responsible for evaluating robustness, calibration, batch effects, and potential biases for their specific application.

Resources and support

Downloads last month

-

Downloads are not tracked for this model. How to track
Safetensors
Model size
0.3B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using kaichenxu/scCAFM 1