Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/scanpy/plotting/legacy/_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ def rank_genes_groups( # noqa: PLR0912, PLR0913, PLR0915

reference = str(adata.uns[key]["params"]["reference"])
group_names = adata.uns[key]["names"].dtype.names if groups is None else groups
if isinstance(group_names, str):
group_names = [group_names]
# one panel for each group
# set up the figure
n_panels_x = min(n_panels_per_row, len(group_names))
Expand Down Expand Up @@ -544,6 +546,8 @@ def _rank_genes_groups_plot( # noqa: PLR0912, PLR0913, PLR0915
if groupby is None:
groupby = str(adata.uns[key]["params"]["groupby"])
group_names = adata.uns[key]["names"].dtype.names if groups is None else groups
if isinstance(group_names, str):
group_names = [group_names]

if var_names is not None:
if isinstance(var_names, Mapping):
Expand Down
23 changes: 23 additions & 0 deletions tests/plotting/legacy/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,29 @@ def test_rank_genes_group_axes(plot_cmp):
plt.close()


@pytest.mark.parametrize(
("plot_func", "kwargs"),
[
pytest.param(sc.pl.rank_genes_groups, {}, id="rank_genes_groups"),
pytest.param(
sc.pl.rank_genes_groups_dotplot,
{"dendrogram": False},
id="shared-rank-genes-groups-plots",
),
],
)
def test_rank_genes_groups_single_group_string(
plot_func: Callable[..., Any], kwargs: dict[str, Any]
) -> None:
adata = pbmc68k_reduced()
sc.tl.rank_genes_groups(adata, "bulk_labels")

result = plot_func(adata, groups="Dendritic", n_genes=2, show=False, **kwargs)

assert result is not None
plt.close("all")


@pytest.fixture(scope="session")
def gene_symbols_adatas_session() -> tuple[AnnData, AnnData]:
"""Create two anndata objects which are equivalent except for var_names.
Expand Down
Loading