stereo.algorithm.spatial_alignment.SpatialAlignment.main

SpatialAlignment.main(use_hvg=False, n_neighors=15, is_undirected=True, spatial_key='spatial', latent_dims=100, gpu=None, lr=0.001, max_epoch=500, alpha=0.5, patient=15, tau1=0.2, tau2=1.0, tau3=0.5, is_verbose=True, inplace=False)[source]

A method to remove batch effect.

Parameters:
  • use_hvgs – Whether to use a subset only contains highly variable genes, defaults to False, if True, data.tl.highly_variable_genes should be run first and the data will be filtered to only contain highly variable genes.

  • n_neighors (int) – The number of neighbors selected when constructing a spatial neighbor graph, defaults to 15

  • is_undirected (bool) – Whether the constructed spatial neighbor graph is undirected graph, defaults to True

  • latent_dims (int) – The number of embedding dimensions, defaults to 100, a reduced dimension matrix whose shape is (n_cells, latent_dims) will be output, you can get it through data.tl.result['aligned_reduction'].

  • seed – Random seed, difference seed will cause difference result, defaults to 42

  • gpu (Union[str, int, None]) – Whether to use GPU to train, set the ID of GPU to be used, defaults to None to use CPU

  • lr (float) – Learning rate, defaults to 1e-3

  • max_epoch (int) – The number of maximum epochs, defaults to 500

  • alpha (float) – The momentum parameter, defaults to 0.5

  • patient (int) – Early stop parameter, defaults to 15

  • tau1 (float) – Instance level and pseudo prototypical cluster level contrastive learning parameters, defaults to 0.2

  • tau2 (float) – Pseudo prototypical cluster entropy parameter, defaults to 1.

  • tau3 (float) – Cross-batch instance self-supervised learning parameter, defaults to 0.5

  • is_verbose (bool) – Whether to print the detail information, defaults to True

  • inplace (bool) – a corrected expression matrix will replace the data.exp_matrix if True or will be stored in data.layers['aligned_matrix'] if False, defaults to False.