Skip to main content
Glama

scale

Standardize single-cell RNA sequencing data by scaling to unit variance and zero mean for preprocessing and analysis.

Instructions

Scale data to unit variance and zero mean

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
zero_centerNoIf False, omit zero-centering variables to handle sparse input efficiently.
max_valueNoClip (truncate) to this value after scaling. If None, do not clip.
layerNoIf provided, which element of layers to scale.
obsmNoIf provided, which element of obsm to scale.
mask_obsNoBoolean mask or string referring to obs column for subsetting observations.

Implementation Reference

  • Generic handler that executes sc.pp.scale (via pp_func['scale']) on the active AnnData object for the 'scale' tool.
    def run_pp_func(ads, func, arguments): adata = ads.adata_dic[ads.active] if func not in pp_func: raise ValueError(f"不支持的函数: {func}") run_func = pp_func[func] parameters = inspect.signature(run_func).parameters arguments["inplace"] = True 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 KeyError as e: raise KeyError(f"Can not foud {e} column in adata.obs or adata.var") except Exception as e: raise e return res
  • Pydantic input schema model for the 'scale' tool, defining parameters and validation.
    class ScaleModel(JSONParsingModel): """Input schema for the scale preprocessing tool.""" zero_center: bool = Field( default=True, description="If False, omit zero-centering variables to handle sparse input efficiently." ) max_value: Optional[float] = Field( default=None, description="Clip (truncate) to this value after scaling. If None, do not clip." ) layer: Optional[str] = Field( default=None, description="If provided, which element of layers to scale." ) obsm: Optional[str] = Field( default=None, description="If provided, which element of obsm to scale." ) mask_obs: Optional[Union[str, bool]] = Field( default=None, description="Boolean mask or string referring to obs column for subsetting observations." ) @field_validator('max_value') def validate_max_value(cls, v: Optional[float]) -> Optional[float]: """Validate max_value is positive if provided""" if v is not None and v <= 0: raise ValueError("max_value must be positive if provided") return v
  • MCP tool registration defining the 'scale' tool name, description, and input schema.
    scale = types.Tool( name="scale", description="Scale data to unit variance and zero mean", inputSchema=ScaleModel.model_json_schema(), )
  • Dictionary mapping tool names to Scanpy functions, with 'scale' mapped to sc.pp.scale used by the handler.
    pp_func = { "filter_genes": sc.pp.filter_genes, "filter_cells": sc.pp.filter_cells, "calculate_qc_metrics": partial(sc.pp.calculate_qc_metrics, inplace=True), "log1p": sc.pp.log1p, "normalize_total": sc.pp.normalize_total, "pca": sc.pp.pca, "highly_variable_genes": sc.pp.highly_variable_genes, "regress_out": sc.pp.regress_out, "scale": sc.pp.scale, "combat": sc.pp.combat, "scrublet": sc.pp.scrublet, "neighbors": sc.pp.neighbors, }
  • Dictionary of registered MCP tools, including the 'scale' tool instance.
    pp_tools = { "filter_genes": filter_genes, "filter_cells": filter_cells, "calculate_qc_metrics": calculate_qc_metrics, "log1p": log1p, "normalize_total": normalize_total, "pca": pca, "highly_variable_genes": highly_variable_genes, "regress_out": regress_out, "scale": scale, "combat": combat, "scrublet": scrublet, "neighbors": neighbors, }

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