question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sc.pl.scatter for var

See original GitHub issue

I get the following error when trying to use sc.pl.scatter to plot gene expression, with use_raw=False. I am using sc.pl.scatter instead of sc.pl.umap, .tsne, etc., because of the need to use custom basis names.

  File "/opt/Python/3.6.5/lib/python3.6/site-packages/scanpy/plotting/_anndata.py", line 118, in scatter
    ax=ax)
  File "/opt/Python/3.6.5/lib/python3.6/site-packages/scanpy/plotting/_anndata.py", line 390, in _scatter_obs
    c = adata.raw.obs_vector(key, layer=layers[2])
TypeError: obs_vector() got an unexpected keyword argument 'layer'

The following snippet is copied from _scatter_obs() in /scanpy/plotting/_anndata.py

        # coloring according to gene expression
        elif (use_raw
              and adata.raw is not None
              and key in adata.raw.var_names):
            c = adata.raw.obs_vector(key)
        elif key in adata.var_names:
            c = adata.raw.obs_vector(key, layer=layers[2])

Should line 390 be c = adata.obs_vector(key, layer=layers[2]) since it is handling the case when use_raw==False and adata.raw.obs_vector does not take layer as argument.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
fidelramcommented, Aug 2, 2019

@coh-racng I would like to add that for your specific intention the best way is to load the plot_scatter function that accepts basis as parameter and works well with layers.

The code should be:

from scanpy._plotting.scatterplots import plot_scatter`
plot_scatter(adata, basis='<name>'....)

@ivirshup, @falexwolf I think we should add plot_scatter to the API maybe renaming it plot_embedding to help users like @coh-racng. Currently we have two different ways to make scatter plots: One for embeddings (plot_scatter) and other more generic for obs and vars (sc.pl.scatter) that accepts x and y parameters.

1reaction
ivirshupcommented, Aug 2, 2019

Thanks for the bug report! That sounds totally right, would you mind submitting a PR to fix that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

scanpy.pl.scatter — Scanpy 1.9.1 documentation
Scatter plot along observations or variables axes. Color the plot using annotations of observations ( .obs ), variables ( .var ) or expression...
Read more >
sc.pl.scatter for var · Issue #762 · scverse/scanpy - GitHub
I get the following error when trying to use sc.pl.scatter to plot gene expression, with use_raw=False. I am using sc.pl.scatter instead of sc....
Read more >
graph twoway scatter - Title Syntax
graph twoway scatter — Twoway scatterplots marker label options. Description mlabel(varlist) specify marker variables mlabposition(clockposlist).
Read more >
seaborn.scatterplot — seaborn 0.12.1 documentation - PyData |
Grouping variable that will produce points with different sizes. Can be either categorical or numeric, although size mapping will behave differently in latter ......
Read more >
pbmc10k - Pitt CRC
View of AnnData object with n_obs × n_vars = 11692 × 33538 var: 'gene_ids', ... sc.pl.scatter(adata, x='n_counts', y='percent_mito') sc.pl.scatter(adata, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found