sccloud.calc_kBET¶
-
sccloud.calc_kBET(data, attr, rep='pca', K=25, alpha=0.05, n_jobs=-1, random_state=0, temp_folder=None)[source]¶ Calculate the kBET metric of the data w.r.t. a specific sample attribute and embedding.
This kBET metric is based on paper “A test metric for assessing single-cell RNA-seq batch correction” [Büttner18] in Nature Methods, 2018.
- 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 be used. The key'X_' + repmust exist indata.obsm. By default, use PCA coordinates.K (
int, optional, default:25) – Number of nearest neighbors, using L2 metric.alpha (
float, optional, default:0.05) – Acceptance rate threshold. A cell is accepted if its kBET p-value is greater than or equal toalpha.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.temp_folder (
str, optional, default:None) – Temporary folder for joblib execution.
- Return type
Tuple[float,float,float]- Returns
stat_mean (
float) – Mean kBET chi-square statistic over all cells.pvalue_mean (
float) – Mean kBET p-value over all cells.accept_rate (
float) – kBET Acceptance rate of the sample.
Examples
>>> scc.calc_kBET(adata, attr = 'Channel')
>>> scc.calc_kBET(adata, attr = 'Channel', rep = 'umap')