spateo.segmentation.moran
#
Cell masking using Moran’s I metric.
Adapted from code written by @HailinPan.
Module Contents#
Functions#
|
Compute Moran's I for cell masking. |
|
Compute scores using Moran's I method. |
|
Compute scores using Moran's I method. |
|
Generate cell mask based on Moran's I. |
- spateo.segmentation.moran.moranI(X: numpy.ndarray, kernel: numpy.ndarray, mask: numpy.ndarray | None = None) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]#
Compute Moran’s I for cell masking.
- Parameters:
- X
Numpy array containing (possibly smoothed) UMI counts or binarized values.
- kernel
2D kernel containing weights
- mask
If provided, only consider pixels within the mask
- Returns:
A 4-element tuple containing (z, c, i, pvalue).
- spateo.segmentation.moran.run_moran(X: numpy.ndarray, k: int = 7, p_threshold: float = 0.05, mask: numpy.ndarray | None = None) numpy.ndarray [source]#
Compute scores using Moran’s I method.
- Parameters:
- X
Numpy array containing (possibly smoothed) UMI counts or binarized values.
- k
Kernel size
- p_threshold
P-value threshold. Test. Test Test
- mask
If provided, only consider pixels within the mask
- Returns:
A 2D Numpy array indicating pixel scores
- spateo.segmentation.moran.run_moran_and_mask_pixels(adata: anndata.AnnData, layer: str, k: int = 7, method: str = 'edge-watershed', mk: int = 3, mask: numpy.ndarray | None = None, mask_layer: str | None = None) numpy.ndarray [source]#
Compute scores using Moran’s I method.
- Parameters:
- adata
Input Anndata
- layer
Layer that contains UMI counts to use
- k
Kernel size
- method
Method used for generating cell mask based on p value of Moran’s I. ‘edge-watershed’ or ‘otsu’
- mk
Kernel size of morphological open and close operations to reduce noise in the mask.
- mask
If provided, only consider pixels within the mask
- mask_layer
Layer to save the final mask. Defaults to {layer}_mask.
- Returns:
A boolean mask.
- spateo.segmentation.moran.binary_morani_result(c: numpy.ndarray, p: numpy.ndarray, pvalue_cutoff: float = None, method: str = 'edge-watershed', c_cutoff: float = None, tissue_mask: numpy.ndarray | None = None) numpy.ndarray [source]#
Generate cell mask based on Moran’s I.