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

Error in samples concatenation #25

Closed
ParisaMa opened this issue Aug 16, 2019 · 2 comments
Closed

Error in samples concatenation #25

ParisaMa opened this issue Aug 16, 2019 · 2 comments

Comments

@ParisaMa
Copy link

Hi,

When I try to run the following line (on the case study) I receive an error:

adata.var['gene_id'] = adata.var['gene_id-1']

KeyError Traceback (most recent call last)
//anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2656 try:
-> 2657 return self._engine.get_loc(key)
2658 except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

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: 'gene_id-1'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
in
31 # Concatenate to main adata object
32 adata = adata.concatenate(adata_tmp, batch_key='sample_id')
---> 33 adata.var['gene_id'] = adata.var['gene_id-1']
34 #adata.var.drop(columns = ['gene_id-1', 'gene_id-0'], inplace=True)
35 #adata.obs.drop(columns=['sample_id'], inplace=True)

//anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in getitem(self, key)
2925 if self.columns.nlevels > 1:
2926 return self._getitem_multilevel(key)
-> 2927 indexer = self.columns.get_loc(key)
2928 if is_integer(indexer):
2929 indexer = [indexer]

//anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2657 return self._engine.get_loc(key)
2658 except KeyError:
-> 2659 return self._engine.get_loc(self._maybe_cast_indexer(key))
2660 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
2661 if indexer.ndim > 1 or indexer.size > 1:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

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: 'gene_id-1'

Seems like the 'adata.concatenate' function does not create any variables as 'gene_id-1' or 'gene_id-0'. Can you please check this?

@LuckyMD
Copy link
Contributor

LuckyMD commented Aug 18, 2019

Hi,

When posting an issue, please look up previous issues with potentially the same topic. This is addressed in issue #21. A recent Anndata update now solves an issue I was addressing with 2 lines in the script. You can now comment those out.

@ParisaMa
Copy link
Author

Thanks!

@LuckyMD LuckyMD closed this as completed Aug 26, 2019
This was referenced May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants