rmarkello / abagen

A toolbox for working with Allen Human Brain Atlas microarray expression data
https://abagen.readthedocs.io
BSD 3-Clause "New" or "Revised" License
92 stars 41 forks source link

[...] not in index #231

Open remenderfdif opened 5 months ago

remenderfdif commented 5 months ago

Hi, A couple days ago, I ran the following code and it was working, but now it's reporting an error,and I don't know how to fix this: import nibabel as nib atlas = nib.load('E:\BN_Atlas_246_2mm.nii') import pandas as pd atlas_info = pd.read_csv('E:\BN246_info.csv') expression3 = abagen.get_expression_data(atlas, atlas_info, probe_selection='rnaseq', norm_structures = True, sim_threshold = 0.2) print(expression3)

KeyError Traceback (most recent call last) Cell In[5], line 5 3 import pandas as pd 4 atlas_info = pd.read_csv('E:\BN246_info.csv') ----> 5 expression3 = abagen.get_expression_data(atlas, atlas_info, probe_selection='rnaseq', norm_structures = True, sim_threshold = 0.2) 6 print(expression3)

File ~.conda\envs\abagen_test\Lib\site-packages\abagen\allen.py:430, in get_expression_data(atlas, atlas_info, ibf_threshold, probe_selection, donor_probes, sim_threshold, lr_mirror, exact, missing, tolerance, sample_norm, gene_norm, norm_matched, norm_structures, region_agg, agg_metric, corrected_mni, reannotated, return_counts, return_donors, return_report, donors, data_dir, verbose, nproc) 428 annot = samples.drop_mismatch_samples(annot, ontol) 429 if simthreshold is not None: --> 430 annot = samples.similarity_threshold(data['microarray'], 431 annot, probe_info, 432 threshold=sim_threshold) 433 data['annotation'] = annot 434 annotation = flatten_dict(files, 'annotation')

File ~.conda\envs\abagentest\Lib\site-packages\abagen\samples.py:365, in similarity_threshold(microarray, annotation, probes, threshold) 362 probes = io.read_probes(probes) 363 microarray = io.read_microarray(microarray, copy=False) --> 365 corrs = np.corrcoef(microarray.loc[probes.index, annotation.index].T) 366 sim = np.sum(corrs, axis=1) 367 thresh = np.mean(sim) - (threshold * np.std(sim, ddof=1))

File ~.conda\envs\abagen_test\Lib\site-packages\pandas\core\indexing.py:1184, in _LocationIndexer.getitem(self, key) 1182 if self._is_scalar_access(key): 1183 return self.obj._get_value(*key, takeable=self._takeable) -> 1184 return self._getitem_tuple(key) 1185 else: 1186 # we by definition only have the 0th axis 1187 axis = self.axis or 0

File ~.conda\envs\abagen_test\Lib\site-packages\pandas\core\indexing.py:1375, in _LocIndexer._getitem_tuple(self, tup) 1373 # ugly hack for GH #836 1374 if self._multi_take_opportunity(tup): -> 1375 return self._multi_take(tup) 1377 return self._getitem_tuple_same_dim(tup)

File ~.conda\envs\abagen_test\Lib\site-packages\pandas\core\indexing.py:1326, in _LocIndexer._multi_take(self, tup) 1310 """ 1311 Create the indexers for the passed tuple of keys, and 1312 executes the take operation. This allows the take operation to be (...) 1323 values: same type as the object being indexed 1324 """ 1325 # GH 836 -> 1326 d = { 1327 axis: self._get_listlike_indexer(key, axis) 1328 for (key, axis) in zip(tup, self.obj._AXIS_ORDERS) 1329 } 1330 return self.obj._reindex_with_indexers(d, copy=True, allow_dups=True)

File ~.conda\envs\abagen_test\Lib\site-packages\pandas\core\indexing.py:1327, in (.0) 1310 """ 1311 Create the indexers for the passed tuple of keys, and 1312 executes the take operation. This allows the take operation to be (...) 1323 values: same type as the object being indexed 1324 """ 1325 # GH 836 1326 d = { -> 1327 axis: self._get_listlike_indexer(key, axis) 1328 for (key, axis) in zip(tup, self.obj._AXIS_ORDERS) 1329 } 1330 return self.obj._reindex_with_indexers(d, copy=True, allow_dups=True)

File ~.conda\envs\abagen_test\Lib\site-packages\pandas\core\indexing.py:1558, in _LocIndexer._get_listlike_indexer(self, key, axis) 1555 ax = self.obj._get_axis(axis) 1556 axis_name = self.obj._get_axis_name(axis) -> 1558 keyarr, indexer = ax._get_indexer_strict(key, axis_name) 1560 return keyarr, indexer

File ~.conda\envs\abagen_test\Lib\site-packages\pandas\core\indexes\base.py:6200, in Index._get_indexer_strict(self, key, axis_name) 6197 else: 6198 keyarr, indexer, new_indexer = self._reindex_non_unique(keyarr) -> 6200 self._raise_if_missing(keyarr, indexer, axis_name) 6202 keyarr = self.take(indexer) 6203 if isinstance(key, Index): 6204 # GH 42790 - Preserve name from an Index

File ~.conda\envs\abagen_test\Lib\site-packages\pandas\core\indexes\base.py:6252, in Index._raise_if_missing(self, key, indexer, axis_name) 6249 raise KeyError(f"None of [{key}] are in the [{axis_name}]") 6251 not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique()) -> 6252 raise KeyError(f"{not_found} not in index")

KeyError: '[1071165, 1071173, 1071193, 1071199, 1071210] not in index'