cellphonedb results visualization
0
1
Entering edit mode
23 months ago
piotto ▴ 20

I want to visualize cellphonedb results but I get several error. I do visualization by ktplotspy package. First, I read the required files based on its tutorials and when I try to create the heatmap, it gives an error:

code:

kpy.plot_cpdb_heatmap(
        adata=adata,
        pvals=pvals,
        celltype_key="celltype",
        figsize = (5,5),
        title = "Sum of significant interactions"
    )

Error:

>Traceback (most recent call last):
  File "/Users/pedram/opt/anaconda3/envs/CPDB-New/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3803, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'celltype'


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

>Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pedram/opt/anaconda3/envs/CPDB-New/lib/python3.8/site-packages/ktplotspy/plot/plot_cpdb.py", line 181, in plot_cpdb
    metadata = ensure_categorical(meta=metadata, key=celltype_key)
  File "/Users/pedram/opt/anaconda3/envs/CPDB-New/lib/python3.8/site-packages/ktplotspy/utils/support.py", line 111, in ensure_categorical
    if not is_categorical(meta[key]):
  File "/Users/pedram/opt/anaconda3/envs/CPDB-New/lib/python3.8/site-packages/pandas/core/frame.py", line 3805, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/Users/pedram/opt/anaconda3/envs/CPDB-New/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    raise KeyError(key) from err
KeyError: 'celltype'

I guess it might be related to the h5ad file but not sure. Also, if there is any suggestion regarding visualization of cpdb results, I welcome.

cellphonedb ktplotspy cpdb visulization • 1.4k views
ADD COMMENT
0
Entering edit mode

Did you solve this? I am struggling with the same issue...

ADD REPLY
0
Entering edit mode

I had this same issue and I was able to resolve it by noting that my cell type annotation column in my adata frame object had a different name. Once I replaced "celltype" with the correct column, I was able to solve this issue

ADD REPLY

Login before adding your answer.

Traffic: 1938 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6