Tutorial 3: Slide-seq or Stereo-seq dataset =========================================== .. raw:: html
In this tutorial, we show how to apply scSTADE to identify spatial domains on Slide-seq or Stereo-seq. As a example, we analyse the Stereo dataset.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. raw:: html
The source code package is freely available at https://github.com/cuiyaxuan/scSTADE/tree/master. The datasets used in this study can be found at https://drive.google.com/drive/folders/1H-ymfCqlDR1wpMRX-bCewAjG5nOrIF51?usp=sharing.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code:: ipython3 import sys sys.path.append("/.../scSTADE-master/scSTADE_Cluster_Functions") # Input the path. from scSTADE import scSTADE import os import torch import pandas as pd import scanpy as sc from sklearn import metrics import multiprocessing as mp def setup_seed(seed=41): import torch import os import numpy as np import random torch.manual_seed(seed) np.random.seed(seed) # Numpy module. random.seed(seed) # Python random module. if torch.cuda.is_available(): # torch.backends.cudnn.benchmark = False torch.backends.cudnn.deterministic = True torch.cuda.manual_seed(seed) torch.cuda.manual_seed_all(seed) #os.environ['PYTHONHASHSEED'] = str(seed) setup_seed(41) device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') n_clusters = 10 ###### the number of spatial domains. file_path = '/home/cuiyaxuan/spatialLIBD/5.Mouse_Olfactory/' #please replace 'file_path' with the download path adata = sc.read_h5ad(file_path + 'filtered_feature_bc_matrix.h5ad') #### project name adata.var_names_make_unique() model = scSTADE(adata,datatype='Slide',device=device,n_top_genes=4000) adata = model.train() radius = 50 tool = 'mclust' # mclust, leiden, and louvain from utils import clustering if tool == 'mclust': clustering(adata, n_clusters, radius=radius, method=tool, refinement=True) elif tool in ['leiden', 'louvain']: clustering(adata, n_clusters, radius=radius, method=tool, start=0.1, end=2.0, increment=0.01, refinement=False) adata.obs['domain'] adata.obs['domain'].to_csv("label.csv") .. parsed-literal:: /home/cuiyaxuan/anaconda3/envs/pytorch/lib/python3.8/site-packages/scanpy/preprocessing/_highly_variable_genes.py:62: UserWarning: `flavor='seurat_v3'` expects raw count data, but non-integers were found. warnings.warn( .. parsed-literal:: Graph constructed! Building sparse matrix ... Begin to train ST data... .. parsed-literal:: 0%| | 0/500 [00:00