Skip to main content
Glama

merge_adata

Combine multiple AnnData objects along specified axes (observations or variables) using customizable alignment and merging strategies. Supports inner and outer joins, index uniqueness, and batch labeling for enhanced single-cell RNA sequencing data integration.

Instructions

merge multiple adata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
axisNoWhich axis to concatenate along. 'obs' or 0 for observations, 'var' or 1 for variables.obs
fill_valueNoWhen join='outer', this is the value that will be used to fill the introduced indices.
index_uniqueNoWhether to make the index unique by using the keys. If provided, this is the delimiter between '{orig_idx}{index_unique}{key}'.
joinNoHow to align values when concatenating. If 'outer', the union of the other axis is taken. If 'inner', the intersection.inner
keysNoNames 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.
labelNolabel different adata, Column in axis annotation (i.e. .obs or .var) to place batch information in.
mergeNoHow elements not aligned to the axis being concatenated along are selected.
pairwiseNoWhether pairwise elements along the concatenated dimension should be included.
uns_mergeNoHow the elements of .uns are selected. Uses the same set of strategies as the merge argument, except applied recursively.

Implementation Reference

  • The core handler function implementing the merge_adata tool logic by concatenating AnnData objects from a dictionary using anndata.concat.
    def merge_adata(adata_dic, **kwargs): import anndata as ad adata = ad.concat(adata_dic, **kwargs) return adata
  • Pydantic model defining the input schema parameters for the merge_adata tool, matching anndata.concat options.
    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." )
  • MCP Tool registration for merge_adata, specifying name, description, and input schema.
    merge_adata_tool = types.Tool( name="merge_adata", description="merge multiple adata", inputSchema=ConcatAdataModel.model_json_schema(), )
  • Registration of the merge_adata tool in the util_tools dictionary, which is exposed via tool/__init__.py.
    "merge_adata": merge_adata_tool,
  • Special handling in run_util_func for merge_adata, which operates on all adata_dic entries 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:

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