Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError while using ov.utils.plot_paga #251

Open
TamiaChin opened this issue Feb 4, 2025 · 0 comments
Open

AttributeError while using ov.utils.plot_paga #251

TamiaChin opened this issue Feb 4, 2025 · 0 comments

Comments

@TamiaChin
Copy link

Great tool !

I came across AttributeError while trying to demonstrate the PAGA LTNN-graph on Umap. However, if I do not set parameter basis = "Umap", a trajectory can be showed with nodes and lines.

Below please find my code.

ov.utils.plot_paga(
    adata, 
    size=50, 
    # basis='umap',
    alpha=0.1, 
    title='PAGA LTNN-graph', 
    min_edge_width=2,
    node_size_scale=1.5, 
    show=False, 
    # legend_loc='on data' 
)

Image

while

ov.utils.plot_paga(
    adata, 
    size=50, 
    basis='umap',
    alpha=0.1, 
    title='PAGA LTNN-graph', 
    min_edge_width=2,
    node_size_scale=1.5, 
    show=False, 
    # legend_loc='on data' 
)

An error occurred

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[14], line 1
----> 1 ov.utils.plot_paga(
      2     adata, 
      3     size=50, 
      4     basis='umap',
      5     alpha=0.1,  
      6     title='PAGA LTNN-graph',
      7     min_edge_width=2,  
      8     node_size_scale=1.5, 
      9     show=False, 
     10     legend_loc='on data' 
     11 )

File /data/person/lab/qinty/.conda/envs/pysc/lib/python3.9/site-packages/omicverse/utils/_paga.py:445, in plot_paga(adata, basis, vkey, color, layer, title, threshold, layout, layout_kwds, init_pos, root, labels, single_component, dashed_edges, solid_edges, transitions, node_size_scale, node_size_power, edge_width_scale, min_edge_width, max_edge_width, arrowsize, random_state, pos, node_colors, normalize_to_color, cmap, cax, cb_kwds, add_pos, export_to_gexf, plot, use_raw, size, groups, components, figsize, dpi, show, save, ax, ncols, scatter_flag, **kwargs)
    442     basis = None
    444 import scvelo as scv
--> 445 return scv.pl.paga(adata,
    446 basis=basis,
    447 vkey=vkey,
    448 color=color,
    449 layer=layer,
    450 title=title,
    451 threshold=threshold,
    452 layout=layout,
    453 layout_kwds=layout_kwds,
    454 init_pos=init_pos,
    455 root=root,
    456 labels=labels,
    457 single_component=single_component,
    458 dashed_edges=dashed_edges,
    459 solid_edges=solid_edges,
    460 transitions=transitions,
    461 node_size_scale=node_size_scale,
    462 node_size_power=node_size_power,
    463 edge_width_scale=edge_width_scale,
    464 min_edge_width=min_edge_width,
    465 max_edge_width=max_edge_width,
    466 arrowsize=arrowsize,
    467 random_state=random_state,
    468 pos=pos,
    469 node_colors=node_colors,
    470 normalize_to_color=normalize_to_color,
    471 cmap=cmap,
    472 cax=cax,
    473 cb_kwds=cb_kwds,
    474 add_pos=add_pos,
    475 export_to_gexf=export_to_gexf,
    476 plot=plot,
    477 use_raw=use_raw,
    478 size=size,
    479 groups=groups,
    480 components=components,
    481 figsize=figsize,
    482 dpi=dpi,
    483 show=show,
    484 save=save,
    485 ax=ax,
    486 ncols=ncols,
    487 scatter_flag=scatter_flag,
    488 **kwargs,)

File /data/person/lab/qinty/.conda/envs/pysc/lib/python3.9/site-packages/scvelo/plotting/paga.py:353, in paga(adata, basis, vkey, color, layer, title, threshold, layout, layout_kwds, init_pos, root, labels, single_component, dashed_edges, solid_edges, transitions, node_size_scale, node_size_power, edge_width_scale, min_edge_width, max_edge_width, arrowsize, random_state, pos, node_colors, normalize_to_color, cmap, cax, cb_kwds, add_pos, export_to_gexf, plot, use_raw, size, groups, components, figsize, dpi, show, save, ax, ncols, scatter_flag, **kwargs)
    351     kwargs.update(dict(basis=basis, layer=layer, color=paga_groups, size=size))
    352     kwargs.update(dict(vkey=vkey, title=title, ax=ax, show=False, save=None))
--> 353     ax = scatter(adata, x=x, y=y, zorder=0, **kwargs)
    354 text_kwds = {"zorder": 1000, "alpha": legend_loc == "on data"}
    355 _paga(adata, ax=ax, show=False, text_kwds=text_kwds, **paga_kwargs)

File /data/person/lab/qinty/.conda/envs/pysc/lib/python3.9/site-packages/scvelo/plotting/scatter.py:668, in scatter(adata, basis, x, y, vkey, color, use_raw, layer, color_map, colorbar, palette, size, alpha, linewidth, linecolor, perc, groups, sort_order, components, projection, legend_loc, legend_loc_lines, legend_fontsize, legend_fontweight, legend_fontoutline, legend_align_text, xlabel, ylabel, title, fontsize, figsize, xlim, ylim, add_density, add_assignments, add_linfit, add_polyfit, add_rug, add_text, add_text_pos, add_margin, add_outline, outline_width, outline_color, n_convolve, smooth, normalize_data, rescale_color, color_gradients, dpi, frameon, zorder, ncols, nrows, wspace, hspace, show, save, ax, **kwargs)
    666     if not (add_outline is None or g_bool is None):
    667         groups = add_outline
--> 668     set_legend(
    669         adata,
    670         ax,
    671         color,
    672         legend_loc,
    673         scatter_array,
    674         legend_fontweight,
    675         legend_fontsize,
    676         legend_fontoutline,
    677         legend_align_text,
    678         groups,
    679     )
    680 if add_density:
    681     plot_density(x, y, add_density, ax=ax)

File /data/person/lab/qinty/.conda/envs/pysc/lib/python3.9/site-packages/scvelo/plotting/utils.py:555, in set_legend(adata, ax, value_to_plot, legend_loc, scatter_array, legend_fontweight, legend_fontsize, legend_fontoutline, legend_align_text, groups)
    553     legend_fontoutline = 1
    554 obs_vals = adata.obs[value_to_plot]
--> 555 obs_vals.cat.categories = obs_vals.cat.categories.astype(str)
    556 color_keys = adata.uns[f"{value_to_plot}_colors"]
    557 if isinstance(color_keys, dict):

File /data/person/lab/qinty/.conda/envs/pysc/lib/python3.9/site-packages/pandas/core/base.py:178, in NoNewAttributesMixin.__setattr__(self, key, value)
    172 if getattr(self, "__frozen", False) and not (
    173     key == "_cache"
    174     or key in type(self).__dict__
    175     or getattr(self, key, None) is not None
    176 ):
    177     raise AttributeError(f"You cannot add any new attribute '{key}'")
--> 178 object.__setattr__(self, key, value)

File /data/person/lab/qinty/.conda/envs/pysc/lib/python3.9/site-packages/pandas/core/accessor.py:99, in PandasDelegate._add_delegate_accessors.<locals>._create_delegator_property.<locals>._setter(self, new_values)
     98 def _setter(self, new_values):
---> 99     return self._delegate_property_set(name, new_values)

File /data/person/lab/qinty/.conda/envs/pysc/lib/python3.9/site-packages/pandas/core/arrays/categorical.py:2915, in CategoricalAccessor._delegate_property_set(self, name, new_values)
   2914 def _delegate_property_set(self, name: str, new_values):  # type: ignore[override]
-> 2915     return setattr(self._parent, name, new_values)

AttributeError: can't set attribute

Thanks for helping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant