zktuong / ktplotspy

Python library for plotting Cellphonedb results. Ported from ktplots R package.
https://ktplotspy.readthedocs.io/
MIT License
46 stars 12 forks source link

ValueError on plot_cpdb_heatmap with degs_analysis=True #40

Closed elainarose97 closed 11 months ago

elainarose97 commented 1 year ago

I am trying to run the plot_cpdb_heatmap function on the output of CellPhoneDB method 3. I used the relevant_interactions.txt for the pvals argument as recommended in the R documentation. Here is the command I used:

kpy.plot_cpdb_heatmap(adata, pvals=pvals, celltype_key = "celltype", degs_analysis=True)

It created this error:

ValueError                                Traceback (most recent call last)
Cell In[8], line 1
----> 1 kpy.plot_cpdb_heatmap(adata, pvals=pvals, celltype_key = "celltype", degs_analysis=True, figsize=(5, 5), title="Sum of significant interactions")

File ~/anaconda3/lib/python3.10/site-packages/ktplotspy/plot/plot_cpdb_heatmap.py:96, in plot_cpdb_heatmap(adata, pvals, celltype_key, degs_analysis, log1p_transform, alpha, linewidths, row_cluster, col_cluster, low_col, mid_col, high_col, cmap, title, return_tables, symmetrical, **kwargs)
     94 count_mat[pd.isnull(count_mat)] = 0
     95 if symmetrical:
---> 96     count_matx = np.triu(count_mat) + np.tril(count_mat.T) + np.tril(count_mat) + np.triu(count_mat.T)
     97     count_matx[np.diag_indices_from(count_matx)] = np.diag(count_mat)
     98     count_matx = pd.DataFrame(count_matx)

ValueError: operands could not be broadcast together with shapes (11,12) (12,11)

I had no problem using Method 2 output without the degs_analysis argument.

zktuong commented 1 year ago

hi @elainarose97, would you be able to try installing the upcoming release version of ktplotspy and see if it helps?

pip install git+https://www.github.com/zktuong/ktplotspy@prep_for_v5

elainarose97 commented 1 year ago

Hi thanks for getting back to me! I was able to install the latest version, but now I am getting a new error message after running the same command.

TypeError                                 Traceback (most recent call last)
Cell In[9], line 1
----> 1 kpy.plot_cpdb_heatmap(adata, pvals=pvals, celltype_key = "celltype", degs_analysis=True, figsize=(5, 5), title="Sum of significant interactions")

TypeError: plot_cpdb_heatmap() got multiple values for argument 'pvals'
zktuong commented 1 year ago

Oh yea. There's no need to supply adata into the function anymore.

elainarose97 commented 1 year ago

I see, but after removing adata from the function, it went back to the original error message.

ValueError: operands could not be broadcast together with shapes (11,12) (12,11)
zktuong commented 1 year ago

Would you be able to send me a version of your file so i can see what's going on? You can send to z.tuong@uq.edu.au

elainarose97 commented 1 year ago

Yes, I just did. Thanks