dotools_py.bm.pcr_comparison#
- dotools_py.bm.pcr_comparison(adata_pre, adata_post, covariate, use_rep, n_comps=50, recompute_pca=False, linreg_method='numpy', scale=True)[source]#
Principal component regression score.
Compare the explained variance before and after integration. Return either the difference of variance contribution before and after integration or a score between 0 and 1 (if
scaledis set toTrue) 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 Annotated data matrix before the integration
- adata_post
AnnData Annotated data matrix after the integration
- covariate
str Column in adata.obs to regress against
- use_rep
str Embedding to use for principal component analysis. If
None, use the full expression matrix (adata.X), otherwise use the embedding provided in adata_post.obsm[use_rep].- n_comps
int(default:50) Number of principal components to compute
- recompute_pca
bool(default:False) Whether to recompute PCA with default settings
- linreg_method
Literal['numpy','sklearn'] (default:'numpy') Method for computing the linear regression
- scale
bool(default:True) If set to
Truescale score between 0 and 1.
- adata_pre
- Return type:
- Returns:
Returns the difference of variance contribution of PCR.
Examples
>>> import dotools_py as do >>> adata = do.dt.example_10x_processed() >>> adata_unintegrated = adata.copy() >>> del adata_unintegrated.obsm >>> do.bm.pcr_comparison(adata_pre=adata_unintegrated, adata_post=adata, covariate="batch", use_rep="X_CCA") Out[47]: np.float64(0.832)