scverse / scverse/scanpy

sc.pl.stacked_violin: issue using imported adata

Open
#318 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

Hi,

I am testing sc.pl.stacked_violin and I had an issue with running it on an AnnData variable that is imported from a h5ad file. I explain.

If I run:

>>> import scanpy.api as sc
>>> adata = sc.datasets.krumsiek11()
>>> sc.pl.stacked_violin(adata, adata.var_names, 'cell_type', use_raw=False, color='blue', show=False)

No problem, but if I run:

>>> import scanpy.api as sc
>>> adata = sc.datasets.krumsiek11()
>>> adata.write('anndata.h5ad')
>>> adata = sc.read_h5ad('anndata.h5ad')
>>> sc.pl.stacked_violin(adata, adata.var_names, 'cell_type', use_raw=False, color='blue', show=False)

then I got the error:

Traceback (most recent call last):
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/miniconda3/envs/scanpy/lib/python3.6/site-packages/scanpy/plotting/anndata.py", line 896, in stacked_violin
    orient='vertical', scale=scale, ax=ax, **kwds)
  File "/miniconda3/envs/scanpy/lib/python3.6/site-packages/seaborn/categorical.py", line 2387, in violinplot
    color, palette, saturation)
  File "/miniconda3/envs/scanpy/lib/python3.6/site-packages/seaborn/categorical.py", line 562, in __init__
    self.establish_variables(x, y, hue, data, orient, order, hue_order)
  File "/miniconda3/envs/scanpy/lib/python3.6/site-packages/seaborn/categorical.py", line 155, in establish_variables
    raise ValueError(err)
ValueError: Could not interpret input 'variable'

I tested it with versions 1.3.1 and 1.3.2, installed with bioconda.

Any idea?

Bérénice

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two examples, especially the h5ad round-trip, then inspect scanpy/plotting/anndata.py around stacked_violin and line 896 where seaborn receives its data. Done means the imported AnnData case completes without the “Could not interpret input 'variable'” error while the in-memory example still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.