merge_adata
Combine multiple AnnData objects for single-cell RNA sequencing analysis by concatenating along observations or variables with configurable alignment options.
Instructions
merge multiple adata
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "merge_adata"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| axis | No | Which axis to concatenate along. 'obs' or 0 for observations, 'var' or 1 for variables. | obs |
| join | No | How to align values when concatenating. If 'outer', the union of the other axis is taken. If 'inner', the intersection. | inner |
| merge | No | How elements not aligned to the axis being concatenated along are selected. | |
| uns_merge | No | How the elements of .uns are selected. Uses the same set of strategies as the merge argument, except applied recursively. | |
| label | No | label different adata, Column in axis annotation (i.e. .obs or .var) to place batch information in. | |
| keys | No | Names for each object being added. These values are used for column values for label or appended to the index if index_unique is not None. | |
| index_unique | No | Whether to make the index unique by using the keys. If provided, this is the delimiter between '{orig_idx}{index_unique}{key}'. | |
| fill_value | No | When join='outer', this is the value that will be used to fill the introduced indices. | |
| pairwise | No | Whether pairwise elements along the concatenated dimension should be included. |
Implementation Reference
- src/scmcp/tool/util.py:84-88 (handler)The core handler function that merges multiple AnnData objects using anndata.concat, taking adata_dic and kwargs.
def merge_adata(adata_dic, **kwargs): import anndata as ad adata = ad.concat(adata_dic, **kwargs) return adata - src/scmcp/schema/util.py:53-92 (schema)Pydantic model defining the input schema for the merge_adata tool, including parameters like axis, join, merge, etc., passed via kwargs to ad.concat.
class ConcatAdataModel(JSONParsingModel): """Model for concatenating AnnData objects""" axis: Literal['obs', 0, 'var', 1] = Field( default='obs', description="Which axis to concatenate along. 'obs' or 0 for observations, 'var' or 1 for variables." ) join: Literal['inner', 'outer'] = Field( default='inner', description="How to align values when concatenating. If 'outer', the union of the other axis is taken. If 'inner', the intersection." ) merge: Optional[Literal['same', 'unique', 'first', 'only']] = Field( default=None, description="How elements not aligned to the axis being concatenated along are selected." ) uns_merge: Optional[Literal['same', 'unique', 'first', 'only']] = Field( default=None, description="How the elements of .uns are selected. Uses the same set of strategies as the merge argument, except applied recursively." ) label: Optional[str] = Field( default=None, description="label different adata, Column in axis annotation (i.e. .obs or .var) to place batch information in. " ) keys: Optional[List[str]] = Field( default=None, description="Names for each object being added. These values are used for column values for label or appended to the index if index_unique is not None." ) index_unique: Optional[str] = Field( default=None, description="Whether to make the index unique by using the keys. If provided, this is the delimiter between '{orig_idx}{index_unique}{key}'." ) fill_value: Optional[Any] = Field( default=None, description="When join='outer', this is the value that will be used to fill the introduced indices." ) pairwise: bool = Field( default=False, description="Whether pairwise elements along the concatenated dimension should be included." ) - src/scmcp/tool/util.py:40-44 (registration)Registers the merge_adata tool as an MCP types.Tool, specifying name, description, and input schema.
merge_adata_tool = types.Tool( name="merge_adata", description="merge multiple adata", inputSchema=ConcatAdataModel.model_json_schema(), ) - src/scmcp/tool/util.py:98-104 (registration)Registers the merge_adata_tool in the util_tools dictionary for tool dispatching.
util_tools = { "mark_var": mark_var_tool, "list_var": list_var_tool, "list_obs": list_obs_tool, "check_gene": check_gene_tool, "merge_adata": merge_adata_tool, } - src/scmcp/tool/util.py:114-119 (helper)Special handling in run_util_func for merge_adata, which merges all adata_dic and updates the active adata.
if func == "merge_adata": res = merge_adata(ads.adata_dic) ads.adata_dic = {} ads.active = "merge_adata" ads.adata_dic[ads.active] = res else: