Skip to main content
Glama

filter_cells

Filter single-cell RNA sequencing data by setting thresholds for gene expression counts and number of genes expressed to identify high-quality cells for analysis.

Instructions

Filter cells based on counts and numbers of genes expressed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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.
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.

Implementation Reference

  • Generic handler function for all preprocessing tools, including filter_cells. Retrieves the scanpy function from pp_func, prepares arguments with inplace=True, executes on active adata, handles exceptions, and logs the operation.
    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 parameters and validation for the filter_cells tool.
    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
  • Creates the MCP types.Tool instance for filter_cells, specifying name, description, and input schema.
    filter_cells = types.Tool( name="filter_cells", description="Filter cells based on counts and numbers of genes expressed.", inputSchema=FilterCells.model_json_schema(), )
  • Registers the filter_cells Tool object in the pp_tools dictionary, which is exposed via server.list_tools().
    "filter_cells": filter_cells,
  • Maps the 'filter_cells' tool name to scanpy's sc.pp.filter_cells function used by the handler.
    "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