ccc_dot_plot
Generate a dotplot to visualize cell-cell communication interactions, filtering and customizing results by specificity, size, color, and specific cell labels for clearer biological insights.
Instructions
Visualize cell-cell communication interactions using a dotplot.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cmap | No | Colour map to use for plotting. | viridis |
| colour | No | Column in liana_res to define the colours of the dots. | |
| figure_size | No | Figure x,y size. | |
| inverse_colour | No | Whether to -log10 the colour column for plotting. | |
| inverse_size | No | Whether to -log10 the size column for plotting. | |
| ligand_complex | No | List of ligand complexes to filter the interactions to be plotted. | |
| orderby | No | If top_n is not None, order the interactions by this column. | |
| orderby_absolute | No | If top_n is not None, whether to order by the absolute value of the orderby column. | |
| orderby_ascending | No | If top_n is not None, specify how to order the interactions. | |
| receptor_complex | No | List of receptor complexes to filter the interactions to be plotted. | |
| size | No | Column in liana_res to define the size of the dots. | |
| size_range | No | Define size range. Tuple of (min, max) integers. | |
| source_labels | No | List of labels to use as source, the rest are filtered out. | |
| specificity_cutoff | No | Specificity or p-value threshold for filtering results. | |
| target_labels | No | List of labels to use as target, the rest are filtered out. | |
| top_n | No | Top N entities to plot. | |
| uns_key | No | Key in adata.uns that contains the LIANA results. | liana_res |
Implementation Reference
- src/scmcp/tool/ccc.py:75-90 (handler)Handler function plot_dotplot that wraps liana.pl.dotplot to visualize cell-cell communication interactions as a dotplot, handling filtering by p-value and parameter inspection.def plot_dotplot(adata, **kwargs): pval = kwargs.pop("specificity_cutoff", 0.05) res_key = kwargs.get("uns_key", "liana_res") pval_col = adata.uns[res_key].columns[-1] kwargs["filter_fun"] = lambda x: x[pval_col] <= pval if kwargs.get("colour", None) is None: kwargs["colour"] = adata.uns[res_key].columns[-2] if kwargs.get("size", None) is None: kwargs["size"] = adata.uns[res_key].columns[-1] parameters = inspect.signature(li.pl.dotplot).parameters kwargs = {k: kwargs.get(k) for k in parameters if k in kwargs} fig = li.pl.dotplot(adata, **kwargs) return fig
- src/scmcp/schema/ccc.py:315-407 (schema)Pydantic model defining the input schema for the ccc_dot_plot tool, including parameters for filtering, ordering, and styling the dotplot.class DotPlotModel(JSONParsingModel): """Input schema for LIANA's dotplot visualization for cell-cell communication networks.""" uns_key: str = Field( default="liana_res", description="Key in adata.uns that contains the LIANA results." ) specificity_cutoff: float = Field( default=0.05, description="specificity or pval threshold for filtering results. " ) colour: Optional[str] = Field( default=None, description="Column in liana_res to define the colours of the dots." ) size: Optional[str] = Field( default=None, description="Column in liana_res to define the size of the dots." ) source_labels: Optional[Union[List[str], str]] = Field( default=None, description="List of labels to use as source, the rest are filtered out." ) target_labels: Optional[Union[List[str], str]] = Field( default=None, description="List of labels to use as target, the rest are filtered out." ) top_n: Optional[int] = Field( default=None, description="Top N entities to plot." ) orderby: Optional[str] = Field( default=None, description="If top_n is not None, order the interactions by this column." ) orderby_ascending: Optional[bool] = Field( default=None, description="If top_n is not None, specify how to order the interactions." ) orderby_absolute: bool = Field( default=False, description="If top_n is not None, whether to order by the absolute value of the orderby column." ) ligand_complex: Optional[Union[List[str], str]] = Field( default=None, description="List of ligand complexes to filter the interactions to be plotted." ) receptor_complex: Optional[Union[List[str], str]] = Field( default=None, description="List of receptor complexes to filter the interactions to be plotted." ) inverse_colour: bool = Field( default=False, description="Whether to -log10 the colour column for plotting." ) inverse_size: bool = Field( default=False, description="Whether to -log10 the size column for plotting." ) cmap: str = Field( default="viridis", description="Colour map to use for plotting." ) size_range: Tuple[int, int] = Field( default=(2, 9), description="Define size range. Tuple of (min, max) integers." ) figure_size: Tuple[float, float] = Field( default=(8, 6), description="Figure x,y size." ) specificity_cutoff: float = Field( default=0.05, description="Specificity or p-value threshold for filtering results." )
- src/scmcp/tool/ccc.py:36-40 (registration)MCP Tool registration for ccc_dot_plot, specifying name, description, and input schema.dot_plot_tool = types.Tool( name="ccc_dot_plot", description="Visualize cell-cell communication interactions using a dotplot.", inputSchema=DotPlotModel.model_json_schema(), )
- src/scmcp/tool/ccc.py:100-106 (registration)Dictionary registering the ccc_dot_plot tool along with other CCC tools for dispatch.ccc_tools = { "ls_ccc_method": ls_ccc_method_tool, "ccc_rank_aggregate": rank_aggregate_tool, "ccc_circle_plot": circle_plot_tool, "ccc_dot_plot": dot_plot_tool, "ccc": ccc_tool, }
- src/scmcp/tool/ccc.py:109-141 (helper)General dispatcher function run_ccc_func that executes the tool handler based on the tool name, handles plotting by saving figures, and logs operations.def run_ccc_func(ads, func, arguments): if func not in ccc_func: raise ValueError(f"不支持的函数: {func}") run_func = ccc_func[func] adata = ads.adata_dic[ads.active] try: logger.info(f"Running function {func} with arguments {arguments}") if func == "ls_ccc_method": res = run_func() elif func == "ccc": # Extract method from arguments and pass remaining args method = arguments.get("method", "cellphonedb") method_args = {k: v for k, v in arguments.items() if k != "method"} res = run_func(adata, method, **method_args) elif "plot" in func: from ..util import savefig ax = run_func(adata, **arguments) fig_path = Path(os.getcwd()) / f"figures/{func}.png" res = savefig(ax, fig_path, format="png") add_op_log(adata, run_func, arguments) # else: parameters = inspect.signature(run_func).parameters kwargs = {k: arguments.get(k) for k in parameters if k in arguments} res = run_func(adata, **kwargs) add_op_log(adata, run_func, kwargs) return res except Exception as e: logger.error(f"Error running function {func}: {e}") raise e