scib.metrics.pcr_comparison
- scib.metrics.pcr_comparison(adata_pre, adata_post, covariate, embed=None, n_comps=50, scale=True, verbose=False)
Principal component regression score
Compare the explained variance before and after integration using
pc_regression()
. Return either the difference of variance contribution before and after integration or a score between 0 and 1 (scaled=True
) with 0 if the variance contribution hasn’t changed. The larger the score, the more different the variance contributions are before and after integration.- Parameters:
adata_pre – anndata object before integration
adata_post – anndata object after integration
covariate – Key for
adata_post.obs
column to regress againstembed – Embedding to use for principal component analysis. If None, use the full expression matrix (
adata_post.X
), otherwise use the embedding provided inadata_post.obsm[embed]
.n_comps – Number of principal components to compute
scale – If True, scale score between 0 and 1 (default)
verbose –
- Returns:
Difference of variance contribution of PCR (scaled between 0 and 1 by default)
The function can be computed on full corrected feature spaces and latent embeddings for both integrated and unintegrated
anndata.Anndata
objects. No preprocessing is needed, as the function will perform PCA directly on the feature or embedding space.Examples
# full feature output scib.me.pcr_comparison(adata_unintegrated, adata, covariate="batch") # embedding output scib.me.pcr_comparison(adata_unintegrated, adata, covariate="batch", embed="X_emb")