Skip to main content
Glama

filter_genes

Filter genes in single-cell RNA sequencing data by setting thresholds for cell expression counts to identify relevant biological markers.

Instructions

Filter genes based on number of cells or counts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
min_countsNoMinimum number of counts required for a gene to pass filtering.
min_cellsNoMinimum number of cells expressed required for a gene to pass filtering.
max_countsNoMaximum number of counts required for a gene to pass filtering.
max_cellsNoMaximum number of cells expressed required for a gene to pass filtering.

Implementation Reference

  • Handler function that executes 'filter_genes' by dispatching to sc.pp.filter_genes based on the tool name.
    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 filter_genes tool defining parameters like min_cells, min_counts, max_counts, max_cells with validation.
    class FilterGenes(JSONParsingModel): """Input schema for the filter_genes preprocessing tool.""" min_counts: Optional[int] = Field( default=None, description="Minimum number of counts required for a gene to pass filtering." ) min_cells: Optional[int] = Field( default=None, description="Minimum number of cells expressed required for a gene to pass filtering." ) max_counts: Optional[int] = Field( default=None, description="Maximum number of counts required for a gene to pass filtering." ) max_cells: Optional[int] = Field( default=None, description="Maximum number of cells expressed required for a gene to pass filtering." ) @field_validator('min_counts', 'min_cells', 'max_counts', 'max_cells') def validate_positive_integers(cls, v: Optional[int]) -> Optional[int]: """验证整数参数为正数""" if v is not None and v <= 0: raise ValueError("must be positive_integers") return v
  • MCP Tool registration defining the filter_genes tool with name, description, and input schema.
    filter_genes = types.Tool( name="filter_genes", description="Filter genes based on number of cells or counts", inputSchema=FilterGenes.model_json_schema(), )
  • Dictionary mapping tool names to their corresponding scanpy preprocessing functions, including filter_genes to sc.pp.filter_genes.
    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, }
  • Dispatch logic in MCP call_tool handler that routes filter_genes (in pp_tools) to run_pp_func.
    elif name in pp_tools.keys(): res = run_pp_func(ads, name, arguments)

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