You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File ~/miniconda3/envs/ov/lib/python3.11/site-packages/omicverse/pl/_cpdb.py:543, in cpdb_group_heatmap(adata, celltype_key, means, source_cells, target_cells, min_means, nodecolor_dict, ax, figsize, fontsize, plot_secret, cmap, return_table)
541 source_gene_pd=pd.DataFrame(index=cor.index)
542 for source_cell in source_cells:
--> 543 source_gene_pd[source_cell]=adata[adata.obs['cell_labels']==source_cell,
544 [i.split('_')[0] for i in cor.index]].to_df().mean().values
546 target_gene_pd=pd.DataFrame(index=cor.index)
547 for target_cell in target_cells:
File ~/miniconda3/envs/ov/lib/python3.11/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
3807 if isinstance(casted_key, slice) or (
3808 isinstance(casted_key, abc.Iterable)
3809 and any(isinstance(x, slice) for x in casted_key)
3810 ):
3811 raise InvalidIndexError(key)
-> 3812 raise KeyError(key) from err
3813 except TypeError:
3814 # If we have a listlike key, _check_indexing_error will raise
3815 # InvalidIndexError. Otherwise we fall through and re-raise
3816 # the TypeError.
3817 self._check_indexing_error(key)
KeyError: 'cell_labels'
The text was updated successfully, but these errors were encountered:
I'm sorry for the trouble, I'll fix it in the next version, until then you can manually define adata.obs['cell_labels'] = adata.obs[celltype_key] to avoid this error!
here, you might forget to change 'cell_labels' to the celltype_key?
--> 543 source_gene_pd[source_cell]=adata[adata.obs['cell_labels']==source_cell,
Details are above
KeyError Traceback (most recent call last)
File ~/miniconda3/envs/ov/lib/python3.11/site-packages/pandas/core/indexes/base.py:3805, in Index.get_loc(self, key)
3804 try:
-> 3805 return self._engine.get_loc(casted_key)
3806 except KeyError as err:
File index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()
File index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()
File pandas/_libs/hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas/_libs/hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'cell_labels'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Cell In[135], line 1
----> 1 ov.pl.cpdb_group_heatmap(adata=adata,
2 celltype_key='celltype',
3 means=cpdb_results['means'],
4 cmap={'Target':'Blues','Source':'Reds'},
5 source_cells=[Mast cell'],
6 target_cells=['T cell'],
7 plot_secret=True,
8 min_means=3,
9 nodecolor_dict=None,
10 ax=None,
11 figsize=(2,6),
12 fontsize=10
13 )
File ~/miniconda3/envs/ov/lib/python3.11/site-packages/omicverse/pl/_cpdb.py:543, in cpdb_group_heatmap(adata, celltype_key, means, source_cells, target_cells, min_means, nodecolor_dict, ax, figsize, fontsize, plot_secret, cmap, return_table)
541 source_gene_pd=pd.DataFrame(index=cor.index)
542 for source_cell in source_cells:
--> 543 source_gene_pd[source_cell]=adata[adata.obs['cell_labels']==source_cell,
544 [i.split('_')[0] for i in cor.index]].to_df().mean().values
546 target_gene_pd=pd.DataFrame(index=cor.index)
547 for target_cell in target_cells:
File ~/miniconda3/envs/ov/lib/python3.11/site-packages/pandas/core/frame.py:4102, in DataFrame.getitem(self, key)
4100 if self.columns.nlevels > 1:
4101 return self._getitem_multilevel(key)
-> 4102 indexer = self.columns.get_loc(key)
4103 if is_integer(indexer):
4104 indexer = [indexer]
File ~/miniconda3/envs/ov/lib/python3.11/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)
3807 if isinstance(casted_key, slice) or (
3808 isinstance(casted_key, abc.Iterable)
3809 and any(isinstance(x, slice) for x in casted_key)
3810 ):
3811 raise InvalidIndexError(key)
-> 3812 raise KeyError(key) from err
3813 except TypeError:
3814 # If we have a listlike key, _check_indexing_error will raise
3815 # InvalidIndexError. Otherwise we fall through and re-raise
3816 # the TypeError.
3817 self._check_indexing_error(key)
KeyError: 'cell_labels'
The text was updated successfully, but these errors were encountered: