atarashansky / SAMap

SAMap: Mapping single-cell RNA sequencing datasets from evolutionarily distant organisms.
MIT License
66 stars 19 forks source link

Error when "transfer_annotations" #73

Closed rodrisenovilla closed 2 years ago

rodrisenovilla commented 2 years ago

First of all, thanks for the tool, it is pretty cool! I could install samap and re-run all the vignette finely, but when I tried to transfer the annotations from one object to the integrated object, this panda-related error appeared. I have tried with the docker version, in case it was an installation issue, but it crashed too. With my own data, same error...

This is the input:

table=transfer_annotations(sm,reference_id='sc',keys='tissue')

This is the error message it sends:

KeyError Traceback (most recent call last) ~/.local/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 3620 try: -> 3621 return self._engine.get_loc(casted_key) 3622 except KeyError as err:

~/.local/lib/python3.8/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

~/.local/lib/python3.8/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'tissue'

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last)

in ----> 1 table=transfer_annotations(sm,reference_id='sc',keys='tissue') ~/bioinfo/SAMap/samap/analysis.py in transfer_annotations(sm, reference_id, keys, num_iters, inplace) 1532 ANN = stitched.adata.obs 1533 ANNr = samref.adata.obs -> 1534 cl = ANN[key].values.astype('object').astype('str') 1535 clr = reference_id+'_'+ANNr[key].values.astype('object') 1536 cl[np.invert(np.in1d(cl,clr))]='' ~/.local/lib/python3.8/site-packages/pandas/core/frame.py in __getitem__(self, key) 3504 if self.columns.nlevels > 1: 3505 return self._getitem_multilevel(key) -> 3506 indexer = self.columns.get_loc(key) 3507 if is_integer(indexer): 3508 indexer = [indexer] ~/.local/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 3621 return self._engine.get_loc(casted_key) 3622 except KeyError as err: -> 3623 raise KeyError(key) from err 3624 except TypeError: 3625 # If we have a listlike key, _check_indexing_error will raise KeyError: 'tissue' I don't know if you need more info, but let me know if I could be more helpful! Thank you again, best regards! Rodrigo Senovilla Ganzo
huawen-poppy commented 2 years ago

I had the same problem. To solve it, I defined the transfer_annotation function in my local jupyter notebook, which is the same as the transfer_annotation function in https://github.com/atarashansky/SAMap/blob/main/samap/analysis.py After this, the local function transfer_annotation works. Hope this helps.

rodrisenovilla commented 2 years ago

Thank you for teh suggestion! Same error, don't get why... I believe it must be because SAMap cannot find the annotation in the object, so that is why "tissue" is not found... But don't know how to solve it