liana.method.inflow.__call__

liana.method.inflow.__call__#

inflow.__call__(groupby=None, obsm_key=None, resource_name=None, resource=None, interactions=None, nz_prop=0.001, connectivity_key='spatial_connectivities', complex_sep='_', x_transform=None, y_transform=None, use_raw=True, layer=None, xy_sep='^', verbose=False, **kwargs)#

A method for trivariate (source cell type, ligand, receptor) local spatial metrics.

Parameters:
  • adata (AnnData | MuData) – Annotated data object.

  • groupby (str, optional) – Column name in adata.obs containing cell type labels. If provided, a one-hot encoding will be created. Mutually exclusive with obsm_key.

  • obsm_key (str, optional) – Key in adata.obsm containing a pre-computed cell type matrix (pandas DataFrame) of shape (n_obs, n_celltypes). Column names will be used as cell type labels. Can contain binary (one-hot) or continuous (probabilities/scores) values. Mutually exclusive with groupby.

  • interactions (list (default: None)) – List of tuples with ligand-receptor pairs [(ligand, receptor), ...] to be used for the analysis. If passed, it will overrule the resource requested via resource and resource_name.

  • resource (DataFrame | None (default: None)) – A pandas dataframe with [ligand, receptor] columns. If provided will overrule the resource requested via resource_name

  • resource_name (str (default: None)) – Name of the resource to be used for ligand-receptor inference. See li.rs.show_resources() for available resources.

  • connectivity_key (str (default: 'spatial_connectivities')) – Key in adata.obsp that contains the spatial connectivity matrix. Default is 'spatial_connectivity'.

  • layer (str | None (default: None)) – Layer in anndata.AnnData.layers to use. If None, use anndata.AnnData.X.

  • use_raw (bool | None (default: True)) – Use raw attribute of adata if present.

  • nz_prop (float) – Minimum proportion of non-zero values for each features. For example, if working with gene expression data, this would be the proportion of cells expressing a gene. Both features must have a proportion greater than nz_prop to be considered in the analysis.

  • complex_sep (str) – Separator to use for complex names.

  • xy_sep (str) – Separator to use for interaction names.

  • x_transform (Callable | None (default: None)) – Function used to transform the source-ligand values. If None, no transformation is applied.

  • y_transform (Callable | None (default: None)) – Function used to transform the receptor values. If None, no transformation is applied.

  • verbose (bool (default: False)) – Verbosity flag.

  • **kwargs (dict, optional) –

    Additional keyword arguments: - For AnnData:

    x_name

    Name of the x-variable. If passing a resource dataframe, this should match the first column. By default: ‘ligand’.

    y_name

    Name of the y-variable. If passing a resource dataframe, this should match the second column. By default: ‘receptor’.

    • For MuData:

      x_mod

    Name of the modality to use for the x-axis.

    y_mod

    Name of the modality to use for the y-axis.

    x_name

    Name of the x-variable. If passing a resource dataframe, this should match the first column. By default: ‘x’.

    y_name

    Name of the y-variable. If passing a resource dataframe, this should match the second column. By default: ‘y’.
    x_use_raw: bool

    Whether to use raw counts for x modality.

    y_use_raw: bool

    Whether to use raw counts for y modality.

    x_layer: str

    Layer to use for x modality.

    y_layer: str

    Layer to use for y modality.

    • For both AnnData and MuData:
      x_transform_kwargs: dict

      Keyword arguments to pass to x_transform function.

      y_transform_kwargs: dict

      Keyword arguments to pass to y_transform function.

Return type:

AnnData

Returns:

An AnnData object of shape (n_cell_type_ligand_receptor_combinations, n_observations), where n_cell_type_ligand_receptor_combinations corresponds to the combinations of cell types (as defined by the groupby parameter) with ligands and receptors expressed in the data and covered by the resource, and n_observations is the number of observations.