liana.method.estimate_metalinks#
- liana.method.estimate_metalinks(adata, resource, pd_net, t_net=None, x_name='metabolite', y_name='receptor', use_raw=True, layer=None, verbose=False, **kwargs)#
Estimate Metabolites from anndata object, and return a MuData object of metabolites and receptors.
- Parameters:
adata (
AnnData) – Annotated data matrix.resource (
DataFrame) – Resource to use for ligand-receptor inference.pd_net (
DataFrame) – Metabolic production-degradation network to use.t_net (
DataFrame(default:None)) – Transport set to use.x_name (
str(default:'metabolite')) – Name of the metabolite modality.y_name (
str(default:'receptor')) – Name of the receptor modality. Must be present as a column in the resource.use_raw (
bool(default:True)) – Use raw attribute of adata if present.layer (
str(default:None)) – Layer in anndata.AnnData.layers to use. If None, use anndata.AnnData.X.verbose (
bool(default:False)) – Verbosity flag.**kwargs – Additional arguments to pass to the decoupler-py functions. Method-specific arguments are not supported.
- Return type:
- Returns:
A MuData object with metabolite & receptor assays.
Examples
pd_netis a metabolite-to-enzyme network whose weights say whether a gene produces (+) or degrades (-) a metabolite, andresourcelinks metabolites to their receptors. Both normally come from MetalinksDB (seeliana.resource.get_metalinks()); toy ones are built here so the example stays offline:>>> import numpy as np >>> import pandas as pd >>> import liana as li >>> adata = li.testing.generate_toy_adata() >>> genes = adata.var_names[:16].tolist() >>> pd_net = pd.DataFrame({'source': np.repeat(['HMDB0000122', ... 'HMDB0000148'], 8), ... 'target': genes, ... 'weight': 1.0}) >>> resource = pd.DataFrame({'source': ['HMDB0000122', 'HMDB0000148'], ... 'receptor': ['CD4', 'ITGB2']}) >>> mdata = li.mt.estimate_metalinks(adata, resource=resource, pd_net=pd_net)
Metabolite abundances are estimated from the enzyme expression and returned in a
'metabolite'modality, next to the receptors in a'receptor'one. Passt_netto additionally require a transporter for metabolites that cannot cross the membrane on their own. The result is the input toliana.method.bivariateor to any single-cell method, withx_mod='metabolite'andy_mod='receptor'.