liana.utils.query_bandwidth

liana.utils.query_bandwidth#

liana.utils.query_bandwidth(coordinates, start=0, end=500, interval_n=50, reference=None)#

Query the bandwidth (maximum distance) at which the average number of neighbors is maximized.

Parameters:
  • coordinates (ndarray) – Spatial coordinates of spots.

  • start (int (default: 0)) – Starting bandwidth.

  • end (int (default: 500)) – Ending bandwidth.

  • interval_n (int (default: 50)) – Number of bandwidths to query. Used to generate a linearly spaced interval between start and end. Default is 50.

  • reference (ndarray (default: None)) – Reference coordinates to query the neighbors from. Default is None, which will use coordinates.

Return type:

tuple[Figure, DataFrame]

Returns:

A plotnine plot and a pandas DataFrame with the following columns: - bandwith: the bandwidth (maximum distance) at which the average number of neighbors is maximized. - neighbours: the average number of neighbors at the specified bandwidth.

Examples

See here [1] or here [2].