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_key into a single cell. Gene expression added up, array coordinates and spatial_keys averaged out. "spot_diameter_fullres" in the scale factors multiplied by diameter_scale_factor to reflect increased unit size. Returns cell level AnnData, including .obs["bin_count"] reporting how many bins went into creating the cell.

Input

adataAnnData

2um bin VisiumHD object. Raw or destriped counts. Needs labels_key in .obs and spatial_keys in .obsm.

labels_keystr, optional (default: "labels_expanded")

Which .obs key 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 of b2c.salvage_secondary_labels() calling, its info will be propagated per label.

spatial_keyslist of str, optional (default: ["spatial"])

Which .obsm keys to average out across all bins falling into a cell to get a cell’s respective spatial coordinates.

diameter_scale_factorfloat or None, optional (default: None)

The object’s "spot_diameter_fullres" will be multiplied by this much to reflect the change in unit per observation. If None, will default to the square root of the mean of the per-cell bin counts.