Skip to main content
Glama

pl_embedding

Generate scatter plots for visualizing single-cell RNA sequencing embeddings like UMAP or t-SNE to analyze data patterns and clusters.

Instructions

Scatter plot for user specified embedding basis (e.g. umap, tsne, etc).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
figsizeNoFigure size. Format is (width, height).
color_mapNoColor map to use for continuous variables.
paletteNoColors to use for plotting categorical annotation groups.
vmaxNoThe value representing the upper limit of the color scale.
vminNoThe value representing the lower limit of the color scale.
vcenterNoThe value representing the center of the color scale.
legend_fontsizeNoNumeric size in pt or string describing the size.
legend_fontweightNoLegend font weight. A numeric value in range 0-1000 or a string.bold
legend_locNoLocation of legend, either 'on data', 'right margin' or a valid keyword for the loc parameter.right margin
legend_fontoutlineNoLine width of the legend font outline in pt.
colorNoKeys for annotations of observations/cells or variables/genes.
gene_symbolsNoColumn name in .var DataFrame that stores gene symbols.
use_rawNoUse .raw attribute of adata for coloring with gene expression.
sort_orderNoFor continuous annotations used as color parameter, plot data points with higher values on top of others.
edgesNoShow edges between nodes.
edges_widthNoWidth of edges.
edges_colorNoColor of edges.grey
neighbors_keyNoWhere to look for neighbors connectivities.
arrowsNoShow arrows.
groupsNoRestrict to a few categories in categorical observation annotation.
componentsNoFor instance, ['1,2', '2,3']. To plot all available components use components='all'.
dimensionsNo0-indexed dimensions of the embedding to plot as integers. E.g. [(0, 1), (1, 2)].
layerNoName of the AnnData object layer that wants to be plotted.
projectionNoProjection of plot.2d
sizeNoPoint size. If None, is automatically computed.
frameonNoDraw a frame around the scatter plot.
add_outlineNoAdd outline to scatter plot points.
ncolsNoNumber of columns for multiple plots.
markerNoMatplotlib marker style for points..
basisYesName of the obsm basis to use.
mask_obsNoA boolean array or a string mask expression to subset observations.
arrows_kwdsNoPassed to matplotlib's quiver function for drawing arrows.
scale_factorNoScale factor for the plot.
cmapNoColor map to use for continuous variables. Overrides color_map.
na_colorNoColor to use for null or masked values.lightgray
na_in_legendNoWhether to include null values in the legend.
outline_widthNoWidth of the outline for highlighted points.
outline_colorNoColor of the outline for highlighted points.
colorbar_locNoLocation of the colorbar.right
hspaceNoHeight space between panels.
wspaceNoWidth space between panels.
titleNoTitle for the plot.

Implementation Reference

  • The run_pl_func executes the tool logic for pl_embedding by dispatching to sc.pl.embedding (via pl_func mapping) with validated arguments and handles figure saving and logging.
    def run_pl_func(ads, func, arguments):
        """
        Execute a Scanpy plotting function with the given arguments.
        
        Parameters
        ----------
        adata : AnnData
            Annotated data matrix.
        func : str
            Name of the plotting function to execute.
        arguments : dict
            Arguments to pass to the plotting function.
            
        Returns
        -------
        The result of the plotting function.
        """
        adata = ads.adata_dic[ads.active]
        if func not in pl_func:
            raise ValueError(f"Unsupported function: {func}")
    
        run_func = pl_func[func]
        parameters = inspect.signature(run_func).parameters
        kwargs = {k: arguments.get(k) for k in parameters if k in arguments}    
    
        if "title" not in parameters:
            kwargs.pop("title", False)    
        kwargs.pop("return_fig", True)
        kwargs["show"] = False
        kwargs["save"] = ".png"
        try:
            fig = run_func(adata, **kwargs)
            fig_path = set_fig_path(func, **kwargs)
            add_op_log(adata, run_func, kwargs)
            return fig_path 
        except Exception as e:
            raise e
        return fig_path
  • Pydantic model defining the input schema for the pl_embedding tool, including basis, color, projection, and other scanpy.pl.embedding parameters.
    class EmbeddingModel(BaseEmbeddingModel):
        """Input schema for the embedding plotting tool."""
        
        basis: str = Field(
            ...,  # Required field
            description="Name of the obsm basis to use."
        )
        
        mask_obs: Optional[str] = Field(
            default=None,
            description="A boolean array or a string mask expression to subset observations."
        )
        
        arrows_kwds: Optional[dict] = Field(
            default=None,
            description="Passed to matplotlib's quiver function for drawing arrows."
        )
        
        scale_factor: Optional[float] = Field(
            default=None,
            description="Scale factor for the plot."
        )
        
        cmap: Optional[str] = Field(
            default=None,
            description="Color map to use for continuous variables. Overrides color_map."
        )
        
        na_color: str = Field(
            default="lightgray",
            description="Color to use for null or masked values."
        )
        
        na_in_legend: bool = Field(
            default=True,
            description="Whether to include null values in the legend."
        )
        
        outline_width: Tuple[float, float] = Field(
            default=(0.3, 0.05),
            description="Width of the outline for highlighted points."
        )
        
        outline_color: Tuple[str, str] = Field(
            default=("black", "white"),
            description="Color of the outline for highlighted points."
        )
        
        colorbar_loc: Optional[str] = Field(
            default="right",
            description="Location of the colorbar."
        )
        
        hspace: float = Field(
            default=0.25,
            description="Height space between panels."
        )
        
        wspace: Optional[float] = Field(
            default=None,
            description="Width space between panels."
        )
        
        title: Optional[Union[str, List[str]]] = Field(
            default=None,
            description="Title for the plot."
        )
  • Creates the MCP Tool object for pl_embedding with name, description, and input schema.
    pl_embedding = types.Tool(
        name="pl_embedding",
        description="Scatter plot for user specified embedding basis (e.g. umap, tsne, etc).",
        inputSchema=EmbeddingModel.model_json_schema(),
    )
  • Adds the pl_embedding tool to the pl_tools dictionary, which is used by the server to list and dispatch tools.
    pl_tools = {
        "pl_pca": pl_pca_tool,
        "pl_embedding": pl_embedding,  # Add the new embedding tool
        # "diffmap": diffmap,
        "pl_violin": pl_violin,
        "pl_stacked_violin": pl_stacked_violin,
        "pl_heatmap": pl_heatmap,
        "pl_dotplot": pl_dotplot,
        "pl_matrixplot": pl_matrixplot,
        "pl_tracksplot": pl_tracksplot,
        "pl_scatter": pl_scatter,
        # "embedding_density": embedding_density,
        # "spatial": spatial,
        # "rank_genes_groups": rank_genes_groups,
        "pl_rank_genes_groups_dotplot": pl_rank_genes_groups_dotplot,  # Add tool mapping
        # "pl_clustermap": pl_clustermap,
        "pl_highly_variable_genes": pl_highly_variable_genes,
        "pl_pca_variance_ratio": pl_pca_variance_ratio,
    }
  • Maps 'pl_embedding' to the underlying scanpy function sc.pl.embedding used by the handler.
    pl_func = {
        "pl_pca": sc.pl.pca,
        "pl_embedding": sc.pl.embedding,  # Add the new embedding function
        "diffmap": sc.pl.diffmap,
        "pl_violin": sc.pl.violin,
        "pl_stacked_violin": sc.pl.stacked_violin,
        "pl_heatmap": sc.pl.heatmap,
        "pl_dotplot": sc.pl.dotplot,
        "pl_matrixplot": sc.pl.matrixplot,
        "pl_tracksplot": sc.pl.tracksplot,
        "pl_scatter": sc.pl.scatter,
        "embedding_density": sc.pl.embedding_density,
        "rank_genes_groups": sc.pl.rank_genes_groups,
        "pl_rank_genes_groups_dotplot": sc.pl.rank_genes_groups_dotplot,  # Add function mapping
        "pl_clustermap": sc.pl.clustermap,
        "pl_highly_variable_genes": sc.pl.highly_variable_genes,
        "pl_pca_variance_ratio": sc.pl.pca_variance_ratio,
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool creates a plot but doesn't disclose behavioral traits like whether it returns an image file, displays the plot, saves it, or modifies data. It also doesn't mention error conditions, performance implications, or dependencies. For a complex plotting tool with 42 parameters, this is a significant gap.

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, efficient sentence that states the core purpose. It's appropriately sized and front-loaded with the main action. However, it could be more structured by including key usage notes, but it avoids unnecessary verbosity.

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 high complexity (42 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what the tool returns (e.g., a plot object, file path, or visualization), how to interpret results, or any side effects. For a plotting tool in a data analysis context, more guidance on output and behavior is needed.

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?

Schema description coverage is 100%, so the schema already documents all 42 parameters thoroughly. The description adds no parameter-specific information beyond implying the 'basis' parameter is for embedding types like UMAP or t-SNE. This meets the baseline of 3 since the schema does the heavy lifting, but the description doesn't compensate with additional context like typical values or interactions.

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

Purpose3/5

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

The description states the tool creates a scatter plot for embeddings, which is a clear purpose. However, it's vague about the specific resource (e.g., what data it plots from) and doesn't distinguish from sibling tools like 'pl_scatter' or 'pl_pca', which also create plots. It mentions 'embedding basis' but doesn't specify this is for AnnData objects or single-cell data.

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

Usage Guidelines2/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 doesn't mention prerequisites (e.g., needing pre-computed embeddings), compare to sibling tools like 'pl_scatter' or 'pl_pca', or specify use cases. The agent must infer usage from the tool name and parameters alone.

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