liana.multi.to_tensor_c2c

liana.multi.to_tensor_c2c(adata: ~anndata._core.anndata.AnnData | None = None, sample_key: str | None = None, score_key: str | None = None, liana_res: ~pandas.core.frame.DataFrame | None = None, source_key: str = 'source', target_key: str = 'target', ligand_key: str = 'ligand_complex', receptor_key: str = 'receptor_complex', uns_key: str = 'liana_res', non_expressed_fill: float | None = None, inverse_fun: callable = <function DefaultValues.inverse_fun>, non_negative: bool = True, return_dict: bool = False, **kwargs)

Function to convert a LIANA result to a tensor for cell2cell analysis.

Parameters:
adata

Annotated data object.

sample_key

key in adata.obs to use for grouping by sample or context.

score_key

Column name of the score in liana_res. If None, the score is inferred from the method.

liana_res

A dataframe with the LIANA results. If None, it will be taken from adata.uns[uns_key].

source_key

Column name of the sender/source cell types in liana_res.

target_key

Column name of the receiver/target cell types in liana_res.

ligand_key

Column name of the ligand in liana_res.

receptor_key

Column name of the receptor in liana_res.

uns_key

Key in adata.uns that contains the LIANA results. Default is ‘liana_res’.

inverse_fun

Function that is applied to the scores before building the views. Default is lambda x: 1 - x which is used to invert the scores reflect probabilities (e.g. magnitude_rank), i.e. such for which lower values reflect higher relevance. This is handled automatically for the scores in liana.

non_expressed_fillfloat, optional (default: None)

Value to fill for non-expressed ligand-receptor pairs.

non_negativebool, optional (default: True)

Whether to make the tensor non-negative.

return_dictbool, optional (default: False)

Whether to return a dictionary of tensors.

**kwargskeyword arguments to pass to Tensor-cell2cell’s cell2cell.tensor.external_scores.dataframes_to_tensor function.
Returns:
Returns a tensor of shape (n_samples, n_senders, n_receivers, n_interactions) or a dictionary of tensors if return_dict is True.