Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during constructing the spatial network #10

Open
OMIC-coding opened this issue Nov 3, 2023 · 5 comments
Open

Error during constructing the spatial network #10

OMIC-coding opened this issue Nov 3, 2023 · 5 comments

Comments

@OMIC-coding
Copy link

I finally successfully installed the STAligner package and I can follow the pipeline in the tutorial file. However, I encountered the error when I run this procedure: STAligner.Cal_Spatial_Net
I got similar feedback for each sample as follows:
0.000 neighbors per cell on average

@zhoux85 zhoux85 closed this as completed Nov 4, 2023
@zhoux85 zhoux85 reopened this Nov 4, 2023
@zhoux85
Copy link
Owner

zhoux85 commented Nov 4, 2023

Hi. Your platform is Visium or stereo-seq? Please set rad_cutoff=150 for Visium to have ~6 neighbors. You can adjust rad_cutoff to keep about 5-10 neighbors.

@OMIC-coding
Copy link
Author

Batch_list = []
adj_list = []
sp_data_folder = '/data/project/liziyu/NAFLD/data/ST/'
section_ids = os.listdir(sp_data_folder)
group_dict = {'KZ-CTR-161':'HD','CTR-179':'HD','KZ-CTR-180':'HD','CYG-1495':'NAFL','CYL-1501':'NASH','HJD-1478':'NASH','HJJ-1480':'NASH','LCQ-1481':'NASH','LLF-1492':'NAFL','LP-1494':'NASH','LSH-1498':'NAFL','XRP-1493':'NAFL','YM-171':'NAFL','ZHT-1475':'NASH','ZLM-1497':'NAFL','ZTH-1479':'NAFL'}
for section_id in section_ids:
adata = sc.read_visium(path=os.path.join(sp_data_folder,section_id),count_file='filtered_feature_bc_matrix.h5',load_images=True)
adata.var_names_make_unique(join='++')
adata.obs['group'] = group_dict.get(list(adata.uns['spatial'].keys())[0])
#make spot name unique
adata.obs_names = [section_id+'_'+x for x in adata.obs_names]
#Constructing the spatial network
STAligner.Cal_Spatial_Net(adata,rad_cutoff=150) #the spatial network are saved in adata.uns['adj]
STAligner.Stats_Spatial_Net(adata) #plot the number of spatial neighbors
#Normalization
sc.pp.highly_variable_genes(adata,flavor='seurat_v3',n_top_genes=10000) #ensure enough common HVGs in the combined matrix
sc.pp.normalize_total(adata,target_sum=1e4)
sc.pp.log1p(adata)
adata = adata[:,adata.var['highly_variable']]

adj_list.append(adata.uns['adj'])
Batch_list.append(adata)

@OMIC-coding
Copy link
Author

I have already set the rad_cutoff parameter to 150, but there is 0 edge still

@zhoux85
Copy link
Owner

zhoux85 commented Nov 7, 2023

You can increase rad_cutoff until reaching enough neighbors.

@BGItaojingxin
Copy link

How exactly this parameter rad_cutoff should be set appropriately?My data is from the same tumour but from different samples, not adjacent slices, the parameter is set small and the calculated edges are 0 edges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants