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
- adata
AnnData 2um bin VisiumHD object. Raw or destriped counts.
- labels_key
str, optional (default:"labels") .obskey holding the labels to be expanded. Integers, with 0 being unassigned to an object.- expanded_labels_key
str, optional (default:"labels_expanded") .obskey to store the expanded labels under.- algorithm
str, optional (default:"max_bin_distance") Toggle between
max_bin_distanceorvolume_ratiobased label expansion.- max_bin_distance
intorNone, optional (default: 2) Maximum number of bins to expand the nuclear labels by.
- volume_ratio
float, optional (default: 4) A per-label expansion distance will be proposed as
ceil((volume_ratio**(1/3)-1) * sqrt(n_bins/pi)), wheren_binsis the number of bins for the corresponding pre-expansion label. Default based on cell line data- k
int, optional (default: 4) Number of assigned spatial coordinate bins to find as potential nearest neighbours for each unassigned bin.
- subset_pca
bool, 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.
- adata