Skip to main content
Glama

filter_cells

Filter single-cell RNA sequencing data by defining minimum and maximum thresholds for gene expression counts and the number of genes expressed to isolate relevant cell populations.

Instructions

Filter cells based on counts and numbers of genes expressed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_countsNoMaximum number of counts required for a cell to pass filtering.
max_genesNoMaximum number of genes expressed required for a cell to pass filtering.
min_countsNoMinimum number of counts required for a cell to pass filtering.
min_genesNoMinimum number of genes expressed required for a cell to pass filtering.

Implementation Reference

  • Generic handler function for all preprocessing (pp) tools, including 'filter_cells'. It retrieves the Scanpy function sc.pp.filter_cells from pp_func dict, extracts relevant kwargs from input arguments, sets inplace=True, calls the function on the active AnnData object, logs the operation, and handles exceptions like missing columns.
    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 model defining the input schema for the filter_cells tool, including parameters like min_counts, min_genes, max_counts, max_genes with validation for positive integers.
    class FilterCells(JSONParsingModel): """Input schema for the filter_cells preprocessing tool.""" min_counts: Optional[int] = Field( default=None, description="Minimum number of counts required for a cell to pass filtering." ) min_genes: Optional[int] = Field( default=None, description="Minimum number of genes expressed required for a cell to pass filtering." ) max_counts: Optional[int] = Field( default=None, description="Maximum number of counts required for a cell to pass filtering." ) max_genes: Optional[int] = Field( default=None, description="Maximum number of genes expressed required for a cell to pass filtering." ) @field_validator('min_counts', 'min_genes', 'max_counts', 'max_genes') def validate_positive_integers(cls, v: Optional[int]) -> Optional[int]: """验证整数参数为正数""" if v is not None and v <= 0: raise ValueError("过滤参数必须是正整数") return v
  • Registers the filter_cells tool using mcp.types.Tool with name, description, and input schema from FilterCells model.
    filter_cells = types.Tool( name="filter_cells", description="Filter cells based on counts and numbers of genes expressed.", inputSchema=FilterCells.model_json_schema(), )
  • Adds the filter_cells tool to the pp_tools dictionary, which is used for tool registration in the MCP server.
    "filter_cells": filter_cells,
  • Maps the tool name 'filter_cells' to the underlying Scanpy function sc.pp.filter_cells in the pp_func dictionary, used by the handler to execute the tool logic.
    "filter_cells": sc.pp.filter_cells,

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