spateo.digitization.grid ======================== .. py:module:: spateo.digitization.grid .. autoapi-nested-parse:: Written by @Jinerhal, adapted by @Xiaojieqiu. Functions --------- .. autoapisummary:: spateo.digitization.grid.digitize spateo.digitization.grid.gridit Module Contents --------------- .. py:function:: digitize(adata: spateo.digitization.utils.AnnData, ctrs: spateo.digitization.utils.Tuple, ctr_idx: int, pnt_xy: spateo.digitization.utils.Tuple[int, int], pnt_Xy: spateo.digitization.utils.Tuple[int, int], pnt_xY: spateo.digitization.utils.Tuple[int, int], pnt_XY: spateo.digitization.utils.Tuple[int, int], spatial_key: str = 'spatial', dgl_layer_key: str = 'digital_layer', dgl_column_key: str = 'digital_column', max_itr: int = 1000000.0, lh: float = 1, hh: float = 100) -> None Calculate the "heat" for a closed area of interests by solving a PDE, partial differential equation, the heat equation. Boundary conditions are defined upon four user provided coordinates that set the direction of heat diffusion. The value of "heat" will be used for define different spatial layers, domains and grids. :param adata: The adata object to digitize. :param ctrs: Contours generated by `cv2.findContours`. :param ctr_idx: The index of the contour of interests. :param pnt_xy: Corner point to define an area of interest. pnt_xy corresponds to the point with minimal layer and minimal column value. :param pnt_Xy: Corner point corresponds to the point with maximal column value but minimal layer value. :param pnt_xY: Corner point corresponds to the point with minimal column value but maximal layer value. :param pnt_XY: Corner point corresponds to the point with maximal layer and maximal columns value. :param spatial_key: The key name in `adata.obsm` of the spatial coordinates. Default to "spatial". :param dgl_layer_key: The key name in `adata.obs` to store layer digital-heat (temperature). Default to "digital_layer". :param dgl_column_key: The key name to store column digital-heat (temperature). :param max_itr: Maximum number of iterations dedicated to solving the heat equation. :param lh: lowest digital-heat (temperature). Defaults to 1. :param hh: highest digital-heat (temperature). Defaults to 100. :returns: 1. dgl_layer_key: The key in `adata.obs` points to the values of layer digital-heat (temperature). 2. dgl_column_key: The key in `adata.obs` points to the values of column digital-heat (temperature). :rtype: Nothing but update the `adata` object with the following keys in `.obs` .. py:function:: gridit(adata: spateo.digitization.utils.AnnData, layer_num: int, column_num: int, lh: float = 1, hh: float = 100, dgl_layer_key: str = 'digital_layer', dgl_column_key: str = 'digital_column', layer_border_width: int = 2, column_border_width: int = 2, layer_label_key: str = 'layer_label', column_label_key: str = 'column_label', grid_label_key: str = 'grid_label') -> None Segment the area of interests into specific layer/column number, according to precomputed digitization heat value. :param adata: The adata object to do layer/column/grid segmentation. :param layer_num: Number of layers to segment. :param column_num: Number of columns to segment. :param lh: lowest digital-heat. Default to 1. :param hh: highest digi-heat. Default to 100. :param layer_border_width: Layer boundary width. Only affect grid_label. :param column_border_width: Column boundary width. Only affect grid_label. :param dgl_layer_key: The key name of layer digitization heat in `adata.obs`. Default to "digital_layer", precomputed. :param dgl_column_key: The key name of column digitization heat in `adata.obs`. Default to "digital_column", precomputed. :param layer_label_key: The key name to store layer labels in `adata.obs`. Default to "layer_label", will be added. :param column_label_key: The key name to store column labels in `adata.obs`. Default to "column_label", will be added. :param grid_label_key: The key name to store grid labels in `adata.obs`. Default to "grid_label", will be added. :returns: 1. layer_label_key: this key points to layer labels. 2. column_label_key: this key points to column labels. 3. grid_label_key: this key points to grid labels. :rtype: Nothing but update the adata object with the following keys in `.obs`