Skip to main content
Glama

combat

Correct batch effects in single-cell RNA sequencing data using a categorical annotation key and optional covariates, enabling accurate downstream analysis without manual coding.

Instructions

ComBat function for batch effect correction

Input Schema

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

Implementation Reference

  • Pydantic model defining the input schema for the 'combat' tool, including batch key and covariates with validation.
    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
  • Registers the 'combat' tool using mcp.types.Tool with name, description, and CombatModel schema.
    combat = types.Tool( name="combat", description="ComBat function for batch effect correction", inputSchema=CombatModel.model_json_schema(), )
  • Handler function that executes preprocessing tools including 'combat' by dispatching to sc.pp.combat with validated arguments and logging.
    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
  • Dictionary mapping tool names to Scanpy functions, with 'combat' mapped to sc.pp.combat for execution.
    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, }
  • Dictionary registering all pp tools including 'combat' Tool object for use in server or init.
    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, }

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