Remove `paga_compare` groups argument?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
Example of potentially bad groups argument (copied from PR):
For example, on current master passing any value for groups to sc.pl.paga_compare causes an error (since the "wrong" number of medians is calculated). Now it works, but it's a bit unclear if it's doing the right thing:
import scanpy as sc
adata = sc.datasets.pbmc3k_processed()
sc.tl.paga(adata, "louvain")
sc.pl.paga_compare(adata, groups=list(adata.obs["louvain"].cat.categories[:4])
On master:
traceback
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-13-e5188d753713> in <module>
1 adata = sc.datasets.pbmc3k_processed()
2 sc.tl.paga(adata, "louvain")
----> 3 sc.pl.paga_compare(adata, groups=list(adata.obs["louvain"].cat.categories[:4]))
~/github/scanpy/scanpy/plotting/_tools/paga.py in paga_compare(adata, basis, edges, color, alpha, groups, components, projection, legend_loc, legend_fontsize, legend_fontweight, legend_fontoutline, color_map, palette, frameon, size, title, right_margin, left_margin, show, save, title_graph, groups_graph, **paga_graph_params)
135 if legend_fontoutline is not None:
136 paga_graph_params['fontoutline'] = legend_fontoutline
--> 137 paga(
138 adata,
139 ax=axs[1],
~/github/scanpy/scanpy/plotting/_tools/paga.py in paga(adata, threshold, color, layout, layout_kwds, init_pos, root, labels, single_component, solid_edges, dashed_edges, transitions, fontsize, fontweight, fontoutline, text_kwds, node_size_scale, node_size_power, edge_width_scale, min_edge_width, max_edge_width, arrowsize, title, left_margin, random_state, pos, normalize_to_color, cmap, cax, colorbar, cb_kwds, frameon, add_pos, export_to_gexf, use_raw, colors, groups, plot, show, save, ax)
552 if title[icolor] is not None:
553 axs[icolor].set_title(title[icolor])
--> 554 sct = _paga_graph(
555 adata,
556 axs[icolor],
~/github/scanpy/scanpy/plotting/_tools/paga.py in _paga_graph(adata, ax, solid_edges, dashed_edges, adjacency_solid, adjacency_dashed, transitions, threshold, root, colors, labels, fontsize, fontweight, fontoutline, text_kwds, node_size_scale, node_size_power, edge_width_scale, normalize_to_color, title, pos, cmap, frameon, min_edge_width, max_edge_width, export_to_gexf, colorbar, use_raw, cb_kwds, single_component, arrowsize)
820 with warnings.catch_warnings():
821 warnings.simplefilter("ignore")
--> 822 nx.draw_networkx_edges(
823 nx_g_solid, pos, ax=ax, width=widths, edge_color='black'
824 )
/usr/local/lib/python3.8/site-packages/networkx/drawing/nx_pylab.py in draw_networkx_edges(G, pos, edgelist, width, edge_color, style, alpha, arrowstyle, arrowsize, edge_cmap, edge_vmin, edge_vmax, ax, arrows, label, node_size, nodelist, node_shape, connectionstyle, min_source_margin, min_target_margin)
654
655 # set edge positions
--> 656 edge_pos = np.asarray([(pos[e[0]], pos[e[1]]) for e in edgelist])
657
658 # Check if edge_color is an array of floats and map to edge_cmap.
/usr/local/lib/python3.8/site-packages/networkx/drawing/nx_pylab.py in <listcomp>(.0)
654
655 # set edge positions
--> 656 edge_pos = np.asarray([(pos[e[0]], pos[e[1]]) for e in edgelist])
657
658 # Check if edge_color is an array of floats and map to edge_cmap.
KeyError: 5
In this PR:

Why is groups a handled argument if it doesn't do anything with the paga representation? Should it be an available argument at all? What was the intent of the argument when it was added?
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, paga, and _paga_graph, then reproduce the supplied PBMC example with a groups value. Determine the intended behavior of groups and resolve the resulting KeyError by either clarifying supported behavior or removing the argument; the example should complete without the reported failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100