Skip to content

Layers to scatter - #555

Merged
falexwolf merged 2 commits into
scverse:masterfrom
fidelram:layers_to_scatter
Mar 29, 2019
Merged

falexwolf merged 2 commits into
scverse:masterfrom
fidelram:layers_to_scatter

Conversation

@fidelram

Copy link
Copy Markdown
Collaborator

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

@gokceneraslan

Copy link
Copy Markdown
Contributor

This is awesome!

@falexwolf

Copy link
Copy Markdown
Member

Fantastic! 😄

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

Xparx commented Apr 15, 2019

Copy link
Copy Markdown

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?

@fidelram

Copy link
Copy Markdown
Collaborator Author

I can replicate the problem. I will look into it

awnimo pushed a commit to dpeerlab/scanpy that referenced this pull request Dec 17, 2019
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

Successfully merging this pull request may close these issues.

4 participants