-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
I am trying animate function but I get an error:
sm.hl.animate(adata_a, x_coordinate = 'X_centroid', y_coordinate = 'Y_centroid')
KeyError Traceback (most recent call last)
Cell In[29], [line 6](vscode-notebook-cell:?execution_count=29&line=6)
[3](vscode-notebook-cell:?execution_count=29&line=3) adata_a.obs['Y_centroid'] = adata_a.obsm['Y_centroid'].flatten()
[5](vscode-notebook-cell:?execution_count=29&line=5) # Basic animation with default UMAP and spatial coordinates
----> [6](vscode-notebook-cell:?execution_count=29&line=6) sm.hl.animate(adata_a, x_coordinate = 'X_centroid', y_coordinate = 'Y_centroid')
[8](vscode-notebook-cell:?execution_count=29&line=8) # sm.hl.animate(adata_a,
[9](vscode-notebook-cell:?execution_count=29&line=9) # embedding='umap',
[10](vscode-notebook-cell:?execution_count=29&line=10) # x_coordinate='X_centroid',
(...)
[33](vscode-notebook-cell:?execution_count=29&line=33) # sm.hl.animate(adata, color='condition', palette={'Control': '#1f77b4', 'Treated': '#ff7f0e'},
[34](vscode-notebook-cell:?execution_count=29&line=34) # subset='image_01', interval=100, save_animation='custom_animation.gif')
File /opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/scimap/helpers/animate.py:267, in animate(adata, color, palette, embedding, x_coordinate, y_coordinate, flip_y, imageid, subset, layer, use_raw, log, subsample, random_state, n_frames, interval, reverse, final_frame, s, alpha, cmap, tight_layout, plot_legend, title, fontsize, watermark, figsize, pltStyle, verbose, save_animation, **kwargs)
[265](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/scimap/helpers/animate.py:265) # extract the spaces
[266](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/scimap/helpers/animate.py:266) e1 = final_data[['umap-1', 'umap-2']].values.astype(float)
--> [267](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/scimap/helpers/animate.py:267) e2 = final_data[[x_coordinate,y_coordinate]].values.astype(float)
[270](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/scimap/helpers/animate.py:270) # rescale to same co-ordinates system
[271](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/scimap/helpers/animate.py:271) e1[:, 0] -= (max(e1[:, 0]) + min(e1[:, 0])) / 2
File /opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/frame.py:4108, in DataFrame.__getitem__(self, key)
[4106](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/frame.py:4106) if is_iterator(key):
[4107](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/frame.py:4107) key = list(key)
-> [4108](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/frame.py:4108) indexer = self.columns._get_indexer_strict(key, "columns")[1]
[4110](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/frame.py:4110) # take() does not accept boolean indexers
...
-> [6249](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/indexes/base.py:6249) raise KeyError(f"None of [{key}] are in the [{axis_name}]")
[6251](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/indexes/base.py:6251) not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique())
[6252](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Caskroom/miniforge/base/envs/akoya/lib/python3.10/site-packages/pandas/core/indexes/base.py:6252) raise KeyError(f"{not_found} not in index")
KeyError: "None of [Index(['X_centroid', 'Y_centroid'], dtype='object')] are in the [columns]"
Even if I have both 'X_centroid' and 'Y_centroid' in my adata.obs:
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
