scib.metrics.opt_louvain
- scib.metrics.opt_louvain(adata, label_key, cluster_key, function=None, resolutions=None, use_rep=None, inplace=True, plot=False, force=True, verbose=True, **kwargs)
Optimised Louvain clustering
DEPRECATED: Use
cluster_optimal_resolution()insteadLouvain clustering with resolution optimised against a metric
- Parameters:
adata – anndata object
label_key – name of column in adata.obs containing biological labels to be optimised against
cluster_key – name of column to be added to adata.obs during clustering. Will be overwritten if exists and
force=Truefunction – function that computes the cost to be optimised over. Must take as arguments
(adata, group1, group2, **kwargs)and returns a number for maximisingresolutions – list of resolutions to be optimised over. If
resolutions=None, default resolutions of 20 values ranging between 0.1 and 2 will be useduse_rep – key of embedding to use only if
adata.uns['neighbors']is not defined, otherwise will be ignored
- Returns:
Tuple of
(res_max, score_max, score_all)or(res_max, score_max, score_all, clustering)ifinplace=False.res_max: resolution of maximum score;score_max: maximum score;score_all:pd.DataFramecontaining all scores at resolutions. Can be used to plot the score profile.clustering: only ifinplace=False, return cluster assignment aspd.Series