stereoAlign.metrics.kbet

stereoAlign.metrics.kbet(data: AnnData, key: str = 'batch', use_rep: str = 'X_umap', alpha: float = 0.05, n_neighbors: int = 30)

K-nearest neighbors Batch Effects Test (K-BET)

Calculate the K-nearest neighbors Batch Effects Test (K-BET) metric of the data regarding a specific sample attribute and embedding. The K-BET metric measures if cells from different samples mix well in their local neighborhood.

Parameters

data: AnnData

Data matrix with rows for cells and columns for genes.

key: str

The sample attribute to be consider. Must exist in data.obs.

use_rep: str

The embedding representation to be used. The key must be exist in data.obsm. By default, use UMAP coordinates.

n_neighbors: int

Number of nearest neighbors.

alpha: float

Threshold. A cell is accepted is its K-BET p-value is greater than or equal to alpha

Returns

stat_mean: float

Mean K-BET chi-square statistic over all cells.

pvalue_mean: float

Mean K-BET p-value over all cells.

accept_rate: float

K-BET acceptance rate of the sample.