Skip to main content
Glama

score_genes_cell_cycle

Analyze and assign cell cycle phases by scoring S and G2M phase genes in single-cell RNA data. Supports gene pool sampling, expression level binning, and custom score naming for detailed cell cycle analysis.

Instructions

Score cell cycle genes and assign cell cycle phases

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
g2m_genesYesList of genes associated with G2M phase.
gene_poolNoGenes for sampling the reference set. Default is all genes.
n_binsNoNumber of expression level bins for sampling.
random_stateNoThe random seed for sampling.
s_genesYesList of genes associated with S phase.
score_nameNoName of the field to be added in .obs. If None, the scores are added as 'S_score' and 'G2M_score'.
use_rawNoWhether to use raw attribute of adata. Defaults to True if .raw is present.

Implementation Reference

  • Pydantic model defining input schema for the score_genes_cell_cycle tool, including required S-phase and G2M-phase gene lists and optional parameters.
    class ScoreGenesCellCycleModel(JSONParsingModel): """Input schema for the score_genes_cell_cycle tool that scores cell cycle genes.""" s_genes: List[str] = Field( ..., # Required field description="List of genes associated with S phase." ) g2m_genes: List[str] = Field( ..., # Required field description="List of genes associated with G2M phase." ) gene_pool: Optional[List[str]] = Field( default=None, description="Genes for sampling the reference set. Default is all genes." ) n_bins: int = Field( default=25, description="Number of expression level bins for sampling.", gt=0 ) score_name: Optional[str] = Field( default=None, description="Name of the field to be added in .obs. If None, the scores are added as 'S_score' and 'G2M_score'." ) random_state: int = Field( default=0, description="The random seed for sampling." ) use_raw: Optional[bool] = Field( default=None, description="Whether to use raw attribute of adata. Defaults to True if .raw is present." ) @field_validator('s_genes', 'g2m_genes') def validate_gene_lists(cls, v: List[str]) -> List[str]: """Validate gene lists are not empty""" if len(v) == 0: raise ValueError("Gene list cannot be empty") return v @field_validator('n_bins') def validate_positive_integers(cls, v: int) -> int: """Validate positive integers""" if v <= 0: raise ValueError("n_bins must be a positive integer") return v
  • Registers the MCP tool 'score_genes_cell_cycle' with name, description, and input schema from ScoreGenesCellCycleModel.
    # Add score_genes_cell_cycle tool score_genes_cell_cycle_tool = types.Tool( name="score_genes_cell_cycle", description="Score cell cycle genes and assign cell cycle phases", inputSchema=ScoreGenesCellCycleModel.model_json_schema(), )
  • Maps the tool name 'score_genes_cell_cycle' to scanpy's sc.tl.score_genes_cell_cycle 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, }
  • Adds the score_genes_cell_cycle_tool to the tl_tools dictionary, likely used for MCP tool listing.
    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, }
  • Executes tl tools: retrieves adata, maps func name to scanpy function via tl_func, inspects parameters, calls with provided arguments, logs operation, handles errors.
    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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/huang-sh/scmcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server