bin2cell.bin_to_cell
- bin2cell.bin_to_cell(adata, labels_key='labels_expanded', spatial_keys=['spatial'], diameter_scale_factor=None)
Collapse all bins for a given nonzero
labels_keyinto a single cell. Gene expression added up, array coordinates andspatial_keysaveraged out."spot_diameter_fullres"in the scale factors multiplied bydiameter_scale_factorto reflect increased unit size. Returns cell level AnnData, including.obs["bin_count"]reporting how many bins went into creating the cell.Input
- adata
AnnData 2um bin VisiumHD object. Raw or destriped counts. Needs
labels_keyin.obsandspatial_keysin.obsm.- labels_key
str, optional (default:"labels_expanded") Which
.obskey to use for grouping 2um bins into cells. Integers, with 0 being unassigned to an object. If an extra"_source"column is detected as a result ofb2c.salvage_secondary_labels()calling, its info will be propagated per label.- spatial_keyslist of
str, optional (default:["spatial"]) Which
.obsmkeys to average out across all bins falling into a cell to get a cell’s respective spatial coordinates.- diameter_scale_factor
floatorNone, optional (default:None) The object’s
"spot_diameter_fullres"will be multiplied by this much to reflect the change in unit per observation. IfNone, will default to the square root of the mean of the per-cell bin counts.
- adata