pegasus.calc_kSIM¶
-
pegasus.
calc_kSIM
(data, attr, rep='pca', K=25, min_rate=0.9, n_jobs=- 1, random_state=0)[source]¶ Calculate the kSIM metric of the data w.r.t. a specific sample attribute and embedding.
This kSIM metric measures if attr are not diffused too much.
- Parameters
data (
anndata.AnnData
) – Annotated data matrix with rows for cells and columns for genes.attr (
str
) – The sample attribute to consider. Must exist indata.obs
.rep (
str
, optional, default:"pca"
) – The embedding representation to consider. The key'X_' + rep
must exist indata.obsm
.K (
int
, optional, default:25
) – The number of nearest neighbors to be considered.min_rate (
float
, optional, default:0.9
) – Acceptance rate threshold. A cell is accepted if its kSIM rate is larger than or equal tomin_rate
.n_jobs (
int
, optional, default:-1
) – Number of threads used. If-1
, use all available threads.random_state (
int
, optional, default:0
) – Random seed set for reproducing results.
- Return type
Tuple
[float
,float
]- Returns
kSIM_mean (
float
) – Mean kSIM rate over all the cells.kSIM_accept_rate (
float
) – kSIM Acceptance rate of the sample.
Examples
>>> pg.calc_kSIM(adata, attr = 'cell_type')
>>> pg.calc_kSIM(adata, attr = 'cell_type', rep = 'umap')