scib_metrics.utils.principal_component_regression

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 (Union[ndarray, Array]) – Array of shape (n_cells, n_features).

  • covariate (Union[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 (Optional[int] (default: None)) – Number of components to compute, passed into pca(). If None, all components are used.

Return type:

float

Returns:

pcr: float Principal component regression using the first n_components principal components.