Skip to main content
Glama

ccc

Analyze cell-cell communication in single-cell RNA sequencing data using multiple methods to identify ligand-receptor interactions between cell types.

Instructions

Cell-cell communication analysis with one method (cellphonedb, cellchat,connectome, natmi, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNocell-cell communication methodcellphonedb
groupbyYesKey to be used for grouping cells (e.g., cell type annotations).
resource_nameNoName of the resource to be used for ligand-receptor inference. See `li.rs.show_resources()` for available resources.consensus
expr_propNoMinimum expression proportion for the ligands and receptors in the corresponding cell identities. Set to 0 to return unfiltered results.
min_cellsNoMinimum cells per cell identity to be considered for downstream analysis.
baseNoExponent base used to reverse the log-transformation of the matrix. Relevant only for the `logfc` method.
return_all_lrsNoWhether to return all ligand-receptor pairs, or only those that surpass the expr_prop threshold.
key_addedNoKey under which the results will be stored in adata.uns.liana_res
use_rawNoUse raw attribute of adata if present.
layerNoLayer in AnnData.layers to use. If None, use AnnData.X.
de_methodNoDifferential expression method used to rank genes according to 1vsRest.t-test
n_permsNoNumber of permutations for the permutation test. Relevant for CellPhoneDB method.
seedNoRandom seed for reproducibility.
n_jobsNoNumber of jobs to run in parallel.
verboseNoWhether to print verbose output.
inplaceNoWhether to store results in place, or return them.
supp_columnsNoAdditional columns to be added from methods in liana, or columns from scanpy.tl.rank_genes_groups.

Implementation Reference

  • Core handler function `run_ccc` that performs the cell-cell communication analysis by dynamically calling the specified LIANA method function.
    def run_ccc(adata, method, **kwargs):
        """Run cell-cell communication analysis with the specified method."""
        method_func = getattr(li.mt, method)
        parameters = inspect.signature(method_func).parameters
        filtered_kwargs = {k: kwargs.get(k) for k in parameters if k in kwargs}
        # filtered_kwargs["key_added"] = f"{method}_res"
        method_func(adata, **filtered_kwargs)
        add_op_log(adata, method_func, filtered_kwargs)
        return adata
  • Pydantic model defining the input schema for the 'ccc' tool, used in inputSchema=CCCModel.model_json_schema().
    class CCCModel(JSONParsingModel):
        """Input schema for LIANA's cell-cell communication analysis."""
        
        method: Literal[
            "singlecellsignalr", 
            "connectome", 
            "cellphonedb", 
            "natmi", 
            "logfc", 
            "cellchat", 
            "geometric_mean", 
            "scseqcomm"
        ] = Field(
            default="cellphonedb",
            description="cell-cell communication method"
        )
        
        groupby: str = Field(
            ...,  # Required field
            description="Key to be used for grouping cells (e.g., cell type annotations)."
        )
        
        resource_name: str = Field(
            default="consensus",
            description="Name of the resource to be used for ligand-receptor inference. See `li.rs.show_resources()` for available resources."
        )
        
        expr_prop: float = Field(
            default=0.1,
            description="Minimum expression proportion for the ligands and receptors in the corresponding cell identities. Set to 0 to return unfiltered results."
        )
        
        min_cells: int = Field(
            default=5,
            description="Minimum cells per cell identity to be considered for downstream analysis."
        )
        
        base: float = Field(
            default=2.718281828459045,  # e
            description="Exponent base used to reverse the log-transformation of the matrix. Relevant only for the `logfc` method."
        )
        
        return_all_lrs: bool = Field(
            default=False,
            description="Whether to return all ligand-receptor pairs, or only those that surpass the expr_prop threshold."
        )
        
        key_added: str = Field(
            default="liana_res",
            description="Key under which the results will be stored in adata.uns."
        )
        
        use_raw: Optional[bool] = Field(
            default=True,
            description="Use raw attribute of adata if present."
        )
        
        layer: Optional[str] = Field(
            default=None,
            description="Layer in AnnData.layers to use. If None, use AnnData.X."
        )
        
        de_method: str = Field(
            default="t-test",
            description="Differential expression method used to rank genes according to 1vsRest."
        )
        
        n_perms: int = Field(
            default=1000,
            description="Number of permutations for the permutation test. Relevant for CellPhoneDB method."
        )
        
        seed: int = Field(
            default=1337,
            description="Random seed for reproducibility."
        )
        
        n_jobs: int = Field(
            default=1,
            description="Number of jobs to run in parallel."
        )
        
        verbose: Optional[bool] = Field(
            default=False,
            description="Whether to print verbose output."
        )
        
        inplace: bool = Field(
            default=True,
            description="Whether to store results in place, or return them."
        )
        
        supp_columns: Optional[List[str]] = Field(
            default=None,
            description="Additional columns to be added from methods in liana, or columns from scanpy.tl.rank_genes_groups."
        )
  • Tool object registration for the 'ccc' tool.
    # Add general CCC tool
    ccc_tool = types.Tool(
        name="ccc",
        description="Cell-cell communication analysis with one method (cellphonedb, cellchat,connectome, natmi, etc.)",
        inputSchema=CCCModel.model_json_schema(),
    )
  • Mapping of 'ccc' tool to ccc_tools dictionary, which is used for registration in server.list_tools().
    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,
    }
  • Server tool listing function that includes ccc_tools.values(), registering the 'ccc' tool.
    @server.list_tools()
    async def list_tools() -> list[types.Tool]:
        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

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