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

1877 del celldata.uns["spatial"] - error #163

Open
spatts14 opened this issue Mar 25, 2024 · 0 comments
Open

1877 del celldata.uns["spatial"] - error #163

spatts14 opened this issue Mar 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@spatts14
Copy link

Hi,

I would really like to try to use this method on my Xenium spatial transcriptomics data that I've pre-processed with squidpy, however Im running into some issues.

Here is my Anndata object:
AnnData object with n_obs × n_vars = 53466 × 339
obs: 'cell_id', 'x_centroid', 'y_centroid', 'transcript_counts', 'control_probe_counts', 'control_codeword_counts', 'unassigned_codeword_counts', 'deprecated_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'pct_counts_in_top_10_genes', 'pct_counts_in_top_20_genes', 'pct_counts_in_top_50_genes', 'n_counts', 'leiden_1.0', 'new_clusters', 'Cell_Type', 'Cluster', 'Condition', 'Sample_ID'
var: 'gene_ids', 'feature_types', 'genome', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'n_cells'
uns: 'dendrogram_leiden_1.0', 'leiden', 'leiden_1.0_colors', 'log1p', 'neighbors', 'new_clusters_colors', 'pca', 'rank_genes_groups', 'umap'
obsm: 'X_pca', 'X_umap', 'spatial'
varm: 'PCs'
layers: 'raw_count'
obsp: 'connectivities', 'distances'

This is the code I'm running

ncem.data = customLoader(
    adata=adata, cluster='new_cluster', patient='Sample_ID', library_id='None', radius=52
)
get_data_custom(interpreter=ncem)

Here is the error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[7], [line 1](vscode-notebook-cell:?execution_count=7&line=1)
----> [1](vscode-notebook-cell:?execution_count=7&line=1) ncem.data = customLoader(
      [2](vscode-notebook-cell:?execution_count=7&line=2)     adata=adata, cluster='new_cluster', patient='Sample_ID', library_id='None', radius=52
      [3](vscode-notebook-cell:?execution_count=7&line=3) )
      [4](vscode-notebook-cell:?execution_count=7&line=4) get_data_custom(interpreter=ncem)

File [~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1852](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1852), in customLoader.__init__(self, adata, cluster, patient, library_id, radius, coord_type, n_rings, n_top_genes, label_selection)
   [1849](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1849) self.library_id = library_id
   [1851](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1851) print("Loading data from raw files")
-> [1852](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1852) self.register_celldata(n_top_genes=n_top_genes)
   [1853](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1853) self.register_img_celldata()
   [1854](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1854) self.register_graph_features(label_selection=label_selection)

File [~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1772](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1772), in DataLoader.register_celldata(self, n_top_genes)
   [1770](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1770) """Load AnnData object of complete dataset."""
   [1771](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1771) print("registering celldata")
-> [1772](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1772) self._register_celldata(n_top_genes=n_top_genes)
   [1773](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1773) assert self.celldata is not None, "celldata was not loaded"

File [~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1877](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1877), in customLoader._register_celldata(self, n_top_genes)
   [1875](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1875) celldata.X = celldata.X.toarray()
   [1876](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1876) celldata.uns["metadata"] = metadata
-> [1877](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1877) del celldata.uns["spatial"]
   [1879](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1879) # register node type names
   [1880](https://file+.vscode-resource.vscode-cdn.net/Users/sarapatti/Desktop/PhD_projects/Llyod_lab/ST_Xenium_Asthma/scripts/~/opt/anaconda3/envs/ncem/lib/python3.8/site-packages/ncem/data.py:1880) node_type_names = list(np.unique(celldata.obs[self.cluster]))

KeyError: 'spatial'

Any suggestions on why Im getting this error?

System:

  • OS: 14.2.1
  • Language Version: Python 3.9
  • Virtual environment: [e.g. Conda]
@spatts14 spatts14 added the bug Something isn't working label Mar 25, 2024
@spatts14 spatts14 changed the title Bug Summary 1877 del celldata.uns["spatial"] - error Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant