spateo.alignment.utils
#
Module Contents#
Functions#
|
|
|
|
|
|
|
Optimal mapping coordinates between X and Y. |
|
Optimal mapping coordinates between X and Y based on intermediate coordinates. |
|
Obtain the label information in anndata.obs[key] corresponding to the coords. |
- spateo.alignment.utils.downsampling(models: List[anndata.AnnData] | anndata.AnnData, n_sampling: int | None = 2000, sampling_method: str = 'trn', spatial_key: str = 'spatial') List[anndata.AnnData] | anndata.AnnData [source]#
- spateo.alignment.utils.get_optimal_mapping_relationship(X: numpy.ndarray, Y: numpy.ndarray, pi: numpy.ndarray, keep_all: bool = False)[source]#
- spateo.alignment.utils.mapping_aligned_coords(X: numpy.ndarray, Y: numpy.ndarray, pi: numpy.ndarray, keep_all: bool = False) Tuple[dict, dict] [source]#
Optimal mapping coordinates between X and Y.
- Parameters:
- X
Aligned spatial coordinates.
- Y
Aligned spatial coordinates.
- pi
Mapping between the two layers output by PASTE.
- keep_all
Whether to retain all the optimal relationships obtained only based on the pi matrix, If
keep_all
is False, the optimal relationships obtained based on the pi matrix and the nearest coordinates.
- Returns:
- Two dicts of mapping_X, mapping_Y, pi_index, pi_value.
mapping_X is X coordinates aligned with Y coordinates. mapping_Y is the Y coordinate aligned with X coordinates. pi_index is index between optimal mapping points in the pi matrix. pi_value is the value of optimal mapping points.
- spateo.alignment.utils.mapping_center_coords(modelA: anndata.AnnData, modelB: anndata.AnnData, center_key: str) dict [source]#
Optimal mapping coordinates between X and Y based on intermediate coordinates.
- Parameters:
- modelA
modelA aligned with center model.
- modelB
modelB aligned with center model.
- center_key
The key in
.uns
that corresponds to the alignment info between modelA/modelB and center model.
- Returns:
- A dict of raw_X, raw_Y, mapping_X, mapping_Y, pi_value.
raw_X is the raw X coordinates. raw_Y is the raw Y coordinates. mapping_X is the Y coordinates aligned with X coordinates. mapping_Y is the X coordinates aligned with Y coordinates. pi_value is the value of optimal mapping points.
- spateo.alignment.utils.get_labels_based_on_coords(model: anndata.AnnData, coords: numpy.ndarray, labels_key: str | List[str], spatial_key: str = 'align_spatial') pandas.DataFrame [source]#
Obtain the label information in anndata.obs[key] corresponding to the coords.