STitch3D
STitch3D copied to clipboard
Example 4 - KeyError: 'spatial'
Hello!
I encountered the following error when I ran example 4:
Traceback (most recent call last):
File ".../STitch3D/example_4_dlpfc.py", line 83, in <module>
adata_st_list = STitch3D.utils.align_spots(adata_st_list_raw, plot=True)
File "D:\Programs\Anaconda3\envs\STitch3D\lib\site-packages\STitch3D\utils.py", line 39, in align_spots
plt.scatter(adata_st_list[i].obsm[coor_key][:, 0],
File "D:\Programs\Anaconda3\envs\STitch3D\lib\site-packages\anndata\_core\aligned_mapping.py", line 113, in __getitem__
_subset(self.parent_mapping[key], self.subset_idx),
File "D:\Programs\Anaconda3\envs\STitch3D\lib\site-packages\anndata\_core\aligned_mapping.py", line 148, in __getitem__
return self._data[key]
KeyError: 'spatial'
May I ask if you know what caused it?
I printed the adata_st_list[0]:
View of AnnData object with n_obs × n_vars = 3611 × 33538
obs: 'barcode', 'slice_id', 'layer'
var: 'gene_ids', 'feature_types', 'genome'
uns: 'spatial'
Thank you!
Hi,
in the function STitch3D.utils.align_spots(), the input AnnData objects are required to contain spatial locations in the attribute .obsm['spatial']. Please make sure the ST AnnData objects are read correctly, or you can manually set .obsm['spatial'] to be the Nx2 spatial coordinates of spots.
Best, Gefei