spateo.digitization.borderline ============================== .. py:module:: spateo.digitization.borderline .. autoapi-nested-parse:: Written by @Jinerhal, adapted by @Xiaojieqiu. Functions --------- .. autoapisummary:: spateo.digitization.borderline.get_borderline spateo.digitization.borderline.grid_borderline Module Contents --------------- .. py:function:: get_borderline(adata: spateo.digitization.utils.AnnData, cluster_key: str, source_clusters: int, target_clusters: int, bin_size: int = 1, spatial_key: str = 'spatial', borderline_key: str = 'borderline', k_size: int = 8, min_area: int = 30, dilate_k_size: int = 3) -> spateo.digitization.utils.np.ndarray Identify the borderline at the interface of the source and target cell clusters. The borderline will be identified by first retrieving the outline/contour formed by the source clusters, which will then be cleaned up to retrieve the borderline by masking with the expanded contours formed by the target clusters. :param adata: The adata object to be used for identifying the borderline. :param cluster_key: The key name of the spatial cluster in `adata.obs` :param source_clusters: The source cluster(s) that will interface with the target clusters. :param target_clusters: The target cluster(s) that will interface with the source clusters. :param bin_size: The size of the binning. :param spatial_key: The key name of the spatial coordinates in `adata.obs` :param borderline_key: The key name in `adata.obs` that will be used to store the borderline. :param k_size: Kernel size of the elliptic structuring element. :param min_area: Minimal area threshold corresponding to the resulting contour(s). :param dilate_k_size: Kernel size of the cv2.dilate function. :returns: The matrix that stores the image information of the borderline between the source and target cluster(s). Note that the adata object will also be updated with the `boundary_line` key that stores the information about whether the bucket is on the borderline. :rtype: borderline_img .. py:function:: grid_borderline(adata: spateo.digitization.utils.AnnData, borderline_img: spateo.digitization.utils.np.ndarray, borderline_list: spateo.digitization.utils.List, layer_num: int = 3, column_num: int = 25, layer_width: int = 10, spatial_key: str = 'spatial', init: bool = False) -> None Extend the borderline to either interior or exterior side to each create `layer_num` layers, and segment such layers to `column_num` columns. :param adata: The adata object to be used for identifying the interior/exterior layers and columns. :param borderline_img: The matrix that stores the image information of the borderline between the source and target cluster(s). :param borderline_list: An order list of np.arrays of coordinates of the borderlines. :param layer_num: Number of layers to extend on either interior or exterior side. :param column_num: Number of columns to segment for each layer. :param layer_width: Layer/column boundary width. This only affects grid_label. :param spatial_key: The key name in `adata.obsm` of the spatial coordinates. Default to "spatial". Passed to `fill_grid_label` function. :param init: Whether to generate (and potentially overwrite) the `layer_label_key` and `column_label_key` in `fill_grid_label` function. :returns: 1. layer_label_key: this key points to layer labels. 2. column_label_key: this key points to column labels. :rtype: Nothing but update the adata object with following keys in `.obs`