mantispy.metrics.pc_regression#
- mantispy.metrics.pc_regression(adata, key, use_rep='X_pca', n_comps=None)[source]#
Variance-weighted R^2 of the principal components on
key.Each component is regressed on
keyon its own, a categorical key through a one-way ANOVA R^2 and a numeric key through the squared Pearson correlation, and the per-component R^2 is weighted by that component’s share of the total variance. The value is the share of total variance the covariate explains, so for a batch key lower is better. The per-component loop runs in a numba kernel and imports no scib.- Parameters:
- Return type:
- Returns:
A one-row tidy frame holding
pc_regression, whose value is NaN whenkeyis constant (a single batch), where the share of variance it explains is undefined.- Raises:
KeyError –
obsmholds nothing underuse_rep.ValueError –
keyis numeric and has missing values, which cannot be regressed.