Skip to main content
Glama

regress_out

Remove unwanted variation from single-cell RNA-seq data by regressing out specified observation annotations to improve downstream analysis.

Instructions

Regress out (mostly) unwanted sources of variation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keysYesKeys for observation annotation on which to regress on.
layerNoIf provided, which element of layers to regress on.
n_jobsNoNumber of jobs for parallel computation.

Implementation Reference

  • run_pp_func: Executes regress_out by retrieving sc.pp.regress_out from pp_func map and calling it on the active AnnData object with validated arguments, handling errors and logging operations.
    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
  • RegressOutModel: Pydantic input schema with fields keys (str or list[str]), layer (optional str), n_jobs (optional positive int), and custom validators.
    class RegressOutModel(JSONParsingModel):
        """Input schema for the regress_out preprocessing tool."""
        
        keys: Union[str, List[str]] = Field(
            description="Keys for observation annotation on which to regress on."
        )
        layer: Optional[str] = Field(
            default=None,
            description="If provided, which element of layers to regress on."
        )
        n_jobs: Optional[int] = Field(
            default=None,
            description="Number of jobs for parallel computation.",
            gt=0
        )
        
        @field_validator('n_jobs')
        def validate_n_jobs(cls, v: Optional[int]) -> Optional[int]:
            """Validate n_jobs is positive integer"""
            if v is not None and v <= 0:
                raise ValueError("n_jobs must be a positive integer")
            return v
        
        @field_validator('keys')
        def validate_keys(cls, v: Union[str, List[str]]) -> Union[str, List[str]]:
            """Ensure keys is either a string or list of strings"""
            if isinstance(v, str):
                return v
            elif isinstance(v, list) and all(isinstance(item, str) for item in v):
                return v
            raise ValueError("keys must be a string or list of strings")
  • Registers the regress_out tool as an MCP Tool object with name, description, and schema from RegressOutModel.
    regress_out = types.Tool(
        name="regress_out",
        description="Regress out (mostly) unwanted sources of variation.",
        inputSchema=RegressOutModel.model_json_schema(),
    )
  • pp_func dictionary: Maps 'regress_out' to sc.pp.regress_out, used by run_pp_func to get the actual execution 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,
    }
  • pp_tools dictionary: Registers the regress_out Tool object for use in MCP server list_tools() and call_tool() dispatch.
    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,
    }
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but fails to do so. It does not explain what 'regress out' entails operationally—whether it modifies data in place, requires specific permissions, has side effects, or handles errors. The parenthetical '(mostly)' is ambiguous and unhelpful.

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 a single, brief sentence that is front-loaded and wastes no words. However, its extreme brevity leads to under-specification rather than true conciseness, as it omits necessary details for clarity and usage.

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 complexity implied by the tool name (a statistical regression operation), lack of annotations, and no output schema, the description is incomplete. It does not explain what data is affected, the output format, or how it integrates with other preprocessing tools in the sibling list, leaving significant gaps for an AI agent.

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 schema description coverage is 100%, so the input schema already documents all parameters ('keys', 'layer', 'n_jobs') with clear descriptions. The tool description adds no additional meaning or context about these parameters beyond what the schema provides, meeting the baseline for high schema coverage.

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

Purpose2/5

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

The description 'Regress out (mostly) unwanted sources of variation' is vague and tautological—it essentially restates the tool name 'regress_out' without specifying what is being regressed or in what context. It does not clearly distinguish this tool from sibling tools like 'combat' or 'scale', which might also handle variation reduction in data preprocessing.

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

Usage Guidelines1/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. It does not mention any specific scenarios, prerequisites, or comparisons to sibling tools such as 'combat' or 'normalize_total', leaving the agent with no usage context.

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