aertslab / scenicplus

SCENIC+ is a python package to build gene regulatory networks (GRNs) using combined or separate single-cell gene expression (scRNA-seq) and single-cell chromatin accessibility (scATAC-seq) data.
Other
163 stars 27 forks source link

TypeError in Branched trajectory analysis #315

Closed Umaarasu closed 3 months ago

Umaarasu commented 3 months ago

Hi, I am trying to run branched trajectory analysis. I am struck in this step with this error..Could someone please tell me how to fix this. Thanks!

sc.tl.paga(adata, groups='ACC_pycisTopic_leiden_10_0.6') %matplotlib inline sc.pl.paga(adata, threshold=0.1, color='ACC_pycisTopic_leiden_10_0.6')


TypeError Traceback (most recent call last) Cell In[42], line 4 2 sc.tl.paga(adata, groups='ACC_pycisTopic_leiden_10_0.6') 3 get_ipython().run_line_magic('matplotlib', 'inline') ----> 4 sc.pl.paga(adata, threshold=0.1, color='ACC_pycisTopic_leiden_10_0.6')

File ~/anaconda3/envs/scenicplus/lib/python3.8/site-packages/scanpy/plotting/_tools/paga.py:554, in paga(adata, threshold, color, layout, layout_kwds, init_pos, root, labels, single_component, solid_edges, dashed_edges, transitions, fontsize, fontweight, fontoutline, text_kwds, node_size_scale, node_size_power, edge_width_scale, min_edge_width, max_edge_width, arrowsize, title, left_margin, random_state, pos, normalize_to_color, cmap, cax, colorbar, cb_kwds, frameon, add_pos, export_to_gexf, use_raw, colors, groups, plot, show, save, ax) 552 if layout in {'rt', 'rt_circular', 'eq_tree'}: 553 adj_tree = adata.uns['paga']['connectivities_tree'] --> 554 pos = _compute_pos( 555 adjacency_solid, 556 layout=layout, 557 random_state=random_state, 558 init_pos=init_pos, 559 layout_kwds=layout_kwds, 560 adj_tree=adj_tree, 561 root=root, 562 ) 564 if plot: 565 axs, panel_pos, draw_region_width, figure_width = _utils.setup_axes( 566 ax=ax, 567 panels=colors, 568 colorbars=colorbars, 569 )

File ~/anaconda3/envs/scenicplus/lib/python3.8/site-packages/scanpy/plotting/_tools/paga.py:244, in _compute_pos(adjacency_solid, layout, random_state, init_pos, adj_tree, root, layout_kwds) 241 else: 242 # igraph layouts 243 random.seed(random_state.bytes(8)) --> 244 g = _sc_utils.get_igraph_from_adjacency(adjacency_solid) 245 if 'rt' in layout: 246 g_tree = _sc_utils.get_igraph_from_adjacency(adj_tree)

File ~/anaconda3/envs/scenicplus/lib/python3.8/site-packages/scanpy/_utils/init.py:219, in get_igraph_from_adjacency(adjacency, directed) 217 g.add_edges(list(zip(sources, targets))) 218 try: --> 219 g.es['weight'] = weights 220 except KeyError: 221 pass

File ~/anaconda3/envs/scenicplus/lib/python3.8/site-packages/scipy/sparse/_base.py:345, in spmatrix.len(self) 344 def len(self): --> 345 raise TypeError("sparse matrix length is ambiguous; use getnnz()" 346 " or shape[0]")

TypeError: sparse matrix length is ambiguous; use getnnz() or shape[0].

This is my adata AnnData object with n_obs × n_vars = 1785 × 1374 obs: 'GEX_nCount_RNA', 'GEX_nFeature_RNA', 'GEX_percent.mt', 'GEX_nCount_ATAC', 'GEX_nFeature_ATAC', 'GEX_nCount_SCT', 'GEX_nFeature_SCT', 'GEX_SCT.weight', 'GEX_ATAC.weight', 'GEX_wsnn_res.0.8', 'GEX_seurat_clusters', 'GEX_predicted.id', 'GEX_prediction.score.ASPC', 'GEX_prediction.score.mesothelium', 'GEX_prediction.score.pericyte', 'GEX_prediction.score.adipocyte', 'GEX_prediction.score.macrophage', 'GEX_prediction.score.endothelial', 'GEX_prediction.score.LEC', 'GEX_prediction.score.monocyte', 'GEX_prediction.score.t_cell', 'GEX_prediction.score.dendritic_cell', 'GEX_prediction.score.SMC', 'GEX_prediction.score.b_cell', 'GEX_prediction.score.mast_cell', 'GEX_prediction.score.nk_cell', 'GEX_prediction.score.endometrium', 'GEX_prediction.score.max', 'GEX_nCount_peaks', 'GEX_nFeature_peaks', 'ACC_cisTopic_nr_frag', 'ACC_cisTopic_log_nr_frag', 'ACC_cisTopic_nr_acc', 'ACC_cisTopic_log_nr_acc', 'ACC_sample_id', 'ACC_Cell_type', 'ACC_pycisTopic_leiden_10_0.6' var: 'highly_variable', 'means', 'dispersions', 'dispersions_norm' uns: 'hvg', 'pca', 'neighbors', 'diffmap_evals', 'umap', 'tsne', 'draw_graph', 'ACC_Cell_type_colors', 'paga', 'ACC_Cell_type_sizes', 'ACC_pycisTopic_leiden_10_0.6_sizes', 'ACC_pycisTopic_leiden_10_0.6_colors' obsm: 'X_pca', 'X_diffmap', 'X_umap', 'X_tsne', 'X_draw_graph_fr' varm: 'PCs' obsp: 'distances', 'connectivities'