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, }

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