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.

Exception: Data must be 1-dimensional from sc.pl.rank_genes_groups_violin

See original GitHub issue

I was using the sc.pl.rank_genes_groups_violinfunction and got the error:

Exception                                 Traceback (most recent call last)
<ipython-input-195-8f87448845a3> in <module>
      1 sc.tl.rank_genes_groups(adata, 'leiden', groups=['0'], reference='1', method='wilcoxon')
----> 2 sc.pl.rank_genes_groups_violin(adata, groups='0', n_genes=1)

~/miniconda3/envs/scrna/lib/python3.7/site-packages/scanpy/plotting/_tools/__init__.py in rank_genes_groups_violin(adata, groups, n_genes, gene_names, gene_symbols, use_raw, key, split, scale, strip, jitter, size, ax, show, save)
    727             if issparse(X_col): X_col = X_col.toarray().flatten()
    728             new_gene_names.append(g)
--> 729             df[g] = X_col
    730         df['hue'] = adata.obs[groups_key].astype(str).values
    731         if reference == 'rest':

~/miniconda3/envs/scrna/lib/python3.7/site-packages/pandas/core/frame.py in __setitem__(self, key, value)
   2936         else:
   2937             # set column
-> 2938             self._set_item(key, value)
   2939 
   2940     def _setitem_slice(self, key, value):

~/miniconda3/envs/scrna/lib/python3.7/site-packages/pandas/core/frame.py in _set_item(self, key, value)
   2997         """
   2998 
-> 2999         self._ensure_valid_index(value)
   3000         value = self._sanitize_column(key, value)
   3001         NDFrame._set_item(self, key, value)

~/miniconda3/envs/scrna/lib/python3.7/site-packages/pandas/core/frame.py in _ensure_valid_index(self, value)
   3052         if not len(self.index) and is_list_like(value) and len(value):
   3053             try:
-> 3054                 value = Series(value)
   3055             except (ValueError, NotImplementedError, TypeError):
   3056                 raise ValueError(

~/miniconda3/envs/scrna/lib/python3.7/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    303                     data = data.copy()
    304             else:
--> 305                 data = sanitize_array(data, index, dtype, copy, raise_cast_failure=True)
    306 
    307                 data = SingleBlockManager(data, index, fastpath=True)

~/miniconda3/envs/scrna/lib/python3.7/site-packages/pandas/core/construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure)
    480     elif subarr.ndim > 1:
    481         if isinstance(data, np.ndarray):
--> 482             raise Exception("Data must be 1-dimensional")
    483         else:
    484             subarr = com.asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional
...
...

Versions:

scanpy==1.4.6 anndata==0.7.1 umap==0.4.2 numpy==1.18.3 scipy==1.4.1 pandas==1.0.3 scikit-learn==0.22.2.post1 statsmodels==0.11.1 python-igraph==0.8.2 louvain==0.6.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mvdbeekcommented, Mar 16, 2021
0reactions
mvdbeekcommented, Apr 25, 2021

If it passes the tests I’m sure it works, feel free to pull it in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception: Data must be 1-dimensional from sc.pl ... - GitHub
I was using the sc.pl.rank_genes_groups_violinfunction and got the error: Exception Traceback (most recent call last) in 1 ...
Read more >
Python Exception: Data must be 1-dimensional - Stack Overflow
var is a number which I pass in the findMaxEval function in minimize , initial value is 0.5. Further, mpPDF and fitKDE are...
Read more >
Exception: Data must be 1-dimensional appears when trying ...
Python tells you that the data you give for the column "predictions" is not 1-dimensional (i.e. it's not a flat list).
Read more >
How to Fix: Data must be 1-dimensional - TidyPython
You might encounter the following error when trying to convert Numpy arrays to a pandas dataframe. Exception: Data must be 1-dimensional ...
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