OmicVerse Single-Cell Clustering Backends
Goal
Turn the notebook's clustering comparison into one reusable job: choose and run a clustering backend on a preprocessed single-cell AnnData. Keep this skill focused on backend selection and output contracts after PCA and, when needed, graph construction.
Quick Workflow
- Inspect whether the input already has PCA or another embedding, and whether a neighbor graph already exists.
- Choose a backend explicitly:
leiden, louvain, scICE, or GMM for the notebook-covered paths.
- Build a neighbor graph first for
leiden and louvain.
- Pass
use_rep explicitly for embedding-based methods such as GMM and scICE.
- Validate which
obs columns were added, and treat ARI or figure rendering as optional downstream reporting rather than the core contract.
Interface Summary
ov.utils.cluster(adata, method='leiden', use_rep='X_pca', random_state=1024, n_components=None, **kwargs) dispatches to a clustering backend.
- Live source exposes more
method values than the notebook covers: leiden, louvain, kmeans, GMM, mclust, mclust_R, schist, and scICE.
leiden and louvain forward **kwargs to scanpy clustering on the current graph.
GMM and mclust use the embedding named by use_rep, require n_components, and write both mclust and gmm_cluster.
scICE returns a fitted model object and adds one or more scICE_k* columns to adata.obs through add_to_adata(...).
scICE runtime behavior depends on resolution_range, n_steps, n_trials, and n_boot.
Stage Selection
- Use
leiden for the default graph-based clustering path.
- Use
louvain only when Louvain compatibility is specifically requested.
- Use
GMM when the user wants soft-assignment-style Gaussian mixture clustering on an embedding instead of graph partitioning.
- Use
scICE when the user wants consistency-guided cluster-count selection and is willing to pay the extra bootstrap cost.
- Keep the notebook's UMAP and ARI cells optional; they are reporting on top of clustering outputs, not the reusable skill boundary.
Input Contract
- Start from an
AnnData object that already has PCA or another usable embedding for embedding-based methods.
- Ensure a neighbor graph exists before
leiden or louvain.
- Ensure the embedding named by
use_rep exists before GMM or scICE.
- Pass
n_components when using GMM or mclust.
Minimal Execution Patterns
import omicverse as ov
ov.pp.neighbors(adata, n_neighbors=15, n_pcs=50, use_rep="scaled|original|X_pca")
ov.utils.cluster(adata, method="leiden", resolution=1.0)
ov.utils.cluster(adata, method="louvain", resolution=1.0)
ov.utils.cluster(
adata,
method="GMM",
use_rep="scaled|original|X_pca",
n_components=21,
)
scice_model = ov.utils.cluster(
adata,
method="scICE",
use_rep="scaled|original|X_pca",
resolution_range=(4, 20),
n_boot=50,
n_steps=11,
)
Constraints
- Do not use this skill as a preprocessing skill; it assumes the object is already prepared enough to cluster.
- Do not leave
method implicit.
- Do not assume the notebook's cluster counts are stable defaults for other datasets.
- Treat
scICE_k* outputs as data-dependent candidate solutions, not a fixed schema with one guaranteed suffix.
- Keep smoke and acceptance commands shell-agnostic.
Validation
- Check that the intended
obs column was added for the chosen backend.
- For
GMM, check both mclust and gmm_cluster.
- For
scICE, check that a model object was returned and that at least one scICE_k* column was added.
- If comparing backends, compute metrics such as ARI only after all requested label columns exist.
- If only a bounded smoke path was run, say which backends were executed and which were source-grounded only.
Resource Map
- Use the branch selection notes when choosing a backend.
- Use the source grounding notes for current method branches and output columns.
- Use the notebook mapping notes to trace the notebook's sections into this reusable skill.
- Use the compatibility notes for dependency-sensitive or backend-sensitive paths.
1---2name: omicverse-single-cell-clustering-backends3description: Run and compare OmicVerse single-cell clustering backends as a reusable, triggerable skill. Use when choosing between Leiden, Louvain, scICE, or GMM Gaussian mixture clustering on a prepared AnnData embedding, or when adapting a related OmicVerse clustering notebook into a repeatable workflow.4---56# OmicVerse Single-Cell Clustering Backends78## Goal910Turn the notebook's clustering comparison into one reusable job: choose and run a clustering backend on a preprocessed single-cell `AnnData`. Keep this skill focused on backend selection and output contracts after PCA and, when needed, graph construction.1112## Quick Workflow13141. Inspect whether the input already has PCA or another embedding, and whether a neighbor graph already exists.152. Choose a backend explicitly: `leiden`, `louvain`, `scICE`, or `GMM` for the notebook-covered paths.163. Build a neighbor graph first for `leiden` and `louvain`.174. Pass `use_rep` explicitly for embedding-based methods such as `GMM` and `scICE`.185. Validate which `obs` columns were added, and treat ARI or figure rendering as optional downstream reporting rather than the core contract.1920## Interface Summary2122- `ov.utils.cluster(adata, method='leiden', use_rep='X_pca', random_state=1024, n_components=None, **kwargs)` dispatches to a clustering backend.23- Live source exposes more `method` values than the notebook covers: `leiden`, `louvain`, `kmeans`, `GMM`, `mclust`, `mclust_R`, `schist`, and `scICE`.24- `leiden` and `louvain` forward `**kwargs` to scanpy clustering on the current graph.25- `GMM` and `mclust` use the embedding named by `use_rep`, require `n_components`, and write both `mclust` and `gmm_cluster`.26- `scICE` returns a fitted model object and adds one or more `scICE_k*` columns to `adata.obs` through `add_to_adata(...)`.27- `scICE` runtime behavior depends on `resolution_range`, `n_steps`, `n_trials`, and `n_boot`.2829## Stage Selection3031- Use `leiden` for the default graph-based clustering path.32- Use `louvain` only when Louvain compatibility is specifically requested.33- Use `GMM` when the user wants soft-assignment-style Gaussian mixture clustering on an embedding instead of graph partitioning.34- Use `scICE` when the user wants consistency-guided cluster-count selection and is willing to pay the extra bootstrap cost.35- Keep the notebook's UMAP and ARI cells optional; they are reporting on top of clustering outputs, not the reusable skill boundary.3637## Input Contract3839- Start from an `AnnData` object that already has PCA or another usable embedding for embedding-based methods.40- Ensure a neighbor graph exists before `leiden` or `louvain`.41- Ensure the embedding named by `use_rep` exists before `GMM` or `scICE`.42- Pass `n_components` when using `GMM` or `mclust`.4344## Minimal Execution Patterns4546```python47import omicverse as ov4849ov.pp.neighbors(adata, n_neighbors=15, n_pcs=50, use_rep="scaled|original|X_pca")50ov.utils.cluster(adata, method="leiden", resolution=1.0)51ov.utils.cluster(adata, method="louvain", resolution=1.0)52```5354```python55ov.utils.cluster(56 adata,57 method="GMM",58 use_rep="scaled|original|X_pca",59 n_components=21,60)61```6263```python64scice_model = ov.utils.cluster(65 adata,66 method="scICE",67 use_rep="scaled|original|X_pca",68 resolution_range=(4, 20),69 n_boot=50,70 n_steps=11,71)72```7374## Constraints7576- Do not use this skill as a preprocessing skill; it assumes the object is already prepared enough to cluster.77- Do not leave `method` implicit.78- Do not assume the notebook's cluster counts are stable defaults for other datasets.79- Treat `scICE_k*` outputs as data-dependent candidate solutions, not a fixed schema with one guaranteed suffix.80- Keep smoke and acceptance commands shell-agnostic.8182## Validation8384- Check that the intended `obs` column was added for the chosen backend.85- For `GMM`, check both `mclust` and `gmm_cluster`.86- For `scICE`, check that a model object was returned and that at least one `scICE_k*` column was added.87- If comparing backends, compute metrics such as ARI only after all requested label columns exist.88- If only a bounded smoke path was run, say which backends were executed and which were source-grounded only.8990## Resource Map9192- Use the branch selection notes when choosing a backend.93- Use the source grounding notes for current method branches and output columns.94- Use the notebook mapping notes to trace the notebook's sections into this reusable skill.95- Use the compatibility notes for dependency-sensitive or backend-sensitive paths.