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_namesgroupby (
str) – Key to be used for grouping.stat_keys (
list[str]) – List of statistics to be used for ligand-receptor pairsresource_name (
str(default:'consensus')) – Name of the resource to be used for ligand-receptor inference. Seeli.rs.show_resources()for available resources.resource (
DataFrame(default:None)) – A pandas dataframe with [ligand,receptor] columns. If provided will overrule the resource requested viaresource_nameinteractions (
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 viaresourceandresource_name.groupby_pairs (
DataFrame(default:None)) – A DataFrame with columnssourceandtargetto 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 bygroupby) to be considered for downstream analysis.complex_col (
str(default:None)) – Column indea_dfto use for complex expression. Default is None. If None, will use mean expression (‘expr’) calculated per group ingroupby.return_all_lrs (
bool(default:False)) – Bool whether to return all ligand-receptor pairs, or only those that surpass theexpr_propthreshold. Ligand-receptor pairs that do not pass theexpr_propthreshold will be assigned to the worst score of the ones that do.Falseby default.source_labels (
list[str] (default:None)) – List of labels to use assource, the rest are filtered out.target_labels (
list[str] (default:None)) – List of labels to use astarget, 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
groupbyvalue is not inadataordea_df, ifdea_dfindexes do not matchadata.var_namesor ifcomplex_coldoes not match one of the computed stats.AssertionError – If there’s no match when grouping-by between
adata.obsanddea_df.