Cell annotation_indeces Error #19
AnaAzambuja
started this conversation in
General
Replies: 1 comment
-
|
That means some barcodes do not exist in the current anndata object. If you used Scanpy directly to annotate the cells then there's usually no need to save as a cell_annotation.tsv and re-read in. If you used other packages such as Seurat for labeling, then the filtered cell list can be different. You can check if all are in the anndata with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am running with my dataset and I generated a cell_annotation.tsv file using yours as template.
When I run it, i getting this:
KeyError Traceback (most recent call last)
Cell In[36], line 1
----> 1 adata_rna = adata_rna[cell_annot.index,:]
2 adata_rna.obs['celltype'] = cell_annot['celltype']
File ~/miniconda3/envs/py38Ana/lib/python3.8/site-packages/anndata/_core/anndata.py:1113, in AnnData.getitem(self, index)
1111 def getitem(self, index: Index) -> "AnnData":
1112 """Returns a sliced view of the object."""
-> 1113 oidx, vidx = self._normalize_indices(index)
1114 return AnnData(self, oidx=oidx, vidx=vidx, asview=True)
File ~/miniconda3/envs/py38Ana/lib/python3.8/site-packages/anndata/_core/anndata.py:1094, in AnnData._normalize_indices(self, index)
1093 def _normalize_indices(self, index: Optional[Index]) -> Tuple[slice, slice]:
-> 1094 return _normalize_indices(index, self.obs_names, self.var_names)
File ~/miniconda3/envs/py38Ana/lib/python3.8/site-packages/anndata/_core/index.py:35, in _normalize_indices(index, names0, names1)
33 index = index[0].values, index[1]
34 ax0, ax1 = unpack_index(index)
---> 35 ax0 = _normalize_index(ax0, names0)
36 ax1 = _normalize_index(ax1, names1)
37 return ax0, ax1
File ~/miniconda3/envs/py38Ana/lib/python3.8/site-packages/anndata/_core/index.py:101, in _normalize_index(indexer, index)
99 if np.any(positions < 0):
100 not_found = indexer[positions < 0]
--> 101 raise KeyError(
102 f"Values {list(not_found)}, from {list(indexer)}, "
103 "are not valid obs/ var names or indices."
104 )
105 return positions # np.ndarray[int]
106 else:
KeyError: "Values ['AAACCGAAGAGGGACT-1', 'AAACGCGCAGCATGAG-1', 'AACTAGCTCTCACTCA-1', 'AACTTAGTCGCACACA-1', 'AAGAACAGTGATGGCT-1', 'AAGGATCCATCTTGAG-1'....TTTGTTGGTGCATTTC-1'], are not valid obs/ var names or indices."
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions