paga
Partition-based Graph Abstraction tool for single-cell RNA sequencing analysis. Abstracts cell populations into graphs, identifies clusters, and models connectivity using RNA velocity or predefined groups.
Instructions
Partition-based graph abstraction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| groups | No | Key for categorical in adata.obs. You can pass your predefined groups by choosing any categorical annotation of observations. Default: The first present key of 'leiden' or 'louvain'. | |
| model | No | The PAGA connectivity model. | v1.2 |
| neighbors_key | No | If specified, paga looks .uns[neighbors_key] for neighbors settings and uses the corresponding connectivities and distances. | |
| use_rna_velocity | No | Use RNA velocity to orient edges in the abstracted graph and estimate transitions. Requires that adata.uns contains a directed single-cell graph with key ['velocity_graph']. |
Implementation Reference
- src/scmcp/schema/tl.py:530-556 (schema)Pydantic model defining the input schema for the 'paga' tool, including parameters like groups, use_rna_velocity, model, and neighbors_key with validation.class PAGAModel(JSONParsingModel): """Input schema for the Partition-based Graph Abstraction (PAGA) tool.""" groups: Optional[str] = Field( default=None, description="Key for categorical in adata.obs. You can pass your predefined groups by choosing any categorical annotation of observations. Default: The first present key of 'leiden' or 'louvain'." ) use_rna_velocity: bool = Field( default=False, description="Use RNA velocity to orient edges in the abstracted graph and estimate transitions. Requires that adata.uns contains a directed single-cell graph with key ['velocity_graph']." ) model: Literal['v1.2', 'v1.0'] = Field( default='v1.2', description="The PAGA connectivity model." ) neighbors_key: Optional[str] = Field( default=None, description="If specified, paga looks .uns[neighbors_key] for neighbors settings and uses the corresponding connectivities and distances." ) @field_validator('model') def validate_model(cls, v: str) -> str: """Validate model version is supported""" if v not in ['v1.2', 'v1.0']: raise ValueError("model must be either 'v1.2' or 'v1.0'") return v
- src/scmcp/tool/tl.py:76-80 (registration)Creates and configures the MCP Tool object for 'paga', linking to the PAGAModel schema.paga_tool = types.Tool( name="paga", description="Partition-based graph abstraction", inputSchema=PAGAModel.model_json_schema(), )
- src/scmcp/tool/tl.py:145-162 (registration)Registers the 'paga' tool in the tl_tools dictionary, which is likely used to expose all tl tools to the MCP server.tl_tools = { "tsne": tsne_tool, "umap": umap_tool, "draw_graph": draw_graph_tool, "diffmap": diffmap_tool, "embedding_density": embedding_density_tool, "leiden": leiden_tool, "louvain": louvain_tool, "dendrogram": dendrogram_tool, "dpt": dpt_tool, "paga": paga_tool, "ingest": ingest_tool, "rank_genes_groups": rank_genes_groups_tool, "filter_rank_genes_groups": filter_rank_genes_groups_tool, "marker_gene_overlap": marker_gene_overlap_tool, "score_genes": score_genes_tool, "score_genes_cell_cycle": score_genes_cell_cycle_tool, }
- src/scmcp/tool/tl.py:164-177 (handler)Generic handler function that executes the 'paga' tool by dispatching to sc.tl.paga (via tl_func['paga']) with validated arguments on the active AnnData object.def run_tl_func(ads, func, arguments): adata = ads.adata_dic[ads.active] if func not in tl_func: raise ValueError(f"Unsupported function: {func}") run_func = tl_func[func] parameters = inspect.signature(run_func).parameters kwargs = {k: arguments.get(k) for k in parameters if k in arguments} try: res = run_func(adata, **kwargs) add_op_log(adata, run_func, kwargs) except Exception as e: logger.error(f"Error running function {func}: {e}") raise return
- src/scmcp/tool/tl.py:125-142 (helper)Maps the 'paga' tool name to the underlying scanpy.tl.paga function for execution.tl_func = { "tsne": sc.tl.tsne, "umap": sc.tl.umap, "draw_graph": sc.tl.draw_graph, "diffmap": sc.tl.diffmap, "embedding_density": sc.tl.embedding_density, "leiden": sc.tl.leiden, "louvain": sc.tl.louvain, "dendrogram": sc.tl.dendrogram, "dpt": sc.tl.dpt, "paga": sc.tl.paga, "ingest": sc.tl.ingest, "rank_genes_groups": sc.tl.rank_genes_groups, "filter_rank_genes_groups": sc.tl.filter_rank_genes_groups, "marker_gene_overlap": sc.tl.marker_gene_overlap, "score_genes": sc.tl.score_genes, "score_genes_cell_cycle": sc.tl.score_genes_cell_cycle, }