jianhuupenn/SpaGCN

SpaGCN not compatible with Visium HD data (single-cell resolution of ST data) - Memory Error

Closed this issue · 1 comments

Hey, I'm trying to run SpaGCN with histology=False and even then it gives a memory error using Visium HD data (600k bins/spots)


MemoryError                               Traceback (most recent call last)
Cell In[53], [line 2](vscode-notebook-cell:?execution_count=53&line=2)
      [1](vscode-notebook-cell:?execution_count=53&line=1) #Run SpaGCN
----> [2](vscode-notebook-cell:?execution_count=53&line=2) adata.obs["pred"]= spg.detect_spatial_domains_ez_mode(adata, img, x_array, y_array, x_pixel, y_pixel, n_clusters=7, histology=False, s=1, b=3, p=0.5, r_seed=100, t_seed=100, n_seed=100)
      [3](vscode-notebook-cell:?execution_count=53&line=3) adata.obs["pred"]=adata.obs["pred"].astype('category')
      [4](vscode-notebook-cell:?execution_count=53&line=4) #Refine domains (optional)
      [5](vscode-notebook-cell:?execution_count=53&line=5) #shape="hexagon" for Visium data, "square" for ST data.

File /mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/ez_mode.py:7, in detect_spatial_domains_ez_mode(adata, img, x_array, y_array, x_pixel, y_pixel, n_clusters, histology, s, b, p, r_seed, t_seed, n_seed)
      [6](https://vscode-remote+ssh-002dremote-002blcg.vscode-resource.vscode-cdn.net/mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/ez_mode.py:6) def detect_spatial_domains_ez_mode(adata, img, x_array, y_array, x_pixel, y_pixel, n_clusters, histology=True, s=1, b=49, p=0.5, r_seed=100, t_seed=100, n_seed=100):
----> [7](https://vscode-remote+ssh-002dremote-002blcg.vscode-resource.vscode-cdn.net/mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/ez_mode.py:7) 	adj=calculate_adj_matrix(x=x_pixel,y=y_pixel, x_pixel=x_pixel, y_pixel=y_pixel, image=img, beta=b, alpha=s, histology=histology)
      [8](https://vscode-remote+ssh-002dremote-002blcg.vscode-resource.vscode-cdn.net/mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/ez_mode.py:8) 	prefilter_genes(adata,min_cells=3) # avoiding all genes are zeros
      [9](https://vscode-remote+ssh-002dremote-002blcg.vscode-resource.vscode-cdn.net/mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/ez_mode.py:9) 	prefilter_specialgenes(adata)

File /mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/calculate_adj.py:78, in calculate_adj_matrix(x, y, x_pixel, y_pixel, image, beta, alpha, histology)
     [76](https://vscode-remote+ssh-002dremote-002blcg.vscode-resource.vscode-cdn.net/mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/calculate_adj.py:76) 	print("Calculateing adj matrix using xy only...")
     [77](https://vscode-remote+ssh-002dremote-002blcg.vscode-resource.vscode-cdn.net/mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/calculate_adj.py:77) 	X=np.array([x, y]).T.astype(np.float32)
---> [78](https://vscode-remote+ssh-002dremote-002blcg.vscode-resource.vscode-cdn.net/mnt/work/RO_src/venv/stnav_venv/lib/python3.10/site-packages/SpaGCN/calculate_adj.py:78) return pairwise_distance(X)

MemoryError: Allocation failed (probably too large).

Any improvements on this in the future? The way it was originally built, I don't think it is fit for sc-ST data unfortunately

Thanks

Closed due to inactivity from repo maintainers