API¶
Import PAST with:
import past
Model¶
|
PAST Model: latent feature extraction and spatial domain deciphering with a prior-based self-attention framework for spatial transcriptomics |
Utils¶
|
Set random seed |
|
Align the gene set of reference dataset with that of target dataset |
|
Select spatially variable genes for better downstream analysis |
|
Data preprocess for downstream analysis |
|
construct pseudo bulk from reference dataset according to annotation |
|
visualization for cell embedding and spatial clustering |
|
Training stategy of subgraph segmentation based on random walk, enabling mini-batch training on large datasets |
|
Prediction stategy of subgraph segmentation based on random walk, enabling mini-batch prediction on large datasets |
|
Spatial Transcriptomic Dataset |
|
Parameters in neural network to be trained |
|
Construct spatial prior graph for metric learning |
|
Add noise to gene expression matrix |
|
Use SVM with radial basis function kernel as classifier to train on the reference dataset and annotate the target dataset. |
|
Based on domain annotation and dataset annotation, apply Stratified downsampling to DLPFC dataset |
Evaluation¶
|
K-fold cross validation, taking low-dimensional embedding as input, annotation as output and SVM with rbf kernel as classifier |
|
Refine clustering result according spatial neighborhood |
|
Default louvain clustering algorithm applied in scanpy package with default resolution 1.0 |
|
Default leiden clustering algorithm applied in scanpy package with default resolution 1.0 |
|
Search resolution so that louvain clustering algorithm obtain cluster numbers as close to given number as possible |
|
Search resolution so that leiden clustering algorithm obtain cluster numbers as close to given number as possible |
|
Clustering using the mclust algorithm. |
|
clustering metrics including ARI, AMI, HOMO and NMI |