c2v.tl.clonal_nn#
- c2v.tl.clonal_nn(adata, clones, obs_name=None, k=15, use_rep='X_pca', obsp_name='gex_adjacency', adata_ref=None, clones_ref=None, nn_transfer_name='ref_gex_adjacency', random_state=4, split_by=None, progress_bar=False, mask_obs=None, **kwargs)#
Computes and adds a clone-to-clone adjacency graph to a clones object.
The graph is built by finding nearest neighbors in a given representation (e.g., PCA) and aggregating these relationships at the clone level.
- Parameters:
- adata AnnData
The original, cell-level annotated data matrix.
- clones AnnData
The clone-level AnnData object, typically from create_clone_adata.
- obs_name str | None, optional
Column in adata.obs containing clonal information. If None, use clones.uns[“obs_name”], by default None.
- k int, optional
Number of nearest neighbors to retrieve for each cell, by default 15.
- use_rep str, optional
Representation in adata.obsm to build the kNN graph, by default “X_pca”.
- obsp_name str, optional
Name of the new graph slot in clones.obsp, by default “gex_adjacency”.
- adata_ref sc.AnnData | None, optional
Reference cell-level annotated data matrix for transfer, by default None.
- clones_ref sc.AnnData | None, optional
Reference clone-level AnnData object for transfer, by default None.
- nn_transfer_name str, optional
Name of the new graph slot in clones_ref.obsp for transfer, by default “ref_gex_adjacency”.
- random_state None | int, optional
Random state for reproducibility, by default 4.
- split_by str | None, optional
Column in clones.obs to split the independent kNN-graph constriction, by default None.
- progress_bar bool, optional
Whether to display a progress bar in the case of split_by, by default False.
- **kwargs dict, optional
Additional keyword arguments to pass to pynndescent.NNDescent.
- mask_obs list[ndarray | Series] | ndarray | Series | None
- Return type:
- Returns:
None Updates clones in-place with the computed adjacency graph in .obsp[obsp_name].