liana.resource.generate_lr_geneset¶
- liana.resource.generate_lr_geneset(resource, net, ligand_key='ligand', receptor_key='receptor', lr_sep='^', source='source', target='target', weight='weight')¶
Generate a ligand-receptor gene set from a resource and a network.
Specifically, it works with weighted bipartite networks, where the weight represents the importance of the genes to a given geneset. The function will assign a weight to each ligand-receptor interaction, based on the mean. It does so by first assigning a weight to each ligand-receptor subunit, checking for sign coherence and completeness of the ligand-receptor complex.
- Parameters:
- resource:
A pandas dataframe with [ligand, receptor] columns.
- net
Prior knowledge network in bipartite or decoupler format.
- ligandstr, optional
Name of the ligand column in the resource
- receptorstr, optional
Name of the receptor column in the resource
- lr_sep
Separator to use when joining ligand and receptor names into interactions.
- sourcestr, optional
Name of the source column in the network.
- weightstr, optional
Name of the weight column in the network. If None, all weights are set to 1.
- Returns:
- Returns ligand-receptor geneset resource as a pandas.DataFrame with the following columns:
- interaction: ligand-receptor interaction
- weight: mean weight of the interaction
- source: source of the interaction