Skip to main content
Glama

pl_scatter

Plot scatter plots of two variables for single-cell RNA sequencing data visualization, enabling analysis of relationships between observations or variables.

Instructions

Plot a scatter plot of two variables, Scatter plot along observations or variables axes.

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.
xNox coordinate.
yNoy coordinate.
colorNoKeys for annotations of observations/cells or variables/genes, or a hex color specification.
use_rawNoWhether to use raw attribute of adata. Defaults to True if .raw is present.
layersNoUse the layers attribute of adata if present: specify the layer for x, y and color.
basisNoBasis to use for embedding.
sort_orderNoFor continuous annotations used as color parameter, plot data points with higher values on top of others.
alphaNoAlpha value for the plot.
groupsNoRestrict to a few categories in categorical observation annotation.
componentsNoFor instance, ['1,2', '2,3']. To plot all available components use components='all'.
projectionNoProjection of plot.2d
right_marginNoAdjust the width of the right margin.
left_marginNoAdjust the width of the left margin.

Implementation Reference

  • Handler function that executes pl_scatter by mapping to sc.pl.scatter, processing arguments, calling the function, saving figure, 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_scatter tool, including fields like x, y, color, alpha, etc., inherited from BaseScatterModel.
    class EnhancedScatterModel(BaseScatterModel):
        """Input schema for the enhanced scatter plotting tool."""
        
        sort_order: bool = Field(
            default=True,
            description="For continuous annotations used as color parameter, plot data points with higher values on top of others."
        )
        
        alpha: Optional[float] = Field(
            default=None,
            description="Alpha value for the plot.",
            ge=0,
            le=1
        )
        
        groups: Optional[Union[str, List[str]]] = Field(
            default=None,
            description="Restrict to a few categories in categorical observation annotation."
        )
        
        components: Optional[Union[str, List[str]]] = Field(
            default=None,
            description="For instance, ['1,2', '2,3']. To plot all available components use components='all'."
        )
        
        projection: Literal['2d', '3d'] = Field(
            default='2d',
            description="Projection of plot."
        )
        
        right_margin: Optional[float] = Field(
            default=None,
            description="Adjust the width of the right margin."
        )
        
        left_margin: Optional[float] = Field(
            default=None,
            description="Adjust the width of the left margin."
        )
        
        @field_validator('alpha')
        def validate_alpha(cls, v: Optional[float]) -> Optional[float]:
            """Validate alpha is between 0 and 1"""
            if v is not None and (v < 0 or v > 1):
                raise ValueError("alpha must be between 0 and 1")
            return v
  • Creates and registers the pl_scatter Tool object with MCP types.Tool, specifying name, description, and input schema.
    pl_scatter = types.Tool(
        name="pl_scatter",
        description="Plot a scatter plot of two variables, Scatter plot along observations or variables axes.",
        inputSchema=EnhancedScatterModel.model_json_schema(),
    )
  • In list_tools MCP endpoint, includes pl_tools.values() (containing pl_scatter) when listing available tools.
    if MODULE == "io":
        tools = io_tools.values()
    elif MODULE == "pp":
        tools = pp_tools.values()
    elif MODULE == "tl":
        tools = tl_tools.values()
    elif MODULE == "pl":
        tools = pl_tools.values()
    elif MODULE == "util":
        tools = util_tools.values()
    else:
        tools = [
            *io_tools.values(),
            *pp_tools.values(),
            *tl_tools.values(),
            *pl_tools.values(),
            *util_tools.values(),
            *ccc_tools.values(),
        ]
    return tools
  • Mapping dictionary pl_func that associates 'pl_scatter' with scanpy's sc.pl.scatter function, 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 plotting but doesn't disclose behavioral traits such as whether it modifies data, requires specific data formats (e.g., AnnData), outputs a plot file or displays it, handles errors, or has performance considerations. The description is too minimal for a tool with 23 parameters.

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 concise with two short phrases, but it's not front-loaded with the most critical information (e.g., data source). It avoids redundancy, but could be more structured to highlight key aspects like input requirements.

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 high complexity (23 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what the tool returns (e.g., a plot object, file path, or visualization), data dependencies, or integration with sibling tools. This leaves significant gaps for an agent to use it effectively.

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 fully documents all 23 parameters. The description adds no parameter-specific information beyond implying two variables are plotted, which is already clear from parameter names like 'x' and 'y'. Baseline score of 3 is appropriate as the schema does the heavy lifting.

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 plots a scatter plot of two variables, which is a clear purpose, but it's vague about what data it operates on (e.g., from an AnnData object common in single-cell analysis) and the phrase 'along observations or variables axes' is ambiguous. It doesn't distinguish from siblings like 'pl_embedding' or 'pl_pca' which might also produce scatter plots.

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?

No guidance is provided on when to use this tool versus alternatives like 'pl_embedding' for embeddings or 'pl_dotplot' for other visualizations. The description lacks context about prerequisites (e.g., requires preprocessed data) or typical use cases, leaving the agent to infer usage.

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