cautrigger.utils.pert_plot_vector_field#
- cautrigger.utils.pert_plot_vector_field(adata_TF, adata_down, model, pert_Gene, pert_celltype, run_suggest_mass_thresholds, fold, state_obs, dot_size=None, scale=0.1, min_mass=0.008, save_dir=None, embedding_name='X_tsne', n_neighbors=None, n_grid=40, palette=None, direction=None)#
Perform in silico perturbation and visualize the resulting vector field to show cell state transitions. The method of drawing vector field map is borrowed from method CellOracle [KLZ+23].
- Parameters:
adata_TF [AnnData]: Annotated data object containing transcription factor expression data.
adata_down [AnnData]: Annotated data object for downstream analysis with embedding coordinates.
model [torch.nn.Module]: Trained CAUTrigger model with eval() and get_model_output() methods.
pert_Gene [list of str]: List of features to be perturbed.
pert_celltype [list of str]: List of cell types that will receive the perturbation.
- run_suggest_mass_thresholds [bool]: Whether to run suggested mass threshold selection.
Must be set to True initially to determine an appropriate ‘min_mass’.
fold [list of float]: Multiplication factors for each perturbed feature; length must match pert_Gene.
state_obs [str]: Column name in adata_TF.obs representing cell states/types.
dot_size [float, optional]: Size of dots in the plot. Defaults to scanpy’s default if None.
scale [float]: Scaling factor for vector arrows. Larger values result in smaller arrows. Default is 0.1.
- min_mass [float]: Threshold for filtering low-density grid points. Use ‘run_suggest_mass_thresholds=True’
first to determine an appropriate value. Default is 0.008.
save_dir [str, optional]: Directory path to save plots. No saving occurs if None. Default is None.
embedding_name [str]: Key for embedding coordinates in adata_down.obsm. Default is ‘X_tsne’.
- n_neighbors [int, optional]: Number of neighbors for vector field calculation. If None, defaults to
int(adata.shape[0] / 5). Default is None.
n_grid [int]: Grid density for vector field visualization. Default is 40.
palette [dict, optional]: Color mapping dictionary for cell types. Default is None.
direction [str, optional]: Label indicating perturbation direction for figure title. Default is None.
- Returns:
model_output_pert [dict]: Model output after applying perturbations.
References
[KLZ+23]Kenji Kamimoto, Chaoran Liu, Zeda Zhang, Kaili Meyer, Tim Stuart, Alex K. Shalek, and Nir Yosef. Dissecting cell identity via network inference and in silico gene perturbation. Nature, 614:742–751, 2023. URL: https://doi.org/10.1038/s41586-022-05688-9, doi:10.1038/s41586-022-05688-9.