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_ratiotimes 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 inanndata.AnnData.obswhere the cluster labels are stored.out_key (
str(default:'linearity')) – Key inanndata.AnnData.obswhere the metric values are stored ifcopy = 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)) – IfTrue, return the result, otherwise save it to theadataobject.
- Return type:
- Returns:
If
copy = True, returns adictwith the cluster labels as keys and the linearity as values.- Otherwise, modifies the
adatawith the following key: anndata.AnnData.uns['shape_{{cluster_key}}']['{{out_key}}']- - the above mentioneddict.
- Otherwise, modifies the