YosefLab / Compass

In-Silico Modeling of Metabolic Heterogeneity using Single-Cell Transcriptomes
BSD 3-Clause "New" or "Revised" License
93 stars 25 forks source link

TypeError: alpha must be a float or None when Figure 2E replication #75

Open Roger-GOAT opened 2 years ago

Roger-GOAT commented 2 years ago

Thank you for the great software!
When I replicated 2E, it showed an error as follows. Other pictures were good. Would the team give some tips?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-57-f357a74f75d3> in <module>
      6 color = data['cohens_d'].map(lambda x: 'r' if x >= 0 else 'b')
      7 alpha = data['adjusted_pval'].map(lambda x: 1.0 if x < 0.1 else 0.25)
----> 8 axs.scatter(data['cohens_d'], data['subsystem'], c=color, alpha=alpha)
      9 axs.set_xlabel("Cohen's d")

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1445     def inner(ax, *args, data=None, **kwargs):
   1446         if data is None:
-> 1447             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1448 
   1449         bound = new_sig.bind(ax, *args, **kwargs)

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, **kwargs)
   4493                 offsets=offsets,
   4494                 transOffset=kwargs.pop('transform', self.transData),
-> 4495                 alpha=alpha
   4496                 )
   4497         collection.set_transform(mtransforms.IdentityTransform())

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/collections.py in __init__(self, paths, sizes, **kwargs)
    951         """
    952 
--> 953         super().__init__(**kwargs)
    954         self.set_paths(paths)
    955         self.set_sizes(sizes)

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
    211 
    212         self._path_effects = None
--> 213         self.update(kwargs)
    214         self._paths = None
    215 

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/artist.py in update(self, props)
    996                         raise AttributeError(f"{type(self).__name__!r} object "
    997                                              f"has no property {k!r}")
--> 998                     ret.append(func(v))
    999         if ret:
   1000             self.pchanged()

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/collections.py in set_alpha(self, alpha)
    832     def set_alpha(self, alpha):
    833         # docstring inherited
--> 834         super().set_alpha(alpha)
    835         self._update_dict['array'] = True
    836         self._set_facecolor(self._original_facecolor)

~/miniconda3/envs/compass/lib/python3.6/site-packages/matplotlib/artist.py in set_alpha(self, alpha)
    928         """
    929         if alpha is not None and not isinstance(alpha, Number):
--> 930             raise TypeError('alpha must be a float or None')
    931         self._alpha = alpha
    932         self.pchanged()

TypeError: alpha must be a float or None
qiuju-Zhang commented 1 year ago

I meet the same error, do you have find a solution?

qiuju-Zhang commented 1 year ago

I found the cause of this error! actually you should set parameter "s=alpha" instead of "alpha=alpha", and you will get the same plot as the tutorial