cellcharter.tl.linearity

Contents

cellcharter.tl.linearity#

cellcharter.tl.linearity(adata, cluster_key='component', out_key='linearity', height=1000, min_ratio=0.05, copy=False)#

Compute the linearity of the topological boundaries of sets of cells.

It rasterizes the polygon and computes the skeleton of the rasterized image. Then, it computes the longest path in the skeleton and divides it by the total length of the skeleton. Branches that are shorter than min_ratio times the total length of the skeleton are removed because are not considered real branches.

Parameters:
  • adata (AnnData) – Annotated data object.

  • cluster_key (str (default: 'component')) – Key in anndata.AnnData.obs where the cluster labels are stored.

  • out_key (str (default: 'linearity')) – Key in anndata.AnnData.obs where the metric values are stored if copy = False.

  • height (int (default: 1000)) – Height of the rasterized image. The width is computed automatically to preserve the aspect ratio of the polygon. Higher values lead to more precise results but also higher memory usage.

  • min_ratio (float (default: 0.05)) – Minimum ratio between the length of a branch and the total length of the skeleton to be considered a real branch and not be removed.

  • copy (bool (default: False)) – If True, return the result, otherwise save it to the adata object.

Return type:

None | dict[int, float]

Returns:

If copy = True, returns a dict with the cluster labels as keys and the linearity as values.

Otherwise, modifies the adata with the following key: