torchcell.models
Model implementations, one module per architecture. They range from sequence language-model wrappers (Nucleotide Transformer, ESM-2, ProtT5, the fungal up/down-stream transformer) through set and graph models (DeepSet, GCN and GAT encoders, DiffPool and SAGPool variants) to the cell models used in the experiments: DCell, the DANGO family (for example GeneInteractionDango in hetero_cell_bipartite_dango_gi), and the Cell Graph Transformer (CellGraphTransformer, with its equivariant variant CellGraphTransformer). The package namespace re-exports a small subset (torchcell.models.__all__); every class below is listed under the module that defines it.
cell_graph_transformer
Cell Graph Transformer with graph-regularized attention heads.
Classes
Transformer layer with graph-regularized attention heads. |
|
Hypergraph Self-Attention Graph Neural Network for perturbation sets. |
|
Perturbation head with switchable attention mechanisms. |
|
Cell Graph Transformer model. |
Functions
Calculate L2 norm of all model weights. |
|
Compute smoothness of node features (oversmoothing diagnostic). |
cell_graph_transformer_metabolism
CGT-Metabolism: the Cell Graph Transformer with production / metabolome readouts.
Classes
Read a measured metabolite level off the predicted flux vector's turnover. |
|
Read a scalar production phenotype off the predicted flux vector. |
|
Whole-cell readout for a SCALAR production phenotype (one value per strain). |
|
Whole-cell readout for a FIXED-COLUMN metabolome vector (Mulleder's 19 AAs). |
|
|
CellGraphTransformer + named production / metabolome readout heads. |
Functions
Mean over ONLY the perturbed gene tokens, per sample. |
dango
DANGO model: PPI-network pretraining, embedding integration, and HyperSAGNN.
Classes
GNN pre-training component of DANGO model that learns node embeddings from protein-protein interaction networks in S. |
|
Meta-embedding module to integrate embeddings from multiple networks. |
|
Fully vectorized Hypergraph Self-Attention Graph Neural Network that handles all perturbation sets in a single forward pass. |
|
DANGO model for predicting higher-order genetic interactions |
dcell
DCell model: a GO-ontology-structured neural network over gene perturbations.
Classes
DCell network mirroring the GO ontology as a hierarchy of subsystems. |
|
Individual subsystem module as described in DCell paper. |
dcell_opt
Optimized DCell model for torch.compile compatibility.
Classes
Optimized DCell with tensorized operations for torch.compile. |
|
Individual subsystem module as described in DCell paper. |
deep_set
DeepSet model with permutation-invariant set aggregation over node features.
Classes
Permutation-invariant network applying per-node MLPs then set aggregation. |
diffusion_decoder
Diffusion-based decoder conditioning on graph embeddings via cross-attention.
Classes
Sinusoidal time embeddings for diffusion timesteps. |
|
Cross-attention module where diffusion state queries graph embeddings. |
|
Single denoising block with cross-attention and feedforward. |
|
Diffusion decoder with cross-attention conditioning on graph embeddings. |
equivariant_cell_graph_transformer
Equivariant Cell Graph Transformer with graph-regularized attention heads.
Classes
|
Transformer layer with graph-regularized attention heads. |
Hypergraph Self-Attention Graph Neural Network for perturbation sets. |
|
|
Equivariant perturbation transformation that preserves per-gene structure. |
|
Route the perturbation to graph NEIGHBOURS -- the missing pair-(p, i) term. |
Explicit rank-R multiplicative interaction between gene identity and perturbation. |
|
Encode PARTIALLY OBSERVED labels so the decoder can condition on them. |
|
GEARS-style cross-gene mixing: one shared global state, then per-gene readout. |
|
Low-rank response-basis decoder: the perturbation activates shared programs. |
|
POST-perturbation gene-gene mixing through a learned latent bottleneck. |
|
Perturbation readout head for gene interaction prediction. |
|
Whole-cell readout head for global phenotypes. |
|
S3 cross-attention readout head (DETR / Perceiver style) for vector phenotypes. |
|
Per-gene (equivariant) readout head for gene-resolved phenotypes. |
|
Per-metabolite readout head via GPR pooling of gene embeddings. |
|
Masked multitask loss over config-selected heads plus graph regularization. |
|
Equivariant Cell Graph Transformer model. |
Functions
Calculate L2 norm of all model weights. |
|
Compute smoothness of node features (oversmoothing diagnostic). |
esm2
ESM-2 protein language model wrapper producing per-residue or mean embeddings.
Classes
Facebook ESM-2 masked-LM wrapper that embeds protein sequences. |
fungal_up_down_transformer
SpeciesLM-based transformer embedding fungal upstream/downstream DNA sequences.
Classes
Embed DNA sequences upstream and downstream of the CDS via SpeciesLM. |
gpu_edge_mask_generator
GPU-based edge mask generator for zero-copy lazy subgraph representation.
Classes
Generates edge masks on GPU from perturbation indices. |
hetero_cell_bipartite_dango
Bipartite hetero GNN with DANGO-style gene interaction attention.
Classes
Self-attention for digenic and trigenic gene interaction prediction. |
|
Predict interaction scores from squared static/dynamic embedding differences. |
|
Attentional pooling that gates and transforms node features before aggregation. |
|
MLP that projects raw input features to the hidden dimension. |
|
Wrap a graph conv with projection, normalization, activation, and dropout. |
|
Hetero GNN with DANGO interaction head over gene/reaction/metabolite graphs. |
Functions
Return a layer or batch normalization module for the given channel count. |
hetero_cell_bipartite_dango_diff_gi
Gene interaction model variant with a diffusion-based prediction head.
Classes
Simple linear decoder for baseline comparison. |
|
Gene interaction model with diffusion-based prediction head. |
hetero_cell_bipartite_dango_gi
Heterogeneous bipartite cell-graph model for DANGO gene-interaction prediction.
Classes
|
Self-attention aggregation over multiple graph views of the same nodes. |
Pairwise interaction aggregation over multiple graph representations. |
|
|
An |
HeteroConv wrapper with configurable aggregation strategies. |
|
Gated attentional pooling of node features into a graph-level representation. |
|
Dango-like HyperSAGNN for local gene interaction prediction. |
|
Predict gene-interaction scores from squared static/dynamic embedding diffs. |
|
MLP that projects input features into the hidden space before convolutions. |
|
Wrap a conv with output projection, optional norm, activation, and dropout. |
|
Full DANGO model: gene embeddings, hetero conv encoder, and interaction head. |
Functions
Return the |
|
Refuse any |
|
Return a LayerNorm or BatchNorm1d layer for the given norm name. |
|
Create appropriate conv layer based on encoder type. |
|
Calculate L2 norm of all model weights. |
|
|
Calculate rolling correlation between two series. |
hetero_cell_bipartite_dango_gi_lazy
Lazy bipartite Dango gene-interaction model using masked, zero-copy message passing.
Classes
|
Self-attention mechanism for aggregating multiple graph representations of the same nodes. |
|
Pairwise interaction mechanism for aggregating multiple graph representations. |
HeteroConv wrapper with configurable aggregation strategies. |
|
|
Attentional aggregation pooling node features into graph-level vectors. |
Dango-like HyperSAGNN for local gene interaction prediction. |
|
|
Predict gene interaction scores from gene embeddings via a HyperSAGNN. |
MLP that preprocesses node features with linear, norm, activation, and dropout layers. |
|
Wrapper applying norm, activation, and dropout around a graph convolution. |
|
Lazy Dango-style model predicting gene interactions from a gene multigraph. |
Functions
Get normalization layer from norm_register - NO FALLBACK. |
|
Create appropriate conv layer based on encoder type. |
|
|
Calculate L2 norm of all model weights. |
|
Calculate rolling correlation between two series. |
hetero_cell_nsa_retry
Heterogeneous cell model using Node-Set Attention blocks over gene/reaction/metabolite graphs.
Classes
Attentional aggregation for graph-level representations. |
|
MLP for preprocessing node features. |
|
Heterogeneous Cell Model using Node-Set Attention (NSA) blocks. |
Functions
Create a normalization layer based on specified type. |
linear
Simple set-aggregation linear model over scatter-pooled node features.
Classes
Scatter-aggregate node features per set, then apply a linear layer. |
llm
Abstract base classes for nucleotide and peptide language models.
Classes
Abstract interface for nucleotide-sequence language models. |
|
Abstract interface for peptide-sequence language models. |
|
Container pairing a tokenizer with a pretrained masked-LM model. |
mlp
Configurable multilayer perceptron with optional normalization and activations.
Classes
Sequential MLP built from linear blocks with optional norm and activation. |
nucleotide_transformer
Nucleotide Transformer wrapper for embedding DNA sequences.
Classes
InstaDeepAI Nucleotide Transformer for DNA sequence embeddings. |
protT5
ProtT5 protein language model wrapper for embedding amino-acid sequences.
Classes
Rostlab ProtT5 encoder wrapper producing per-residue or mean embeddings. |
self_attention_deep_set
Self-attention Deep Sets model for permutation-invariant set encoding.
Classes
Multi-head self-attention returning outputs and per-graph weights. |
|
Deep Sets encoder with self-attention between node and set layers. |