liana.multi.df_to_lr

Contents

liana.multi.df_to_lr#

liana.multi.df_to_lr(adata, dea_df, groupby, stat_keys, resource_name='consensus', resource=None, interactions=None, groupby_pairs=None, layer=None, use_raw=True, expr_prop=0.1, min_cells=5, complex_col=None, return_all_lrs=False, source_labels=None, target_labels=None, lr_sep='^', verbose=False)#

Convert DEA results to ligand-receptor pairs.

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

  • dea_df (DataFrame) – DEA results. Index must match adata.var_names

  • groupby (str) – Key to be used for grouping.

  • stat_keys (list[str]) – List of statistics to be used for ligand-receptor pairs

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

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

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

  • groupby_pairs (DataFrame (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.

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

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

  • 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.

  • complex_col (str (default: None)) – Column in dea_df to use for complex expression. Default is None. If None, will use mean expression (‘expr’) calculated per group in groupby.

  • 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.

  • source_labels (list[str] (default: None)) – List of labels to use as source, the rest are filtered out.

  • target_labels (list[str] (default: None)) – List of labels to use as target, the rest are filtered out.

  • lr_sep (str (default: '^')) – Separator to use when joining ligand and receptor names into interactions.

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

Return type:

DataFrame

Returns:

Returns a pd.DataFrame with joined ligand-receptor pairs and statistics.

Raises:
  • ValueError – If the groupby value is not in adata or dea_df, if dea_df indexes do not match adata.var_names or if complex_col does not match one of the computed stats.

  • AssertionError – If there’s no match when grouping-by between adata.obs and dea_df.