scib_metrics.utils.principal_component_regression#
- scib_metrics.utils.principal_component_regression(X, covariate, categorical=False, n_components=None)[source]#
Principal component regression (PCR) [Büttner et al., 2018].
- Parameters:
- X
ndarray|Array Array of shape (n_cells, n_features).
- covariate
ndarray|Array Array of shape (n_cells,) or (n_cells, 1) representing batch/covariate values.
- categorical
bool(default:False) If True, batch will be treated as categorical and one-hot encoded.
- n_components
int|None(default:None) Number of components to compute, passed into
pca(). If None, all components are used.
- X
- Return type:
- Returns:
pcr: float Principal component regression using the first n_components principal components.