stereo.algorithm.st_gears.StGears.main

StGears.main(cluster_res_key=None, start_i=0, end_i=None, tune_alpha_li=[0.2, 0.1, 0.05, 0.025, 0.01, 0.005], numItermax=200, dissimilarity_val='kl', uniform_weight=False, dissimilarity_weight_val='kl', map_method_dis2wei='logistic', filter_by_label=True, use_gpu=False, verbose=False, res_key='st_gears')[source]

ST-GEARS is a strong 3D reconstruction tool for Spatial Transcriptomics, with accurate position alignment plus distortion correction.

It consists of methods to compute anchors, to rigidly align and to elastically registrate sections:

This main function computes mappings between adjacent sections in serial, using Fused-Gromov Wasserstein Optimal Transport with our innovatie Distributive Constraints.

stack_slices_pairwise_rigid rigidly aligns sections using Procrustes Analysis.

stack_slices_pairwise_elas_field eliminates distorsions through Gaussian Smoothed Elastic Fields.

This algorithm only supports AnnData currently, you can use st.io.stereo_to_anndata to convert your data to AnnData and input into st.io.read_h5ad to reload the data.

Parameters:
  • cluster_res_key (Optional[str]) – The key to get a cluster result or the column name in obs where annotated cell types are stored, defaults to None

  • start_i (int) – The index of first sample to calulate, defaults to 0

  • end_i (Optional[int]) – The index of last sample to calulate, defaults to None. By default, it is the last of all samples.

  • tune_alpha_li (list) – List of regularization factor in Fused Gromov Wasserstin (FGW) OT problem formulation, to be automatically tunned. Refer to this paper for the FGW formulation: Optimal transport for structured data with application on graphs. T Vayer, L Chapel, R Flamary, R Tavenard… - arXiv preprint arXiv …, 2018 - arxiv.org

  • numItermax (int) – Max number of iterations, defaults to 200

  • dissimilarity_val (str) – Matrix to calculate feature similarity. default to ‘kl’. Choose between ‘kl’ for Kullback-Leibler Divergence, and ‘euc’/’euclidean’ for euclidean distance.

  • uniform_weight (bool) – Whether to assign same margin weights to every spots, defaults to False.

  • dissimilarity_weight_val (str) – Matrix to calculate cell types feature similarity when assigning weighted boundary conditions for margin constrains. Refer to our paper for more details. Only assign when uniform_weight is False, defaults to ‘kl’

  • map_method_dis2wei (str) – Methood to map cell types feature similarity to margin weighhts. Choose between linear’ and ‘logistic’. Only assign when uniform_weight is False, defaults to ‘logistic’

  • filter_by_label (bool) – Where to filter out spots not appearing in its registered sample, so it won’t interfere with the ot solving process, defaults to True

  • use_gpu (bool) – Whether to use GPU, in the parameter calculation process. OT solving process is only built on CPU, defaults to False

  • verbose (bool) – Whether to print the OT solving process of each iteration, defaults to False

  • res_key (str) – The key to store calculating result, defaults to ‘st_gears’