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

Example 4 - KeyError: 'spatial' #31

Open
Leroy-Xiong opened this issue Jul 15, 2024 · 1 comment
Open

Example 4 - KeyError: 'spatial' #31

Leroy-Xiong opened this issue Jul 15, 2024 · 1 comment

Comments

@Leroy-Xiong
Copy link

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!

@gefeiwang
Copy link
Collaborator

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

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

2 participants