SpaMetric.reference_centers#
- SpaMetric.reference_centers(adata, n_centers, method='MiniBatchKMeans', n_pcs=None, use_rep=None, random_state=0, copy=False)[source]#
Select reference centers for mini-batch metric learning.
- Parameters:
- adata :
AnnData Annotated data matrix.
- n_centers :
int Number of reference centers to be selected.
- method : {‘MiniBatchKMeans’, ‘KMeans’, ‘Random’}
Literal[‘MiniBatchKMeans’, ‘KMeans’, ‘Random’] (default:'MiniBatchKMeans') Method to use for reference center selection.
'MiniBatchKMeans'Use scikit-learn
MiniBatchKMeansto select reference centers.
'KMeans'Use scikit-learn
KMeansto select reference centers.
'Random'Randomly choose reference centers.
- n_pcs :
int|NoneOptional[int] (default:None) Use this many PCs. If n_pcs==0 use .X if use_rep is None.
- use_rep :
str|NoneOptional[str] (default:None) Use the indicated representation. ‘X’ or any key for .obsm is valid. If None, the representation is chosen automatically: For .n_vars < 50, .X is used, otherwise ‘X_pca’ is used. If ‘X_pca’ is not present, it’s computed with default parameters.
- random_state :
int(default:0) Change to use different initial states for the optimization.
- copy :
bool(default:False) Return a copy instead of writing to
adata.
- adata :
- Return type:
- Returns:
Depending on
copy, returns or updatesadatawith the following fields.- .obs[‘reference_centers’]
Boolean indicator of reference centers.