Skip to content

TypeError: can't multiply sequence by non-int of type 'float' #3

@jiumeng-bit

Description

@jiumeng-bit

当我在运行各种sc.pl.spatial绘图命令,比如sc.pl.spatial(adata, img_key="hires", color=['domain', 'Ground Truth'])时,都会出现以下报错:

TypeError Traceback (most recent call last)
Cell In[36], line 1
----> 1 sc.pl.spatial(adata, img_key="hires", color='domain')

File /home/data/t010541/miniconda3/envs/SOAPy_st2/lib/python3.9/site-packages/scanpy/plotting/_tools/scatterplots.py:1009, in spatial(adata, basis, img, img_key, library_id, crop_coord, alpha_img, bw, size, scale_factor, spot_size, na_color, show, return_fig, save, **kwargs)
1006 cmap_img = None
1007 circle_radius = size * scale_factor * spot_size * 0.5
-> 1009 axs = embedding(
1010 adata,
1011 basis=basis,
1012 scale_factor=scale_factor,
1013 size=circle_radius,
1014 na_color=na_color,
1015 show=False,
1016 save=False,
1017 **kwargs,
1018 )
1019 if not isinstance(axs, list):
1020 axs = [axs]

File /home/data/t010541/miniconda3/envs/SOAPy_st2/lib/python3.9/site-packages/scanpy/plotting/_tools/scatterplots.py:394, in embedding(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, neighbors_key, arrows, arrows_kwds, groups, components, dimensions, layer, projection, scale_factor, color_map, cmap, palette, na_color, na_in_legend, size, frameon, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, colorbar_loc, vmax, vmin, vcenter, norm, add_outline, outline_width, outline_color, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs)
391 # if user did not set alpha, set alpha to 0.7
392 kwargs['alpha'] = 0.7 if alpha is None else alpha
--> 394 cax = scatter(
395 coords[:, 0],
396 coords[:, 1],
397 marker=".",
398 c=color_vector,
399 rasterized=settings._vector_friendly,
400 norm=normalize,
401 **kwargs,
402 )
404 # remove y and x ticks
405 ax.set_yticks([])

File /home/data/t010541/miniconda3/envs/SOAPy_st2/lib/python3.9/site-packages/scanpy/plotting/_utils.py:1109, in circles(x, y, s, ax, marker, c, vmin, vmax, scale_factor, **kwargs)
1106 # You can set facecolor with an array for each patch,
1107 # while you can only set facecolors with a value for all.
1108 if scale_factor != 1.0:
-> 1109 x = x * scale_factor
1110 y = y * scale_factor
1111 zipped = np.broadcast(x, y, s)

TypeError: can't multiply sequence by non-int of type 'float'

我该如何解决?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions