stereo.algorithm.spa_seg.SpaSeg.main¶
- SpaSeg.main(seed=1029, n_channel=None, n_conv=2, lr=0.002, weight_decay=1e-05, pretrain_epochs=400, iterations=2100, sim_weight=0.4, con_weight=0.7, min_label=7, gpu=None, result_prefix='SpaSEG')[source]¶
SpaSEG, an unsupervised convolutional neural network-based method towards multiple SRT analysis tasks by jointly learning transcriptional similarity between spots and their spatial dependence within tissue. SpaSEG adopts edge strength constraint to enable coherent spatial domains, and allows integrative SRT analysis by automatically aligning spatial domains across multiple adjacent sections. Moreover, SpaSEG can effectively detect spatial domain-specific gene expression patterns(SVG), and infer intercellular interactions and co-localizations.
Note
Currently, this algorithm only supports AnnData, if your data is read from GEF/GEM file, you can use st.io.stereo_to_anndata to convert your data to AnnData and reload the data by st.io.read_h5ad.
- Parameters:
seed (
int) – random seed, fixed value to fixed result, defaults to 1029.n_channel (
Optional[int]) – the input/output channels of the middle convolutional layers, defaults to the dimension of PCA results. In the process of convolution, the input channels of the first convolutional layer is the same as the output channels of the last convolutional layer, which is set as the dimension of PCA results, the output channels of the first convolutional layer, the input channels of the last convolutional layer and the input/output channels of all the middle convolutional layers are set asn_channel.n_conv (
int) – convolution will runn_conv + 1times, defaults to 2.lr (
float) – learning rate for Adam algorithm, defaults to 0.002.weight_decay (
float) – weight decay for Adam algorithm, defaults to 1e-5.pretrain_epochs (
int) – pretrain epochs, defaults to 400.iterations (
int) – training iterations, defaults to 2100.sim_weight (
float) – sim weight, defaults to 0.4.con_weight (
float) – con weight, defaults to 0.7.min_label (
int) – the number of labels when the training stops, defaults to 7.gpu (
Union[int,str,None]) – the GPU to be used, defaults to None to use CPU.result_prefix (
str) – the results will be save into obs whose column names are ‘{result_prefix}_discrete_clusters’ and ‘{result_prefix}_clusters’, defaults to ‘SpaSEG’, ‘{result_prefix}_discrete_clusters’ is the original cluster label, it may be discrete, ‘{result_prefix}_clusters’ is the cluster label after converting to continuous, which is used usually.
- Returns:
A SpaSeg object