pl_dotplot
Generate dot plots to visualize gene expression values across groups, enabling insights into single-cell RNA sequencing data through customizable visual parameters.
Instructions
Plot dot plot of expression values per gene for each group.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color_map | No | Color map to use for continuous variables. | |
| colorbar_title | No | Title for the color bar. New line character (\n) can be used. | Mean expression in group |
| dendrogram | No | If True or a valid dendrogram key, a dendrogram based on the hierarchical clustering between the groupby categories is added. | |
| dot_max | No | The maximum size of the dots. | |
| dot_min | No | The minimum size of the dots. | |
| expression_cutoff | No | Expression cutoff that is used for binarizing the gene expression. | |
| figsize | No | Figure size. Format is (width, height). | |
| gene_symbols | No | Column name in .var DataFrame that stores gene symbols. | |
| groupby | Yes | The key of the observation grouping to consider. | |
| layer | No | Name of the AnnData object layer that wants to be plotted. | |
| legend_fontoutline | No | Line width of the legend font outline in pt. | |
| legend_fontsize | No | Numeric size in pt or string describing the size. | |
| legend_fontweight | No | Legend font weight. A numeric value in range 0-1000 or a string. | bold |
| legend_loc | No | Location of legend, either 'on data', 'right margin' or a valid keyword for the loc parameter. | right margin |
| log | No | Plot on logarithmic axis. | |
| mean_only_expressed | No | If True, gene expression is averaged only over the cells expressing the given genes. | |
| palette | No | Colors to use for plotting categorical annotation groups. | |
| size_title | No | Title for the size legend. New line character (\n) can be used. | Fraction of cells in group (%) |
| smallest_dot | No | The smallest dot size. | |
| standard_scale | No | Whether or not to standardize that dimension between 0 and 1. | |
| swap_axes | No | By default, the x axis contains var_names and the y axis the groupby categories. By setting swap_axes then x are the groupby categories and y the var_names. | |
| use_raw | No | Use raw attribute of adata if present. | |
| var_group_labels | No | Labels for each of the var_group_positions that want to be highlighted. | |
| var_group_positions | No | Use this parameter to highlight groups of var_names with brackets or color blocks between the given start and end positions. | |
| var_group_rotation | No | Label rotation degrees. By default, labels larger than 4 characters are rotated 90 degrees. | |
| var_names | No | var_names should be a valid subset of adata.var_names or a mapping where the key is used as label to group the values. | |
| vcenter | No | The value representing the center of the color scale. | |
| vmax | No | The value representing the upper limit of the color scale. | |
| vmin | No | The value representing the lower limit of the color scale. |
Implementation Reference
- src/scmcp/tool/pl.py:179-217 (handler)Generic handler that implements the pl_dotplot tool (and others). Looks up sc.pl.dotplot from pl_func dict based on func='pl_dotplot', calls it on active adata with inspected and filtered kwargs, saves the figure, logs the operation, returns fig_path.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
- src/scmcp/schema/pl.py:524-575 (schema)Pydantic model defining the input schema (parameters and validation) for the pl_dotplot tool.class DotplotModel(BaseMatrixModel): """Input schema for the dotplot plotting tool.""" expression_cutoff: float = Field( default=0.0, description="Expression cutoff that is used for binarizing the gene expression." ) mean_only_expressed: bool = Field( default=False, description="If True, gene expression is averaged only over the cells expressing the given genes." ) standard_scale: Optional[Literal['var', 'group']] = Field( default=None, description="Whether or not to standardize that dimension between 0 and 1." ) swap_axes: bool = Field( default=False, description="By default, the x axis contains var_names and the y axis the groupby categories. By setting swap_axes then x are the groupby categories and y the var_names." ) dot_max: Optional[float] = Field( default=None, description="The maximum size of the dots." ) dot_min: Optional[float] = Field( default=None, description="The minimum size of the dots." ) smallest_dot: Optional[float] = Field( default=None, description="The smallest dot size." ) var_group_rotation: Optional[float] = Field( default=None, description="Label rotation degrees. By default, labels larger than 4 characters are rotated 90 degrees." ) colorbar_title: Optional[str] = Field( default='Mean expression\nin group', description="Title for the color bar. New line character (\\n) can be used." ) size_title: Optional[str] = Field( default='Fraction of cells\nin group (%)', description="Title for the size legend. New line character (\\n) can be used." )
- src/scmcp/tool/pl.py:48-52 (registration)Registers the pl_dotplot tool using mcp.types.Tool with name and input schema reference.pl_dotplot = types.Tool( name="pl_dotplot", description="Plot dot plot of expression values per gene for each group.", inputSchema=DotplotModel.model_json_schema(), )
- src/scmcp/tool/pl.py:148-148 (registration)Adds the pl_dotplot tool to the pl_tools dictionary used for tool registration in the package."pl_dotplot": pl_dotplot,
- src/scmcp/tool/pl.py:121-138 (helper)Maps the tool name 'pl_dotplot' to the underlying scanpy function sc.pl.dotplot, 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, }