Skip to main content
Glama

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
NameRequiredDescriptionDefault
cmapNoColour map to use for plotting.viridis
colourNoColumn in liana_res to define the colours of the dots.
figure_sizeNoFigure x,y size.
inverse_colourNoWhether to -log10 the colour column for plotting.
inverse_sizeNoWhether to -log10 the size column for plotting.
ligand_complexNoList of ligand complexes to filter the interactions to be plotted.
orderbyNoIf top_n is not None, order the interactions by this column.
orderby_absoluteNoIf top_n is not None, whether to order by the absolute value of the orderby column.
orderby_ascendingNoIf top_n is not None, specify how to order the interactions.
receptor_complexNoList of receptor complexes to filter the interactions to be plotted.
sizeNoColumn in liana_res to define the size of the dots.
size_rangeNoDefine size range. Tuple of (min, max) integers.
source_labelsNoList of labels to use as source, the rest are filtered out.
specificity_cutoffNoSpecificity or p-value threshold for filtering results.
target_labelsNoList of labels to use as target, the rest are filtered out.
top_nNoTop N entities to plot.
uns_keyNoKey in adata.uns that contains the LIANA results.liana_res

Implementation Reference

  • 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
  • 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." )
  • 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(), )
  • 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, }
  • 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

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