sc.pl.paga_compare fails when color is different than groups parameter of sc.tl.paga
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
When I run the following code:
import scanpy as sc
sc.set_figure_params(dpi=70)
adata = sc.datasets.paul15()
sc.pp.neighbors(adata)
sc.tl.umap(adata)
sc.tl.leiden(adata)
sc.tl.paga(adata, groups='paul15_clusters')
print(adata.uns['paga'].keys())
sc.pl.paga_compare(adata, color='leiden')
It fails with the following exception:
KeyError Traceback (most recent call last)
<ipython-input-1-5ec08bc29df7> in <module>
7 sc.tl.leiden(adata)
8 sc.tl.paga(adata, groups='paul15_clusters')
----> 9 sc.pl.paga_compare(adata, color='leiden')
10 adata.uns['paga'].keys()
~/.anaconda3/lib/python3.7/site-packages/scanpy/plotting/_tools/paga.py in paga_compare(adata, basis, edges, color, alpha, groups, components, projection, legend_loc, legend_fontsize, legend_fontweight, color_map, palette, frameon, size, title, right_margin, left_margin, show, save, title_graph, groups_graph, **paga_graph_params)
108 paga_graph_params['pos'] = utils._tmp_cluster_pos
109 else:
--> 110 paga_graph_params['pos'] = adata.uns['paga']['pos']
111 xlim, ylim = axs[0].get_xlim(), axs[0].get_ylim()
112 axs[1].set_xlim(xlim)
KeyError: 'pos'
and it prints:
dict_keys(['connectivities', 'connectivities_tree', 'groups'])
@falexwolf might have broken this with https://github.com/theislab/scanpy/commit/504b87e57327be8824d0697b92bac30fd86f0a82 :) but I didn't fully debug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in scanpy/plotting/_tools/paga.py at paga_compare and compare its handling of the groups passed to sc.tl.paga with the color passed to sc.pl.paga_compare. Reproduce the example using the paul15 dataset and inspect how the PAGA position is generated; done means the example no longer raises KeyError when color differs from groups.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- bioinformatics, data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100