Repository navigation
Labels
Needs info❔More information needed
Description
Hi,
I run scanpy in Python 3.7, matplotlib=3.1.1 - sc.pl.paga_path gives me the following error(s).
import scanpy as sc
adata = sc.datasets.paul15()
sc.pp.pca(adata)
sc.pp.neighbors(adata)
sc.tl.dpt(adata)
sc.tl.paga(adata, groups='paul15_clusters')
sc.pl.paga_path(adata, nodes=['1Ery'], keys=['Gata2', 'Btg2', 'Btg1'])---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-a9471349c389> in <module>
----> 1 sc.pl.paga_path(adata, nodes=['1Ery'], keys=['Gata2', 'Btg2', 'Btg1'])
~/Documents/Python/scanpy/scanpy/plotting/_tools/paga.py in paga_path(adata, nodes, keys, use_raw, annotations, color_map, color_maps_annotations, palette_groups, n_avg, groups_key, xlim, title, left_margin, ytick_fontsize, title_fontsize, show_node_names, show_yticks, show_colorbar, legend_fontsize, legend_fontweight, normalize_to_zero_one, as_heatmap, return_data, show, save, ax)
1057 if as_heatmap:
1058 img = ax.imshow(
-> 1059 X, aspect='auto', interpolation='nearest', cmap=color_map
1060 )
1061 if show_yticks:
~/anaconda3/lib/python3.7/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
1599 def inner(ax, *args, data=None, **kwargs):
1600 if data is None:
-> 1601 return func(ax, *map(sanitize_sequence, args), **kwargs)
1602
1603 bound = new_sig.bind(ax, *args, **kwargs)
~/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
--> 369 return func(*args, **kwargs)
370
371 return wrapper
~/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
--> 369 return func(*args, **kwargs)
370
371 return wrapper
~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5669 resample=resample, **kwargs)
5670
-> 5671 im.set_data(X)
5672 im.set_alpha(alpha)
5673 if im.get_clip_path() is None:
~/anaconda3/lib/python3.7/site-packages/matplotlib/image.py in set_data(self, A)
688 or self._A.ndim == 3 and self._A.shape[-1] in [3, 4]):
689 raise TypeError("Invalid shape {} for image data"
--> 690 .format(self._A.shape))
691
692 if self._A.ndim == 3:
TypeError: Invalid shape (3, 43, 1) for image dataIf I convert the adata.X to sparse matrix format, I have the following error:
adata.X = sci.sparse.csr_matrix(adata.X)
sc.pl.paga_path(adata, nodes=['1Ery'], keys=['Gata2', 'Btg2', 'Btg1'])---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-29-a9471349c389> in <module>
----> 1 sc.pl.paga_path(adata, nodes=['1Ery'], keys=['Gata2', 'Btg2', 'Btg1'])
~/Documents/Python/scanpy/scanpy/plotting/_tools/paga.py in paga_path(adata, nodes, keys, use_raw, annotations, color_map, color_maps_annotations, palette_groups, n_avg, groups_key, xlim, title, left_margin, ytick_fontsize, title_fontsize, show_node_names, show_yticks, show_colorbar, legend_fontsize, legend_fontweight, normalize_to_zero_one, as_heatmap, return_data, show, save, ax)
1057 if as_heatmap:
1058 img = ax.imshow(
-> 1059 X, aspect='auto', interpolation='nearest', cmap=color_map
1060 )
1061 if show_yticks:
~/anaconda3/lib/python3.7/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
1599 def inner(ax, *args, data=None, **kwargs):
1600 if data is None:
-> 1601 return func(ax, *map(sanitize_sequence, args), **kwargs)
1602
1603 bound = new_sig.bind(ax, *args, **kwargs)
~/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
--> 369 return func(*args, **kwargs)
370
371 return wrapper
~/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
367 f"%(removal)s. If any parameter follows {name!r}, they "
368 f"should be pass as keyword, not positionally.")
--> 369 return func(*args, **kwargs)
370
371 return wrapper
~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5669 resample=resample, **kwargs)
5670
-> 5671 im.set_data(X)
5672 im.set_alpha(alpha)
5673 if im.get_clip_path() is None:
~/anaconda3/lib/python3.7/site-packages/matplotlib/image.py in set_data(self, A)
683 not np.can_cast(self._A.dtype, float, "same_kind")):
684 raise TypeError("Image data of dtype {} cannot be converted to "
--> 685 "float".format(self._A.dtype))
686
687 if not (self._A.ndim == 2
TypeError: Image data of dtype object cannot be converted to floatPlotting a heatmap with sc.pl.heatmap works.
Versions:
scanpy==1.4.5.dev137+ge46f89b anndata==0.6.22.post2.dev73+g00b4b91 umap==0.3.8 numpy==1.17.3 scipy==1.2.1 pandas==0.25.2 scikit-learn==0.20.3 statsmodels==0.10.1 python-igraph==0.7.1 louvain==0.6.1
Reacted by Chris Rands and Tokuwa Kanno
Metadata
Metadata
Assignees
Labels
Needs info❔More information needed
Activity
chris-rands commentedon Feb 5, 2020
+1, I still have the same issue (the 2nd traceback)- did you find a solution?
chris-rands commentedon Feb 7, 2020
I've found a workaround, when I downgrade to
anndata=0.6.22.post1(still withscanpy==1.4.5.post2), it generates an output withpaga_pathbut also this warning:tkkanno commentedon Feb 12, 2020
+1 issue found with scanpy <Version('1.4.5.post3')>
flying-sheep commentedon Feb 14, 2020
Should be fixed in #1047, please check
mbuttner commentedon Feb 14, 2020
Hi,
I tested your fix and it works!
BTW:
matplotlib==3.1.3flying-sheep commentedon Feb 14, 2020
Cool! Can you also try to run the test that fails in the PR please?
Should be
PYTHONPATH=. pytest scanpy/tests/test_plotting.py::test_paga_pathI have no idea why it does that, as it works for me. If it fails for you, please attach the failed-diff image and the corresponding plot image in a comment here (they’re in
scanpy/tests/figures)mbuttner commentedon Feb 14, 2020
Ok, I ran the test and was successful.
flying-sheep commentedon Feb 15, 2020
Damn … it’s going to be hard to find out why the test fails on Travis then, and I don’t feel comfortable not adding a test. Do we have an Amazon web service (AWS) subscription at ICB that we could use to upload failed image tests?
mbuttner commentedon Feb 17, 2020
flying-sheep commentedon Feb 18, 2020
OK, TODO: check resources with https://calculator.s3.amazonaws.com/index.html and report back to him
esrice commentedon Apr 24, 2020
Getting the same bug. What's the status on merging this fix into a release? Thanks!
mbuttner commentedon Apr 24, 2020
I have a temporary solution, where I created a new conda environment and checked out the scanpy branch with the fix (https://github.com/theislab/scanpy/tree/fix-paga).
esrice commentedon Apr 24, 2020
thanks!
flying-sheep commentedon May 1, 2020
Can someone at ICB make the S3 bucket happen and give me the login creds? Then I can merge this.
lucygarner commentedon Oct 30, 2020
I am also getting a TypeError when I run the following code:
sc.pl.paga_path(adata, nodes = [0, 5, 1], keys = ['IFNG', 'GZMB'], show = True)What is the current solution to this issue?
Many thanks,
Lucy
giovp commentedon Nov 2, 2020
@flying-sheep could you explain again what you need from ICB? Sorry not sure I understand. Thank you!
giovp commentedon Feb 10, 2021
@lc822 could you post a reproducible example? maren seems to have solved it so it could be something else.
mbuttner commentedon Feb 12, 2021
I hve to clarify: I tried out the fix provided above from @flying-sheep and it does the job for me, but the error persists on the
masterbranch.giovp commentedon Feb 12, 2021
I just tried again with the reprex above and it works for me
I'm on a separate branch but it's on par with current master
mbuttner commentedon Feb 12, 2021
I copied your code to a google colabs instance and ran into a Type Error similar to the one above:
https://colab.research.google.com/drive/1LYxOAuNqaJHGfRjNjyluUHk9BFsmkWa4?usp=sharing
Error message:
Versions:
giovp commentedon Feb 12, 2021
...ok then let's wait for #1047 to get merged