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

Layers to scatter #555

Merged
merged 2 commits into from Mar 29, 2019

Conversation

Projects
None yet
4 participants
@fidelram
Copy link
Collaborator

commented Mar 25, 2019

This PR adds the argument layer to the different scatter plot functions like .pl.umap, pl.tsne etc. This partially addresses #458

@gokceneraslan

This comment has been minimized.

Copy link
Collaborator

commented Mar 26, 2019

This is awesome!

@falexwolf

This comment has been minimized.

Copy link
Member

commented Mar 29, 2019

Fantastic! 😄

@falexwolf falexwolf merged commit a3ce0d5 into theislab:master Mar 29, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Xparx

This comment has been minimized.

Copy link

commented Apr 15, 2019

I noticed a minor bug that if the layer is sparse the plot fails with the following traceback.

TypeErrorTraceback (most recent call last)
<ipython-input-963-f4f784156b06> in <module>
----> 1 import sys, codecs, os, ast;__pyfile = codecs.open('''/tmp/pySnNnI3''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile.close();os.remove('''/tmp/pySnNnI3''');__block = ast.parse(__code, '''/tmp/pySnNnI3''', mode='exec'); __block.body = (__block.body if not isinstance(__block.body[0], ast.If) else __block.body if not isinstance(__block.body[0].test, ast.Name) else __block.body if not __block.body[0].test.id == 'True' else __block.body[0].body) if sys.version_info[0] < 3 else (__block.body if not isinstance(__block.body[0], ast.If) else __block.body if not isinstance(__block.body[0].test, ast.NameConstant) else __block.body if not __block.body[0].test.value is True else __block.body[0].body);__last = __block.body[-1];__isexpr = isinstance(__last,ast.Expr);_ = __block.body.pop() if __isexpr else None;exec(compile(__block, '''/tmp/pySnNnI3''', mode='exec'));eval(compile(ast.Expression(__last.value), '''/tmp/pySnNnI3''', mode='eval')) if __isexpr else None

/tmp/pySnNnI3 in <module>

~/projects/scanpy/scanpy/plotting/_tools/scatterplots.py in umap(adata, **kwargs)
    285     If `show==False` a `matplotlib.Axis` or a list of it.
    286     """
--> 287     return plot_scatter(adata, 'umap', **kwargs)
    288 
    289 

~/projects/scanpy/scanpy/plotting/_tools/scatterplots.py in plot_scatter(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, arrows, arrows_kwds, groups, components, layer, projection, color_map, palette, size, frameon, legend_fontsize, legend_fontweight, legend_loc, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs)
    202                 _data_points[:, 0], _data_points[:, 1],
    203                 marker=".", c=color_vector, rasterized=settings._vector_friendly,
--> 204                 **kwargs,
    205             )
    206 

~/.virtualenvs/intel_default/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1808                         "the Matplotlib list!)" % (label_namer, func.__name__),
   1809                         RuntimeWarning, stacklevel=2)
-> 1810             return func(ax, *args, **kwargs)
   1811 
   1812         inner.__doc__ = _add_data_doc(inner.__doc__,

~/.virtualenvs/intel_default/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, **kwargs)
   4203                 isinstance(c, str) or
   4204                 (isinstance(c, collections.Iterable) and
-> 4205                     len(c) > 0 and
   4206                     isinstance(cbook.safe_first_element(c), str))):
   4207             c_array = None

~/.virtualenvs/intel_default/lib/python3.6/site-packages/scipy/sparse/base.py in __len__(self)
    294     # non-zeros is more important.  For now, raise an exception!
    295     def __len__(self):
--> 296         raise TypeError("sparse matrix length is ambiguous; use getnnz()"
    297                         " or shape[0]")
    298 

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

Is this only on my end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.