cellflow.model.CellFlow

class cellflow.model.CellFlow(adata, solver='otfm')[source]

CellFlow model for perturbation prediction using Flow Matching and Optimal Transport.

CellFlow builds upon neural optimal transport estimators extending [Tong et al., 2023], [Pooladian et al., 2023], [Eyring et al., 2024], [Klein et al., 2024] which are all based on Flow Matching [Lipman et al., 2022].

Parameters:
  • adata (AnnData) – An AnnData object to extract the training data from.

  • solver (str) – Solver to use for training. Any name registered in cellflow.solvers.SOLVER_REGISTRY ('otfm' or 'genot' by default, extendable via cellflow.solvers.register_solver()).

Methods

get_condition_embedding(covariate_data[, ...])

Get the embedding of the conditions.

load(filename)

Load a CellFlow model from a saved instance.

predict(adata, covariate_data[, sample_rep, ...])

Predict perturbation responses.

prepare_data(sample_rep, control_key, ...[, ...])

Prepare the dataloader for training from adata.

prepare_model([condition_mode, ...])

Prepare the model for training.

prepare_validation_data(adata, name[, ...])

Prepare the validation data.

save(dir_path[, file_prefix, overwrite])

Save the model.

train(num_iterations[, batch_size, ...])

Train the model.

Attributes

adata

The AnnData object used for training.

condition_mode

The mode of the encoder.

data_manager

The data manager, initialised with cellflow.model.CellFlow.adata.

dataloader

The dataloader used for training.

solver

The solver.

train_data

The training data.

trainer

The trainer used for training.

validation_data

The validation data.

velocity_field

The conditional velocity field.