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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions filtering but doesn't specify whether this operation is destructive (e.g., modifies the dataset in place), what permissions are required, or what the output looks like (e.g., returns a filtered dataset or just a list). For a tool with potential data mutation implications, this lack of detail is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded with the core action ('filter genes'), making it easy to parse quickly, and every part of the sentence contributes essential information about the filtering criteria.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that likely performs data filtering. It doesn't explain the behavioral implications (e.g., whether filtering is reversible or affects downstream analysis), output format, or error conditions. For a preprocessing tool in a data analysis context, this leaves critical gaps in understanding how to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with each parameter clearly documented (e.g., 'Minimum number of counts required for a gene to pass filtering'). The description adds minimal value beyond this, only hinting at the filtering criteria without providing additional context like default thresholds or interaction effects between parameters. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('filter genes') and the criteria ('based on number of cells or counts'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'filter_cells' or 'filter_rank_genes_groups', which would require more specific context about what distinguishes gene filtering from cell filtering or other filtering operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'filter_cells' and 'filter_rank_genes_groups' available, there's no indication of the specific scenarios or data preprocessing steps where gene filtering is appropriate, leaving the agent to infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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