Skip to main content
Glama

calculate_qc_metrics

Calculate quality control metrics for single-cell RNA sequencing data, including total counts, gene numbers, and mitochondrial/ribosomal percentages to assess data quality.

Instructions

Calculate quality control metrics(common metrics: total counts, gene number, percentage of counts in ribosomal and mitochondrial) for AnnData.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expr_typeNoName of kind of values in X.counts
var_typeNoThe kind of thing the variables are.genes
qc_varsNoKeys for boolean columns of .var which identify variables you could want to control for mark_var tool should be called frist when you want to calculate mt, ribo, hb, and check tool output for var columns
percent_topNoList of ranks (where genes are ranked by expression) at which the cumulative proportion of expression will be reported as a percentage.
layerNoIf provided, use adata.layers[layer] for expression values instead of adata.X
use_rawNoIf True, use adata.raw.X for expression values instead of adata.X
log1pNoSet to False to skip computing log1p transformed annotations.

Implementation Reference

  • Handler function that executes the calculate_qc_metrics tool logic by calling the mapped scanpy.pp.calculate_qc_metrics function on the active AnnData object with provided arguments and inplace=True.
    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 calculate_qc_metrics tool, including fields like qc_vars, percent_top, layer, use_raw, log1p with validation.
    class CalculateQCMetrics(JSONParsingModel): """Input schema for the calculate_qc_metrics preprocessing tool.""" expr_type: str = Field( default="counts", description="Name of kind of values in X." ) var_type: str = Field( default="genes", description="The kind of thing the variables are." ) qc_vars: Optional[Union[List[str], str]] = Field( default=[], description=( "Keys for boolean columns of .var which identify variables you could want to control for " "mark_var tool should be called frist when you want to calculate mt, ribo, hb, and check tool output for var columns" ) ) percent_top: Optional[List[int]] = Field( default=[50, 100, 200, 500], description="List of ranks (where genes are ranked by expression) at which the cumulative proportion of expression will be reported as a percentage." ) layer: Optional[str] = Field( default=None, description="If provided, use adata.layers[layer] for expression values instead of adata.X" ) use_raw: bool = Field( default=False, description="If True, use adata.raw.X for expression values instead of adata.X" ) log1p: bool = Field( default=True, description="Set to False to skip computing log1p transformed annotations." ) @field_validator('percent_top') def validate_percent_top(cls, v: Optional[List[int]]) -> Optional[List[int]]: """验证 percent_top 中的值为正整数""" if v is not None: for rank in v: if not isinstance(rank, int) or rank <= 0: raise ValueError("percent_top 中的所有值必须是正整数") return v
  • MCP Tool object registration defining the name, description, and input schema for calculate_qc_metrics.
    calculate_qc_metrics = types.Tool( name="calculate_qc_metrics", description="Calculate quality control metrics(common metrics: total counts, gene number, percentage of counts in ribosomal and mitochondrial) for AnnData.", inputSchema=CalculateQCMetrics.model_json_schema(), )
  • pp_func dictionary entry mapping the tool name to the wrapped scanpy function partial(sc.pp.calculate_qc_metrics, inplace=True).
    "calculate_qc_metrics": partial(sc.pp.calculate_qc_metrics, inplace=True),
  • pp_tools dictionary that includes the calculate_qc_metrics tool, used by server.list_tools() to expose the tool.
    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