Skip to main content
Glama

combat

Correct batch effects in single-cell RNA sequencing data to improve analysis accuracy by removing technical variations between experimental batches.

Instructions

ComBat function for batch effect correction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNoKey to a categorical annotation from adata.obs that will be used for batch effect removal.batch
covariatesNoAdditional covariates besides the batch variable such as adjustment variables or biological condition.

Implementation Reference

  • Generic handler that executes the 'combat' tool by retrieving sc.pp.combat from pp_func, preparing arguments (including inplace=True), calling it on the active adata, handling errors, and logging 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 schema for the 'combat' tool: 'key' (default 'batch') for the batch annotation column in adata.obs, and optional 'covariates' list of additional adjustment variables.
    class CombatModel(JSONParsingModel):
        """Input schema for the combat batch effect correction tool."""
        
        key: str = Field(
            default='batch',
            description="Key to a categorical annotation from adata.obs that will be used for batch effect removal."
        )
        
        covariates: Optional[List[str]] = Field(
            default=None,
            description="Additional covariates besides the batch variable such as adjustment variables or biological condition."
        )
        
        @field_validator('key')
        def validate_key(cls, v: str) -> str:
            """Validate key is not empty"""
            if not v.strip():
                raise ValueError("key cannot be empty")
            return v
        
        @field_validator('covariates')
        def validate_covariates(cls, v: Optional[List[str]]) -> Optional[List[str]]:
            """Validate covariates are non-empty strings if provided"""
            if v is not None:
                if not all(isinstance(item, str) and item.strip() for item in v):
                    raise ValueError("covariates must be non-empty strings")
            return v
  • Creates the MCP Tool instance for 'combat' with description and input schema from CombatModel.
    combat = types.Tool(
        name="combat",
        description="ComBat function for batch effect correction",
        inputSchema=CombatModel.model_json_schema(),
    )
  • Dictionary mapping tool names to their corresponding scanpy preprocessing functions; 'combat' maps to sc.pp.combat, the core batch correction function.
    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,
    }
  • Registers all preprocessing tools including 'combat' in the pp_tools dictionary for tool dispatching.
    # 模型与函数名称的映射
    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,
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral information. It mentions 'batch effect correction' which implies data transformation, but doesn't disclose whether this is destructive (modifies input data), requires specific data formats, has computational requirements, or what the output looks like. Significant behavioral gaps remain.

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

Conciseness4/5

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

The description is extremely concise - a single sentence that directly states the tool's function. There's no wasted language or unnecessary elaboration. However, the brevity comes at the cost of completeness, making it more under-specified than optimally concise.

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?

For a data transformation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, what data format it expects, whether it modifies data in-place, or how it differs from other correction methods. Given the complexity of batch effect correction and lack of structured metadata, more context is needed.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional parameter information beyond what's in the schema. According to scoring rules, with high schema coverage (>80%), the baseline is 3 even with no param info in description.

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

Purpose3/5

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

The description states the tool performs 'batch effect correction' using the 'ComBat function', which is a specific statistical method. However, it doesn't clearly distinguish this from sibling tools like 'regress_out' or 'scale' that might also address data normalization or correction. The purpose is clear but lacks sibling differentiation.

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?

No guidance is provided about when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., requires normalized data), when batch correction is appropriate, or what alternatives exist among the many sibling tools for data processing and normalization.

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