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

an error in failing to save stream figures aftering installing some packages like "mpi4py petsc petsc4py" #1236

Open
Shiywa opened this issue Apr 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Shiywa
Copy link

Shiywa commented Apr 14, 2024

Hi, recently I met an error in saving stream figures. When I want to used CellRank, I installed three packages including mpi4py petsc petsc4py. then When I want to use

scv.pl.velocity_embedding_stream(adata, basis="harmony_umap", color="develop_anno",palette=color_dict,
                                save= "scvelo_Mock and Ctrl Macro scVelo lineage.png",figsize=(8,8),
                                 legend_loc= "right margin")

I got the error. Firstly, the cluster labels can't be displayed. Then the figure can't be saved by the function.

# paste your code here, if applicable
scv.pl.velocity_embedding_stream(adata, basis="harmony_umap", color="develop_anno",palette=color_dict,
                                save= "scvelo_Mock and Ctrl Macro scVelo lineage.png",figsize=(8,8),
                                 legend_loc= "right margin")
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[23], line 2 1 #scv.pl.velocity_embedding_stream(adata, basis="umap", color="anno2",palette=color_dict) ----> 2 scv.pl.velocity_embedding_stream(adata, basis="harmony_umap", color="develop_anno",palette=color_dict, 3 save= "scvelo_Mock and Ctrl Macro scVelo lineage.png",figsize=(8,8), 4 legend_loc= "right margin")

File ~/biosoft/miniconda3/envs/SCP_env/lib/python3.8/site-packages/scvelo/plotting/velocity_embedding_stream.py:252, in velocity_embedding_stream(adata, basis, vkey, density, smooth, min_mass, cutoff_perc, arrow_color, arrow_size, arrow_style, max_length, integration_direction, linewidth, n_neighbors, recompute, color, use_raw, layer, color_map, colorbar, palette, size, alpha, perc, X, V, X_grid, V_grid, sort_order, groups, components, legend_loc, legend_fontsize, legend_fontweight, xlabel, ylabel, title, fontsize, figsize, dpi, frameon, show, save, ax, ncols, **kwargs)
249 ax.streamplot(X_grid[0], X_grid[1], V_grid[0], V_grid[1], **stream_kwargs)
251 size = 8 * default_size(adata) if size is None else size
--> 252 ax = scatter(
253 adata,
254 layer=layer,
255 color=color,
256 size=size,
257 title=title,
258 ax=ax,
259 zorder=0,
260 **scatter_kwargs,
261 )
262 if save is True:
263 save = "embedding_stream"

File ~/biosoft/miniconda3/envs/SCP_env/lib/python3.8/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 ~/biosoft/miniconda3/envs/SCP_env/lib/python3.8/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 ~/biosoft/miniconda3/envs/SCP_env/lib/python3.8/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 ~/biosoft/miniconda3/envs/SCP_env/lib/python3.8/site-packages/pandas/core/accessor.py:99, in PandasDelegate._add_delegate_accessors.._create_delegator_property.._setter(self, new_values)
98 def _setter(self, new_values):
---> 99 return self._delegate_property_set(name, new_values)

File ~/biosoft/miniconda3/envs/SCP_env/lib/python3.8/site-packages/pandas/core/arrays/categorical.py:2460, in CategoricalAccessor._delegate_property_set(self, name, new_values)
2459 def _delegate_property_set(self, name, new_values):
-> 2460 return setattr(self._parent, name, new_values)

AttributeError: can't set attribute

@Shiywa Shiywa added the bug Something isn't working label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant