regvelo.ModelComparison

class regvelo.ModelComparison(terminal_states=None, state_transition=None, n_states=None)[source]

Compare different types of RegVelo models : cite:p: Wang2025.

This class is used to compare different RegVelo models with different optimization mode (soft, hard, soft_regularized) and under different normalization factor lamda2. User can evaluate and visulize competence of different types of models based on various side information (Real time, Pseudo Time, Stemness Score, Terminal States Identification, Cross Boundary Correctness) of cell. Finally, it will return a barplot with best performed model marked, and its performance will also be highlighted by significance test.

Examples

See notebook.

Parameters:
  • terminal_states (list)

  • state_transition (dict)

  • n_states (int)

Methods table

Methods

ModelComparison.calculate(adata, side_information, side_key=None)[source]
Parameters:
ModelComparison.evaluate(side_information, side_key=None)[source]

Evaluate all of trained model under one specific side_information mode, For example, if user know the exact time or stage of cells, user can choose ‘Real_Time’ as reference; If users has used Pseudotime calculator such as CellRank beforehand, they can also choose ‘Pseudo_Time’ as reference.

Parameters:
  • side_information (str) – User can choose perspectives to compare RegVelo models, including ‘Real_Time’, ‘Pseudo_Time’, ‘Stemness_Score’,’TSI’,’CBC’.

  • side_key (Optional[str]) – Column name of adata.obs which used to store information of selected side_information. For ‘Pseudo_Time’ and ‘Stemness_Score’, we provide default side_key, but you can also choose your own side_key as input.

Return type:

DataFrame

Returns:

: A dataframe records evaluation performance of all models.

ModelComparison.get_significance(pvalue)[source]
ModelComparison.min_max_scaling(x)[source]
ModelComparison.plot_results(side_information, figsize=(6, None), palette='lightpink')[source]

Visualize comparision result by barplot with scatters. The significant mark will only show with n_repeats more than 3, and p < 0.05.

Paramters

side_information

Here choose the side_information you wish to visulize, which must be performed in ‘evaluation’ step in advance.

figsize

You can choose the size of figure. Default is (6,None), which means the height of the plot are set to change with the number of models.

palette

You can choose the color of barplot.

returns:

: Nothing, just plots the figure.

ModelComparison.train(adata, model_list, lam2=None, n_repeat=1, batch_size=None)[source]

Train all the possible models given by users, and stored them in a dictionary, where users can reach them easily and deal with them in batch.If there are already model trained and saved before, they won’t be removed.

Parameters:
  • adata (AnnData) – The annotated data matrix. After input of adata, the object will store it as self variable.

  • model_list (list[str]) – The list of valid model type, including ‘Soft’, ‘Hard’, ‘Soft_regularized’

  • lam2 (Union[list[float], float, None]) – Normalization factor used under ‘soft_regularized’ mode. A float or a list of float number in range of (0,1)

  • batch_size – Training batch size. This enable user to adjust batch size according to data size.

  • n_repeat (int)

Return type:

list

Returns:

: A dictionary key names, represent to all models trained in this step.

ModelComparison.validate_input(adata, model_list=None, side_information=None, lam2=None, side_key=None)[source]
Return type:

None

Parameters: