API

Import SC2Spa:

import SC2Spa

Spatial Inference

tl.FineMapping(adata_ref, adata_query[, ...])

Finely map single cells to spatial locations and Reconstruct ST data at single cell resolution

tl.Reconstruct_scST(adata_ref, adata_query)

Reconstruct ST data at single cell resolution

tl.NRD_CT_preprocess(adata_ref, adata_query)

Apply KNN algorithm to obtain the single cell neighbors of ST beads

tl.NRD_weight(neighbors, dis, adata_ref, ...)

Calculate the weights of nearby single cells for ST beads based on the fine mapping result

tl.NRD_CT(neighbors, dis, adata_ref, adata_query)

Normalized Reciprocal Distance

tl.NRD_impute(neighbors, dis, adata_ref, ...)

Reconstruct the gene expression profile of ST beads based on the NRD_weight output

tl.Train_transfer(adata, root, model_root[, ...])

Finetune location prediction model (FCNN) on a specific cell type A model will be trained and saved to root + 'SI_' + CT + '.h5' The predicted coordinates of single cells will be saved in adata_query.obsm['spatial_mapping'] The predicted coordinates of beads will be saved in adata_ref.obs['spatial_mapping'] Fine mapping information will be saved in adata_ref.obs['FM'] and adata_query.obs['FM'].

tl.SaveValidation(history, CV, name)

Save the FCNN or LR training history to 'log/training_log_' + name + '.pickle',

tl.CheckAccuracy(name[, item_name])

Check the accuracies and mean accuracy of cross-validation

tl.CrossValidation(X, Y, train_indices, ...)

Perform Cross-validation using fully connected neural network

tl.WassersteinD(adata_ref, adata_query, ...)

Calculate Wassertein distances of genes between two datasets

tl.pp_Mapping(adata_ref, adata_query, JGs[, ...])

Extract gene expression matrices sharing the same genes and the reference coordinates

tl.BatchPredict(Model, X[, BatchSize])

Predict batch by batch

Plotting

pl.DrawGenes2(adata, gene[, coords_name, ...])

Show the expression of a gene in cells or ST beads

pl.DrawCT1(adata, CT[, ax, coords_name, s, ...])

Show the spatial locations of a type of cells or beads

pl.DrawCT2(adata, CT[, coords_name, title, ...])

Customized Function

pl.DrawCT3(adata, CT_list[, coords_name, s, ...])

Display original locations or predicted locations of beads/cells of selected types.

pl.DrawSVG(adata, GeneList, target_field[, ...])

Show the expression of location predictive genes (or spatially variable genes)

pl.Superimpose(adata[, coords_name, G1, G2, ...])

Show the spatial gene expressions of two genes and their superimposed images

pl.draw_cb([cmap, figsize, save, size])

Draw an independent color bar figure

Benchmarking

bm.BVMI(adata1, adata2, GL[, coords_name, ...])

Calculate bivariate Moran's I of the genes of two ST data.

bm.Vis_Euclidean(coord_ref, coord_pred, ...)

Show the euclidean distance of the original and predicted locations of beads.

Preprocessing

pp.MinMaxNorm(Y, Y_ref)

Min-Max normalize along the second axis

pp.ReMMNorm(Y_ref, Y_pred)

Reverse Min-Max normalize along the second axis

pp.PolarTrans(Y)

Transform cartesian coordinates to polar coordinates

pp.RePolarTrans(RTheta)

Transform polar coordinates to cartesian coordinates

Spatially Variable Gene Analysis

sva.PrioritizeLPG(adata, Model[, sparse, ...])

Prioritize genes' contribution to location prediction

sva.SelectGenes(Weights[, percent])

Trace back the weight matrices to evaluate the importance of genes in location prediction

sva.SelectFeatures(array_in, percent)

Select top percent quantile nodes

Mutual Exclusivity Analysis

me.BME_stat(A1, A2[, p_coef])

Calculate Balanced Mutual exclusivity score between Gene 1 and Gene 2

me.calc_BME(A[, n_process, n_resamples])

Calculate Balanced Mutual Exclusivity

me.calc_BME_sub(ij, A, genes, n_resamples)

Calculate Balanced Mutual exclusivity (subprocess)

me.calc_DEEI(A[, cutoff, p_coef, n_process])

Calculate Balanced Mutual Exclusivity and Directed exclusively express index

me.DEEI_sub(ij, Count_excl, Prob_excl, A_S, ...)

Calculate Balanced Mutual exclusivity and Directed exclusively express index (subprocess)

me.Count_Prob_EEI(A)

Calculate the counts and probabilities of exclusive events