liana.resource.generate_lr_geneset

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 (DataFrame) – A pandas dataframe with [ligand, receptor] columns.

  • net (DataFrame) – Prior knowledge network in bipartite or decoupler format.

  • ligand – Name of the ligand column in the resource

  • receptor – Name of the receptor column in the resource

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

  • source (str (default: 'source')) – Name of the source column in the network.

  • weight (str (default: 'weight')) – Name of the weight column in the network. If None, all weights are set to 1.

Return type:

DataFrame

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