CFLARE.compute_terminal_states(use=None, percentile=98, method='kmeans', cluster_key=None, n_clusters_kmeans=None, n_neighbors=20, resolution=0.1, n_matches_min=0, n_neighbors_filtering=15, basis=None, n_comps=5, scale=False, en_cutoff=0.7, p_thresh=1e-15)[source]

Find approximate recurrent classes of the Markov chain.

Filter to obtain recurrent states in left eigenvectors. Cluster to obtain approximate recurrent classes in right eigenvectors.

  • use (Union[int, Tuple[int], List[int], range, None]) – Which or how many first eigenvectors to use as features for clustering/filtering. If None, use the eigengap statistic.

  • percentile (Optional[int]) – Threshold used for filtering out cells which are most likely transient states. Cells which are in the lower percentile percent of each eigenvector will be removed from the data matrix.

  • method (str) – Method to be used for clustering. Must be one of ‘louvain’, ‘leiden’ or ‘kmeans’.

  • cluster_key (Optional[str]) – If a key to cluster labels is given, terminal_states will get associated with these for naming and colors.

  • n_clusters_kmeans (Optional[int]) – If None, this is set to use + 1.

  • n_neighbors (int) – If we use ‘louvain’ or ‘leiden’ for clustering cells, we need to build a KNN graph. This is the \(K\) parameter for that, the number of neighbors for each cell.

  • resolution (float) – Resolution parameter for ‘louvain’ or ‘leiden’ clustering. Should be chosen relatively small.

  • n_matches_min (Optional[int]) – Filters out cells which don’t have at least n_matches_min neighbors from the same class. This filters out some cells which are transient but have been misassigned.

  • n_neighbors_filtering (int) – Parameter for filtering cells. Cells are filtered out if they don’t have at least n_matches_min neighbors among their n_neighbors_filtering nearest cells.

  • basis (Optional[str]) – Key from :paramref`adata` .obsm to be used as additional features for the clustering.

  • n_comps (int) – Number of embedding components to be use when basis is not None.

  • scale (bool) – Scale to z-scores. Consider using this if appending embedding to features.

  • en_cutoff (Optional[float]) – If cluster_key is given, this parameter determines when an approximate recurrent class will be labeled as ‘Unknown’, based on the entropy of the distribution of cells over transcriptomic clusters.

  • p_thresh (float) – If cell cycle scores were provided, a Wilcoxon rank-sum test is conducted to identify cell-cycle states. If the test returns a positive statistic and a p-value smaller than p_thresh, a warning will be issued.


Nothing, but updates the following fields:

Return type