Starlitnightly / omicverse

A python library for multi omics included bulk, single cell and spatial RNA-seq analysis.
https://starlitnightly.github.io/omicverse/
GNU General Public License v3.0
431 stars 46 forks source link

ov.pl.cpdb_heatmap function error #136

Closed WeiQin2001 closed 1 month ago

WeiQin2001 commented 1 month ago

Describe the bug

运行ov.pl.cpdb_heatmap()函数的时候无法出现图 To Reproduce 按照教程一步步运行,一直到以下这一步: fig, ax = plt.subplots(figsize=(4,4)) ov.pl.cpdb_heatmap(adata, interaction['interaction_edges'], celltype_key='cell_labels', fontsize=11, ax=ax, legend_kws={'fontsize':12,'bbox_to_anchor':(5, -0.9),'loc':'center left',})

error representation

AssertionError Traceback (most recent call last) Cell In[17], line 2 1 fig, ax = plt.subplots(figsize=(4,4)) ----> 2 ov.pl.cpdb_heatmap(adata, 3 interaction['interaction_edges'], 4 celltype_key='cell_labels', 5 fontsize=11, 6 ax=ax, 7 legend_kws={'fontsize':12,'bbox_to_anchor':(5, -0.9),'loc':'center left',})

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/omicverse/pl/_cpdb.py:293, in cpdb_heatmap(adata, interaction_edges, celltype_key, nodecolor_dict, ax, source_cells, target_cells, figsize, fontsize, rotate, legend_kws, return_table, kwargs) 271 cm = DotClustermapPlotter( 272 corr_mat, 273 y='SOURCE', (...) 290 #cmap_legend_kws={'font':12}, 291 ) 292 else: --> 293 cm = DotClustermapPlotter( 294 corr_mat, 295 x='SOURCE', 296 y='TARGET', 297 value='COUNT', 298 hue='SOURCE', 299 legend_gap=7, 300 top_annotation=row_ha, 301 left_annotation=col_ha, 302 c='COUNT', 303 s='COUNT', 304 cmap='Reds', 305 vmin=0, 306 show_rownames=False, 307 show_colnames=False, 308 row_dendrogram=False, 309 col_names_side='top', 310 legend=True, 311 kwargs 312 #cmap_legend_kws={'font':12}, 313 ) 315 # 调整网格设置 316 cm.ax_heatmap.grid(which='minor', color='gray', linestyle='--', alpha=0.5)

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/PyComplexHeatmap/dotHeatmap.py:350, in DotClustermapPlotter.init(self, data, x, y, value, hue, s, c, marker, alpha, color_legend_kws, cmap_legend_kws, dot_legend_kws, dot_legend_marker, aggfunc, value_na, hue_na, s_na, c_na, x_order, y_order, spines, grid, max_s, kwargs) 347 self.dot_legend_marker=dot_legend_marker 348 self.max_s=max_s --> 350 super().init(kwargs)

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/PyComplexHeatmap/clustermap.py:1286, in ClusterMapPlotter.init(self, data, z_score, standard_scale, top_annotation, bottom_annotation, left_annotation, right_annotation, row_cluster, col_cluster, row_cluster_method, row_cluster_metric, col_cluster_method, col_cluster_metric, show_rownames, show_colnames, row_names_side, col_names_side, xticklabels_kws, yticklabels_kws, row_dendrogram, col_dendrogram, row_dendrogram_size, col_dendrogram_size, row_split, col_split, row_dendrogram_kws, col_dendrogram_kws, tree_kws, row_split_order, col_split_order, row_split_gap, col_split_gap, mask, subplot_gap, legend, legend_kws, plot, plot_legend, legend_anchor, legend_gap, legend_width, legend_hpad, legend_vpad, legend_side, cmap, label, xlabel, ylabel, xlabel_kws, ylabel_kws, xlabel_side, ylabel_side, xlabel_bbox_kws, ylabel_bbox_kws, rasterized, legend_delta_x, verbose, **kwargs) 1284 self.ylabel_bbox_kws = ylabel_bbox_kws 1285 if plot: -> 1286 self.plot() 1287 if plot_legend: 1288 if legend_anchor == "auto":

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/PyComplexHeatmap/clustermap.py:2300, in ClusterMapPlotter.plot(self, ax, subplot_spec, row_order, col_order) 2298 self._reorder_cols() 2299 col_order = self.col_order -> 2300 self.plot_matrix(row_order=row_order, col_order=col_order) 2301 if not self.top_annotation is None: 2302 gs = self.gs[0, 1] if not self.col_dendrogram else self.top_gs[1, 0]

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/PyComplexHeatmap/dotHeatmap.py:518, in DotClustermapPlotter.plot_matrix(self, row_order, col_order) 516 kwargs = self.kwargs.copy() 517 # print(kwargs) --> 518 dotHeatmap2d( 519 self.data2d.loc[rows, cols], 520 cmap=kwargs.pop("cmap", self.cmap), #default cmap is defined in ClusterMapPlotter 521 ax=ax1, 522 spines=self.spines, 523 **kwargs 524 ) 525 self.heatmap_axes[i, j] = ax1 526 ax1.yaxis.label.set_visible(False)

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/PyComplexHeatmap/dotHeatmap.py:193, in dotHeatmap2d(failed resolving arguments) 185 ax.scatter( 186 x=df2.X.values, 187 y=df2.Y.values, (...) 190 **kwargs 191 ) 192 else: #colors is dict & cmap is str --> 193 assert isinstance(colors,dict) 194 df["C"] = df["Hue"].map(colors).fillna(c_na) 195 norm=kwargs.pop('norm') #not color values are provided, remove norm parameter

AssertionError:无报错信息显现,不知道该怎么改

Starlitnightly commented 1 month ago

You can try PyComplexHeatmap==1.6.3

Starlitnightly commented 1 month ago

I have added version auto identification in 1.6.6

WeiQin2001 commented 1 month ago

无法下载这个版本 其他版本是否也可以?

魏钦

@. | ---- Replied Message ---- | From | Zehua @.> | | Date | 8/29/2024 13:35 | | To | @.> | | Cc | @.> , @.***> | | Subject | Re: [Starlitnightly/omicverse] ov.pl.cpdb_heatmap function error (Issue #136) |

You can try PyComplexHeatmap==1.6.3

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

WeiQin2001 commented 1 month ago

I download the PyComplexHeatmap==1.6.6, but the error is still existing.

魏钦

@. | ---- Replied Message ---- | From | Zehua @.> | | Date | 8/29/2024 13:35 | | To | @.> | | Cc | @.> , @.***> | | Subject | Re: [Starlitnightly/omicverse] ov.pl.cpdb_heatmap function error (Issue #136) |

You can try PyComplexHeatmap==1.6.3

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Starlitnightly commented 1 month ago

你将omicverse更新到1.6.6可以解决该问题,更新需要从git安装,具体见安装教程末尾

WeiQin2001 commented 1 month ago

你将omicverse更新到1.6.6可以解决该问题,更新需要从git安装,具体见安装教程末尾

我git克隆了,然后更新了最新的1.66版本的omicverse,pycomplexheatmap是1.7.6版本的,还是会出现这个问题,并没有解决。。。

WeiQin2001 commented 1 month ago

我重新创立了一个新环境,并克隆了nightly版本的,最后运行成功啦~ 谢谢~