bin2cell.expand_labels

bin2cell.expand_labels(adata, labels_key='labels', expanded_labels_key='labels_expanded', algorithm='max_bin_distance', max_bin_distance=2, volume_ratio=4, k=4, subset_pca=True)

Expand StarDist segmentation results to bins a maximum distance away in the array coordinates. In the event of multiple equidistant bins with different labels, ties are broken by choosing the closest bin in a PCA representation of gene expression. The resulting labels will be integers, with 0 being unassigned to an object.

Input

adataAnnData

2um bin VisiumHD object. Raw or destriped counts.

labels_keystr, optional (default: "labels")

.obs key holding the labels to be expanded. Integers, with 0 being unassigned to an object.

expanded_labels_keystr, optional (default: "labels_expanded")

.obs key to store the expanded labels under.

algorithmstr, optional (default: "max_bin_distance")

Toggle between max_bin_distance or volume_ratio based label expansion.

max_bin_distanceint or None, optional (default: 2)

Maximum number of bins to expand the nuclear labels by.

volume_ratiofloat, optional (default: 4)

A per-label expansion distance will be proposed as ceil((volume_ratio**(1/3)-1) * sqrt(n_bins/pi)), where n_bins is the number of bins for the corresponding pre-expansion label. Default based on cell line data

kint, optional (default: 4)

Number of assigned spatial coordinate bins to find as potential nearest neighbours for each unassigned bin.

subset_pcabool, optional (default: True)

If True, will obtain the PCA representation of just the bins involved in the tie breaks rather than the full bin space. Results in a slightly different embedding at a lower resource footprint.