← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-single-cell-clustering / references / usage-guide.md

Single-Cell Clustering - Usage Guide

Overview

This skill covers dimensionality reduction and graph-based clustering for single-cell RNA-seq using Scanpy (Python) and Seurat (R). It treats clustering as exploratory hypothesis generation: resolution has no biological meaning, clusters must be validated by markers and stability before being named cell populations, and UMAP/tSNE are for display only. The skill resolves the hard decisions - Leiden vs Louvain, how many PCs, how to sweep and validate resolution, when a split is over-clustering, and why post-clustering marker p-values are not valid inference.

Prerequisites

Python (Scanpy):

pip install scanpy igraph leidenalg matplotlib

R (Seurat):

install.packages(c('Seurat', 'clustree'))

Quick Start

Tell the agent what to do: - "Run PCA and cluster my single-cell data" - "Sweep clustering resolutions and tell me which to use" - "Are these two clusters really separate cell types?" - "Generate a UMAP colored by cluster"

Example Prompts

Dimensionality Reduction

"Run PCA and show the elbow plot to pick the number of PCs"

"How many PCs should drive the neighbor graph for this dataset?"

Clustering

"Cluster with Leiden and pin the backend so it is reproducible"

"Sweep resolutions 0.2 to 1.0 and build a clustree to choose granularity"

"Subcluster cluster 3 and recompute HVGs and PCA on the subset"

Validation

"Check whether my clusters are stable to bootstrapping"

"Run a significance test to decide if this split is over-clustering"

"These two clusters share all their top markers - should they be merged?"

Visualization

"Show clusters on a UMAP and overlay CD3D, MS4A1, and CD14"

What the Agent Will Do

  1. Run PCA and choose n_pcs from the elbow (n_pcs dominates the result more than n_neighbors).
  2. Build the kNN graph and partition with Leiden, pinning the backend (flavor='igraph', n_iterations=2, directed=False) for reproducibility.
  3. Sweep a resolution range rather than fixing one value, and visualize cell flow with clustree.
  4. Validate clusters: stability by bootstrapping, distinct markers per cluster, and a significance test (scSHC/CHOIR) before claiming populations.
  5. Adjudicate biological vs technical: rule out cell-cycle, dissociation stress, mitochondrial, ambient, and batch drivers.
  6. Generate UMAP/tSNE for display, treating distances as non-metric.

Tips