Tutorial 2: 10X Visium Breast dataset ===================================== .. raw:: html
In this tutorial, we show how to apply scSTADE to identify spatial domains on 10X Visium data. As a example, we analyse the Breast 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 #Low-resolution spatial transcriptomics data simplified version. 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:1' if torch.cuda.is_available() else 'cpu') n_clusters = 30 ###### the number of spatial domains. file_fold = '/home/cuiyaxuan/spatialLIBD/3.Human_Breast_Cancer' #### to your path adata = sc.read_visium(file_fold, count_file='filtered_feature_bc_matrix.h5', load_images=True) #### project name adata.var_names_make_unique() model = scSTADE(adata,device=device,n_top_genes=5000) 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:: Begin to train ST data... .. parsed-literal:: 0%| | 0/500 [00:00