liana.mt.connectome.__call__

liana.mt.connectome.__call__#

connectome.__call__(adata, groupby, resource_name='consensus', expr_prop=0.1, min_cells=5, groupby_pairs=None, base=np.float64(2.718281828459045), supp_columns=None, return_all_lrs=False, key_added='liana_res', use_raw=False, layer=None, de_method='t-test', n_perms=1000, seed=1337, n_jobs=1, resource=None, interactions=None, spatial_key=None, spatial_kwargs=None, mdata_kwargs=None, inplace=True, verbose=False)#

Run a ligand-receptor method.

Parameters:
adata AnnData | MuData

Annotated data object.

groupby str

Key to be used for grouping.

resource_name str (default: 'consensus')

Name of the resource to be used for ligand-receptor inference. See li.rs.show_resources() for available resources.

expr_prop float (default: 0.1)

Minimum expression proportion for the ligands and receptors (+ their subunits) in the corresponding cell identities. Set to 0 to return unfiltered results.

min_cells int (default: 5)

Minimum cells (per cell identity if grouped by groupby) to be considered for downstream analysis.

groupby_pairs DataFrame | None (default: None)

A DataFrame with columns source and target to be used to subset the possible combinations of interacting cell types. If None, all possible combinations are used.

base float (default: np.float64(2.718281828459045))

Exponent base used to reverse the log-transformation of the matrix. Relevant only for the logfc method.

supp_columns list[str] | None (default: None)

Additional columns to be added from any of the methods implemented in liana, or any of the columns returned by scanpy.tl.rank_genes_groups, each starting with ligand_* or receptor_*. For example, ['ligand_pvals', 'receptor_pvals']. None by default.

return_all_lrs bool (default: False)

Bool whether to return all ligand-receptor pairs, or only those that surpass the expr_prop threshold. Ligand-receptor pairs that do not pass the expr_prop threshold will be assigned to the worst score of the ones that do. False by default.

key_added str (default: 'liana_res')

Key under which the results will be stored in adata.uns if inplace is True.

use_raw bool (default: False)

Whether to use the .raw attribute of adata. Defaults to False (uses .X).

layer str | None (default: None)

Layer in anndata.AnnData.layers to use. If None, use anndata.AnnData.X.

de_method Literal['logreg', 't-test', 'wilcoxon', 't-test_overestim_var'] (default: 't-test')

Differential expression method. scanpy.tl.rank_genes_groups is used to rank genes according to 1vsRest. The default method is ‘t-test’.

n_perms int | None (default: 1000)

Number of permutations for the permutation test. If None, no p-values are computed.

seed int (default: 1337)

Random seed for reproducibility.

n_jobs int (default: 1)

Number of jobs to run in parallel.

resource DataFrame | None (default: None)

A pandas dataframe with [ligand, receptor] columns. If provided will overrule the resource requested via resource_name

interactions list[tuple[str, str]] | None (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.

spatial_key str | None (default: None)

Key in adata.obsm that contains the spatial coordinates.

spatial_kwargs SpatialKwargs | None (default: None)

Keyword arguments passed to liana.pp.spatial_pair_proximity() for computing spatial proximity weights. Default is None, which uses default values (bandwidth=250, kernel=’gaussian’, trim_fraction=0.1).

mdata_kwargs MdataKwargs | None (default: None)

Keyword arguments to be passed to li.ms.mdata_to_anndata if adata is an instance of MuData. If an AnnData object is passed, these arguments are ignored.

inplace bool (default: True)

Whether to store results in place, or else to return them.

verbose bool (default: False)

Verbosity flag.

Return type:

DataFrame | None

Returns:

If inplace = False, returns a DataFrame with ligand-receptor results Otherwise, modifies the adata object with the following key:

Examples

Every method instance is called the same way; cellphonedb shown here:

>>> import liana as li
>>> adata = li.ds.generate_toy_adata()
>>> li.mt.cellphonedb(adata, groupby="bulk_labels", n_perms=100)