spateo.segmentation.qc¶
Functions¶
|
Select regions to use for segmentation quality control purposes. |
|
|
|
Create random labels, usually for benchmarking and QC purposes. |
|
Create random labels, using another layer as a template. |
Module Contents¶
- spateo.segmentation.qc.select_qc_regions(adata: anndata.AnnData, regions: List[Tuple[int, int]] | List[Tuple[int, int, int, int]] = None, n: int = 4, size: int = 2000, seed: int | None = None, use_scale: bool = True, absolute: bool = False, weight_func: Callable[[anndata.AnnData], float] | None = lambda adata: ...)[source]¶
Select regions to use for segmentation quality control purposes.
Note
All coordinates are in terms of “real” coordinates (i.e. the coordinates in adata.obs_names and adata.var_names) so that slicing the AnnData retains the regions correctly.
- Parameters:
- adata
Input AnnData
- regions
List of tuples in the form (xmin, ymin) or (xmin, xmax, ymin, ymax). If the later, the size argument is used to compute the bounding box.
- n
Number of regions to select if regions is not provided.
- size
Width and height, in pixels, of each randomly selected region.
- seed
Random seed.
- use_scale
Whether or not the provided regions are in scale units. This option only has effect when regions are provided. False means the provided coordinates are in terms of pixels.
- absolute
Whether or not the provided regions are in terms of absolute X and Y coordinates. This option only has effect when regions are provided. False means the provided coordinates are relative with respect to the coordinates in the provided adata.
- weight_func
Weighting function when regions is not provided. The probability of selecting each size x size region will be weighted by this function, which accepts a single AnnData (the region) as its argument, and returns a single float weight, such that higher weights mean higher probability. By default, the log1p of the sum of the counts in the X layer is used. Set to None to weight each region equally.
- spateo.segmentation.qc._generate_random_labels(shape: Tuple[int, int], areas: List[int], seed: int | None = None) numpy.ndarray [source]¶
- spateo.segmentation.qc.generate_random_labels(adata: anndata.AnnData, areas: List[int], seed: int | None = None, out_layer: str = 'random_labels')[source]¶
Create random labels, usually for benchmarking and QC purposes.
- Parameters:
- adata
Input Anndata
- areas
List of desired areas.
- seed
Random seed.
- out_layer
Layer to save results.
- spateo.segmentation.qc.generate_random_labels_like(adata: anndata.AnnData, layer: str, seed: int | None = None, out_layer: str = 'random_labels')[source]¶
Create random labels, using another layer as a template.
- Parameters:
- adata
Input Anndata
- layer
Layer containing template labels
- seed
Random seed.
- out_layer
Layer to save results.