# a4bio/cellvq architecture

> Architecture diagram of the GitHub repository a4bio/cellvq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/a4bio/cellvq
- Repository: https://github.com/a4bio/cellvq

## Overview

CellVQ is a single-cell foundation model whose main user workflow loads expression data and a checkpoint, encodes cells into representations and discrete cell codes, and saves the results. The repository also contains CellVQ-Graph analysis and separate downstream task implementations for perturbation and drug-response prediction. The map includes those documented capabilities, but edges are limited to relationships visible in the excerpts, SOURCE INDEX references, or README; several downstream internals are not sampled.

Main entry points: [`inference.py`](https://github.com/a4bio/cellvq/blob/master/inference.py) (Inference entry), [`CellVQ-graph/graph_module/main.py`](https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/main.py) (Graph training), [`GEARS/gears/gears.py`](https://github.com/a4bio/cellvq/blob/master/GEARS/gears/gears.py) (GEARS workflow), [`model/load.py`](https://github.com/a4bio/cellvq/blob/master/model/load.py) (Checkpoint loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cellvq["CellVQ inference"]
  node_inference["Inference entry<br/>[inference.py]"]
  node_preprocess["Expression normalization<br/>[normalize.py]"]
  node_loader["Checkpoint loader<br/>[load.py]"]
  node_selector["Model selector<br/>[select_model.py]"]
  node_encoder["Performer encoder<br/>[performer.py]"]
  node_attention["Local attention<br/>[local_attention.py]"]
  node_vq["Vector quantization<br/>[vq_modules.py]"]
end

subgraph group_graph["CellVQ-Graph analysis"]
  node_graphmain["Graph training<br/>[main.py]"]
  node_graphdata["Graph data loading<br/>[dataloader.py]"]
  node_graphops["Graph construction<br/>[graph_function.py]"]
  node_homograph["Homogeneous graph model<br/>[HomoGraph.py]"]
  node_graphutils["Graph analysis utilities<br/>[utils_gac.py]"]
end

subgraph group_perturb["Perturbation prediction"]
  node_gears["GEARS workflow<br/>[gears.py]"]
  node_gearsmodel["Perturbation model<br/>[model.py]"]
  node_gearseval["Perturbation evaluation<br/>[inference.py]"]
  node_gearsattention["Performer modules"]
end

subgraph group_drug["Drug response"]
  node_scad["SCAD training"]
  node_scadmodules["SCAD modules<br/>[SCADmodules.py]"]
  node_deepcdr["DeepCDR workflow<br/>[run_DeepCDR.py]"]
end

subgraph group_analysis["Interpretation and visualization"]
  node_visualize["Embedding visualization<br/>[visualize.py]"]
  node_geneanalysis["Gene-property analysis<br/>[get_property.py]"]
  node_grn["Regulatory network analysis<br/>[grn.py]"]
end

node_user(("Researcher"))
node_input["Expression data"]
node_embeddings["Saved embeddings"]

node_user -->|"runs"| node_inference
node_input -->|"provides data"| node_inference
node_inference -->|"loads checkpoint"| node_loader
node_inference -.->|"normalizes"| node_preprocess
node_loader -->|"selects model"| node_selector
node_selector -->|"constructs"| node_encoder
node_encoder -->|"uses attention"| node_attention
node_inference -.->|"encodes cell codes"| node_vq
node_inference -->|"saves outputs"| node_embeddings
node_user -->|"runs analysis"| node_graphmain
node_graphmain -->|"loads graph data"| node_graphdata
node_graphdata -->|"uses graph functions"| node_graphops
node_graphmain -->|"trains model"| node_homograph
node_graphmain -->|"uses utilities"| node_graphutils
node_user -.->|"runs prediction"| node_gears
node_gears -->|"uses model"| node_gearsmodel
node_gears -->|"evaluates predictions"| node_gearseval
node_gearsattention -.->|"shares attention design"| node_attention
node_user -.->|"runs response task"| node_scad
node_scad -->|"uses modules"| node_scadmodules
node_user -.->|"runs response task"| node_deepcdr
node_user -.->|"explores results"| node_visualize
node_user -->|"analyzes properties"| node_geneanalysis
node_user -->|"analyzes networks"| node_grn

click node_inference "https://github.com/a4bio/cellvq/blob/master/inference.py"
click node_preprocess "https://github.com/a4bio/cellvq/blob/master/preprocess/normalize.py"
click node_loader "https://github.com/a4bio/cellvq/blob/master/model/load.py"
click node_selector "https://github.com/a4bio/cellvq/blob/master/model/pretrainmodels/select_model.py"
click node_encoder "https://github.com/a4bio/cellvq/blob/master/model/pretrainmodels/performer.py"
click node_attention "https://github.com/a4bio/cellvq/blob/master/model/pretrainmodels/local_attention.py"
click node_vq "https://github.com/a4bio/cellvq/blob/master/modules/vq_modules.py"
click node_graphmain "https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/main.py"
click node_graphdata "https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/module/dataloader.py"
click node_graphops "https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/module/graph_function.py"
click node_homograph "https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/model/HomoGraph.py"
click node_graphutils "https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/utils/utils_gac.py"
click node_gears "https://github.com/a4bio/cellvq/blob/master/GEARS/gears/gears.py"
click node_gearsmodel "https://github.com/a4bio/cellvq/blob/master/GEARS/gears/model.py"
click node_gearseval "https://github.com/a4bio/cellvq/blob/master/GEARS/gears/inference.py"
click node_gearsattention "https://github.com/a4bio/cellvq/blob/master/GEARS/modules/performer_module.py"
click node_scad "https://github.com/a4bio/cellvq/blob/master/SCAD/model/SCAD_train_binarized_5folds-pub.py"
click node_scadmodules "https://github.com/a4bio/cellvq/blob/master/SCAD/model/SCADmodules.py"
click node_deepcdr "https://github.com/a4bio/cellvq/blob/master/DeepCDR/prog/run_DeepCDR.py"
click node_visualize "https://github.com/a4bio/cellvq/blob/master/visualize/visualize.py"
click node_geneanalysis "https://github.com/a4bio/cellvq/blob/master/visualize/get_property.py"
click node_grn "https://github.com/a4bio/cellvq/blob/master/visualize/grn.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_inference,node_preprocess,node_loader,node_selector,node_encoder,node_attention,node_vq toneBlue
class node_graphmain,node_graphdata,node_graphops,node_homograph,node_graphutils toneAmber
class node_gears,node_gearsmodel,node_gearseval,node_gearsattention toneMint
class node_scad,node_scadmodules,node_deepcdr toneRose
class node_visualize,node_geneanalysis,node_grn,node_user,node_input,node_embeddings toneIndigo
```

## Components

### CellVQ inference

- [Inference entry](https://github.com/a4bio/cellvq/blob/master/inference.py): `inference.py`
- [Expression normalization](https://github.com/a4bio/cellvq/blob/master/preprocess/normalize.py): `preprocess/normalize.py`
- [Checkpoint loader](https://github.com/a4bio/cellvq/blob/master/model/load.py): `model/load.py`
- [Model selector](https://github.com/a4bio/cellvq/blob/master/model/pretrainmodels/select_model.py): `model/pretrainmodels/select_model.py`
- [Performer encoder](https://github.com/a4bio/cellvq/blob/master/model/pretrainmodels/performer.py): `model/pretrainmodels/performer.py`
- [Local attention](https://github.com/a4bio/cellvq/blob/master/model/pretrainmodels/local_attention.py): `model/pretrainmodels/local_attention.py`
- [Vector quantization](https://github.com/a4bio/cellvq/blob/master/modules/vq_modules.py): `modules/vq_modules.py`

### CellVQ-Graph analysis

- [Graph training](https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/main.py): `CellVQ-graph/graph_module/main.py`
- [Graph data loading](https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/module/dataloader.py): `CellVQ-graph/graph_module/module/dataloader.py`
- [Graph construction](https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/module/graph_function.py): `CellVQ-graph/graph_module/module/graph_function.py`
- [Homogeneous graph model](https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/model/HomoGraph.py): `CellVQ-graph/graph_module/model/HomoGraph.py`
- [Graph analysis utilities](https://github.com/a4bio/cellvq/blob/master/CellVQ-graph/graph_module/utils/utils_gac.py): `CellVQ-graph/graph_module/utils/utils_gac.py`

### Perturbation prediction

- [GEARS workflow](https://github.com/a4bio/cellvq/blob/master/GEARS/gears/gears.py): `GEARS/gears/gears.py`
- [Perturbation model](https://github.com/a4bio/cellvq/blob/master/GEARS/gears/model.py): `GEARS/gears/model.py`
- [Perturbation evaluation](https://github.com/a4bio/cellvq/blob/master/GEARS/gears/inference.py): `GEARS/gears/inference.py`
- [Performer modules](https://github.com/a4bio/cellvq/blob/master/GEARS/modules/performer_module.py): `GEARS/modules/performer_module.py`

### Drug response

- [SCAD training](https://github.com/a4bio/cellvq/blob/master/SCAD/model/SCAD_train_binarized_5folds-pub.py): `SCAD/model/SCAD_train_binarized_5folds-pub.py`
- [SCAD modules](https://github.com/a4bio/cellvq/blob/master/SCAD/model/SCADmodules.py): `SCAD/model/SCADmodules.py`
- [DeepCDR workflow](https://github.com/a4bio/cellvq/blob/master/DeepCDR/prog/run_DeepCDR.py): `DeepCDR/prog/run_DeepCDR.py`

### Interpretation and visualization

- [Embedding visualization](https://github.com/a4bio/cellvq/blob/master/visualize/visualize.py): `visualize/visualize.py`
- [Gene-property analysis](https://github.com/a4bio/cellvq/blob/master/visualize/get_property.py): `visualize/get_property.py`
- [Regulatory network analysis](https://github.com/a4bio/cellvq/blob/master/visualize/grn.py): `visualize/grn.py`

### Other components

- **Researcher**
- **Expression data**
- **Saved embeddings**

## Connections

- Researcher → Inference entry: runs
- Expression data → Inference entry: provides data (evidence: `inference.py`)
- Inference entry → Checkpoint loader: loads checkpoint (evidence: `inference.py`)
- Inference entry → Expression normalization: normalizes
- Checkpoint loader → Model selector: selects model (evidence: `model/load.py`)
- Model selector → Performer encoder: constructs (evidence: `model/pretrainmodels/select_model.py`)
- Performer encoder → Local attention: uses attention (evidence: `model/pretrainmodels/performer.py`)
- Inference entry → Vector quantization: encodes cell codes
- Inference entry → Saved embeddings: saves outputs (evidence: `inference.py`)
- Researcher → Graph training: runs analysis
- Graph training → Graph data loading: loads graph data (evidence: `CellVQ-graph/graph_module/main.py`)
- Graph data loading → Graph construction: uses graph functions (evidence: `CellVQ-graph/graph_module/module/dataloader.py`)
- Graph training → Homogeneous graph model: trains model (evidence: `CellVQ-graph/graph_module/main.py`)
- Graph training → Graph analysis utilities: uses utilities (evidence: `CellVQ-graph/graph_module/main.py`)
- Researcher → GEARS workflow: runs prediction
- GEARS workflow → Perturbation model: uses model (evidence: `GEARS/gears/gears.py`)
- GEARS workflow → Perturbation evaluation: evaluates predictions (evidence: `GEARS/gears/gears.py`)
- Performer modules → Local attention: shares attention design (evidence: `GEARS/modules/performer_module.py`)
- Researcher → SCAD training: runs response task
- SCAD training → SCAD modules: uses modules (evidence: `SCAD/model/SCAD_train_binarized_5folds-pub.py`)
- Researcher → DeepCDR workflow: runs response task
- Researcher → Embedding visualization: explores results
- Researcher → Gene-property analysis: analyzes properties
- Researcher → Regulatory network analysis: analyzes networks
