Skip to main content
Glama

dendrogram

Generate hierarchical clustering dendrograms for single-cell RNA sequencing data. Group observations, specify correlation methods, and customize clustering parameters to visualize relationships in SCMCP MCP server.

Instructions

Hierarchical clustering dendrogram

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cor_methodNoCorrelation method to use: 'pearson', 'kendall', or 'spearman'.pearson
groupbyYesThe categorical observation annotation to use for grouping.
key_addedNoBy default, the dendrogram information is added to .uns[f'dendrogram_{groupby}'].
linkage_methodNoLinkage method to use for hierarchical clustering.complete
n_pcsNoUse this many PCs. If n_pcs==0 use .X if use_rep is None.
optimal_orderingNoReorders the linkage matrix so that the distance between successive leaves is minimal.
use_rawNoOnly when var_names is not None. Use raw attribute of adata if present.
use_repNoUse the indicated representation. 'X' or any key for .obsm is valid.
var_namesNoList of var_names to use for computing the hierarchical clustering. If provided, use_rep and n_pcs are ignored.

Implementation Reference

  • Handler function that executes the tool logic for 'dendrogram' by calling the mapped Scanpy function sc.tl.dendrogram with input parameters.
    def run_tl_func(ads, func, arguments): adata = ads.adata_dic[ads.active] if func not in tl_func: raise ValueError(f"Unsupported function: {func}") run_func = tl_func[func] parameters = inspect.signature(run_func).parameters 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 Exception as e: logger.error(f"Error running function {func}: {e}") raise return
  • Pydantic model defining the input schema and validation for the dendrogram tool.
    class DendrogramModel(JSONParsingModel): """Input schema for the hierarchical clustering dendrogram tool.""" groupby: str = Field( ..., # Required field description="The categorical observation annotation to use for grouping." ) n_pcs: Optional[int] = Field( default=None, description="Use this many PCs. If n_pcs==0 use .X if use_rep is None.", ge=0 ) use_rep: Optional[str] = Field( default=None, description="Use the indicated representation. 'X' or any key for .obsm is valid." ) var_names: Optional[List[str]] = Field( default=None, description="List of var_names to use for computing the hierarchical clustering. If provided, use_rep and n_pcs are ignored." ) use_raw: Optional[bool] = Field( default=None, description="Only when var_names is not None. Use raw attribute of adata if present." ) cor_method: str = Field( default='pearson', description="Correlation method to use: 'pearson', 'kendall', or 'spearman'." ) linkage_method: str = Field( default='complete', description="Linkage method to use for hierarchical clustering." ) optimal_ordering: bool = Field( default=False, description="Reorders the linkage matrix so that the distance between successive leaves is minimal." ) key_added: Optional[str] = Field( default=None, description="By default, the dendrogram information is added to .uns[f'dendrogram_{groupby}']." ) @field_validator('cor_method') def validate_cor_method(cls, v: str) -> str: """Validate correlation method is supported""" valid_methods = ['pearson', 'kendall', 'spearman'] if v.lower() not in valid_methods: raise ValueError(f"cor_method must be one of {valid_methods}") return v.lower() @field_validator('linkage_method') def validate_linkage_method(cls, v: str) -> str: """Validate linkage method is supported""" valid_methods = ['single', 'complete', 'average', 'weighted', 'centroid', 'median', 'ward'] if v.lower() not in valid_methods: raise ValueError(f"linkage_method must be one of {valid_methods}") return v.lower() @field_validator('n_pcs') def validate_n_pcs(cls, v: Optional[int]) -> Optional[int]: """Validate n_pcs is non-negative""" if v is not None and v < 0: raise ValueError("n_pcs must be a non-negative integer") return v
  • Registration of the MCP tool object for 'dendrogram', specifying name, description, and input schema.
    # Add dendrogram tool dendrogram_tool = types.Tool( name="dendrogram", description="Hierarchical clustering dendrogram", inputSchema=DendrogramModel.model_json_schema(), )
  • Addition of the dendrogram tool to the tl_tools dictionary for registration.
    "dendrogram": dendrogram_tool,
  • Mapping of the 'dendrogram' tool name to the underlying Scanpy function sc.tl.dendrogram used by the handler.
    "dendrogram": sc.tl.dendrogram,

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