insitupy.dataclasses.BoundariesData#
- class insitupy.dataclasses.BoundariesData(cell_names, seg_mask_value, nucleus_to_cell_map=None, nucleus_count=None)#
Object to read and load boundaries of cells and nuclei.
- __init__(cell_names, seg_mask_value, nucleus_to_cell_map=None, nucleus_count=None)#
Initialize the BoundariesData object.
- Parameters:
cell_names (
Union[ndarray,List]) – Cell names which need to correspond to.obs_namesin the.tableofCellData.seg_mask_value (
Union[ndarray,List,None]) – Segmentation mask values. Required to have the same length ascell_names. Specifies which values in the “cells” segmentation mask correspond to which cell name.nucleus_to_cell_map (
Optional[Dict[int,int]] (default:None)) – Mapping from nucleus index (0-indexed) to cell index (0-indexed). For Xenium v2.0+ with multinucleated cells, this allows mapping each nucleus to its parent cell. To look up a nucleus mask value N, use:nucleus_to_cell_map[N - 1](since mask values are 1-indexed). If None, assumes 1:1 mapping between nuclei and cells (Xenium v1.x behavior).nucleus_count (
Optional[ndarray] (default:None)) – Array with the number of nuclei per cell. Useful for identifying multinucleated cells. If None, not available.
For more details on how these values are saved in case of Xenium In Situ, see: https://www.10xgenomics.com/support/software/xenium-onboard-analysis/latest/tutorials/outputs/xoa-output-zarr
Methods
__init__(cell_names, seg_mask_value[, ...])Initialize the BoundariesData object.
add_boundaries(cell_boundaries, pixel_size)close()Close the underlying zarr store if one is attached.
convert_to_shapely_objects()copy()Function to generate a deep copy of the current object.
crop(cell_ids, xlim, ylim[, inplace])Crop the BoundariesData object.
save([bound_file, save_as_pyramid, ...])update_nucleus_metadata_from_xenium(xenium_path)Update nucleus_to_cell_map and nucleus_count from raw Xenium data if they are None.
Attributes
cell_namesis_emptymetadatanucleus_countArray with number of nuclei per cell.
nucleus_to_cell_mapMapping from nucleus label ID to cell index.
seg_mask_value