spateo.alignment.paste_alignment

Functions

paste_align(→ Tuple[List[anndata.AnnData], ...)

Align spatial coordinates of models.

paste_align_ref(→ Tuple[List[anndata.AnnData], ...)

Align the spatial coordinates of one model list through the affine transformation matrix obtained from another model list.

Module Contents

spateo.alignment.paste_alignment.paste_align(models: List[anndata.AnnData], layer: str = 'X', genes: list | numpy.ndarray | None = None, spatial_key: str = 'spatial', key_added: str = 'align_spatial', mapping_key_added: str = 'models_align', alpha: float = 0.1, numItermax: int = 200, numItermaxEmd: int = 100000, dtype: str = 'float64', device: str = 'cpu', verbose: bool = True, **kwargs) Tuple[List[anndata.AnnData], List[numpy.ndarray | numpy.ndarray]][source]

Align spatial coordinates of models.

Parameters:
models

List of models (AnnData Object).

layer

If 'X', uses .X to calculate dissimilarity between spots, otherwise uses the representation given by .layers[layer].

genes

Genes used for calculation. If None, use all common genes for calculation.

spatial_key

The key in .obsm that corresponds to the raw spatial coordinate.

key_added

.obsm key under which to add the aligned spatial coordinates.

mapping_key_added

.uns key under which to add the alignment info.

alpha

Alignment tuning parameter. Note: 0 <= alpha <= 1.

When alpha = 0 only the gene expression data is taken into account, while when alpha =1 only the spatial coordinates are taken into account.

numItermax

Max number of iterations for cg during FGW-OT.

numItermaxEmd

Max number of iterations for emd during FGW-OT.

dtype

The floating-point number type. Only float32 and float64.

device

Equipment used to run the program. You can also set the specified GPU for running. E.g.: '0'.

verbose

If True, print progress updates.

**kwargs

Additional parameters that will be passed to pairwise_align function.

Returns:

List of models (AnnData Object) after alignment. pis: List of pi matrices.

Return type:

align_models

spateo.alignment.paste_alignment.paste_align_ref(models: List[anndata.AnnData], models_ref: List[anndata.AnnData] | None = None, n_sampling: int | None = 2000, sampling_method: str = 'trn', layer: str = 'X', genes: list | numpy.ndarray | None = None, spatial_key: str = 'spatial', key_added: str = 'align_spatial', mapping_key_added: str = 'models_align', alpha: float = 0.1, numItermax: int = 200, numItermaxEmd: int = 100000, dtype: str = 'float64', device: str = 'cpu', verbose: bool = True, **kwargs) Tuple[List[anndata.AnnData], List[anndata.AnnData], List[numpy.ndarray | numpy.ndarray]][source]

Align the spatial coordinates of one model list through the affine transformation matrix obtained from another model list.

Parameters:
models

List of models (AnnData Object).

models_ref

Another list of models (AnnData Object).

n_sampling

When models_ref is None, new data containing n_sampling coordinate points will be automatically generated for alignment.

sampling_method

The method to sample data points, can be one of ["trn", "kmeans", "random"].

layer

If 'X', uses .X to calculate dissimilarity between spots, otherwise uses the representation given by .layers[layer].

genes

Genes used for calculation. If None, use all common genes for calculation.

spatial_key

The key in .obsm that corresponds to the raw spatial coordinates.

key_added

.obsm key under which to add the aligned spatial coordinates.

mapping_key_added

.uns key under which to add the alignment info.

alpha

Alignment tuning parameter. Note: 0 <= alpha <= 1.

When alpha = 0 only the gene expression data is taken into account, while when alpha =1 only the spatial coordinates are taken into account.

numItermax

Max number of iterations for cg during FGW-OT.

numItermaxEmd

Max number of iterations for emd during FGW-OT.

dtype

The floating-point number type. Only float32 and float64.

device

Equipment used to run the program. You can also set the specified GPU for running. E.g.: '0'.

verbose

If True, print progress updates.

**kwargs

Additional parameters that will be passed to models_align function.

Returns:

List of models (AnnData Object) after alignment. align_models_ref: List of models_ref (AnnData Object) after alignment. pis: The list of pi matrices from align_models_ref.

Return type:

align_models