diff --git a/docs/release-notes/3243.bugfix.md b/docs/release-notes/3243.bugfix.md new file mode 100644 index 0000000000..5aa6063b1e --- /dev/null +++ b/docs/release-notes/3243.bugfix.md @@ -0,0 +1 @@ +Accept `'group'` instead of `'obs'` for `standard_scale` parameter in {func}`~scanpy.pl.stacked_violin` {smaller}`P Angerer` diff --git a/src/scanpy/plotting/_stacked_violin.py b/src/scanpy/plotting/_stacked_violin.py index 862bf76098..f2b4a1696b 100644 --- a/src/scanpy/plotting/_stacked_violin.py +++ b/src/scanpy/plotting/_stacked_violin.py @@ -222,6 +222,10 @@ def __init__( ) if standard_scale == "obs": + standard_scale = "group" + msg = "`standard_scale='obs'` is deprecated, use `standard_scale='group'` instead" + warnings.warn(msg, FutureWarning) + if standard_scale == "group": self.obs_tidy = self.obs_tidy.sub(self.obs_tidy.min(1), axis=0) self.obs_tidy = self.obs_tidy.div(self.obs_tidy.max(1), axis=0).fillna(0) elif standard_scale == "var": @@ -680,7 +684,7 @@ def stacked_violin( gene_symbols: str | None = None, var_group_positions: Sequence[tuple[int, int]] | None = None, var_group_labels: Sequence[str] | None = None, - standard_scale: Literal["var", "obs"] | None = None, + standard_scale: Literal["var", "group"] | None = None, var_group_rotation: float | None = None, layer: str | None = None, stripplot: bool = StackedViolin.DEFAULT_STRIPPLOT, diff --git a/tests/_images/dotplot/expected.png b/tests/_images/dotplot/expected.png index ea54ae3447..9c4b822369 100644 Binary files a/tests/_images/dotplot/expected.png and b/tests/_images/dotplot/expected.png differ diff --git a/tests/_images/dotplot_dict/expected.png b/tests/_images/dotplot_dict/expected.png index ec1df6560c..d805ea94db 100644 Binary files a/tests/_images/dotplot_dict/expected.png and b/tests/_images/dotplot_dict/expected.png differ diff --git a/tests/_images/matrixplot/expected.png b/tests/_images/matrixplot/expected.png index 216626af46..cb2421ba02 100644 Binary files a/tests/_images/matrixplot/expected.png and b/tests/_images/matrixplot/expected.png differ diff --git a/tests/_images/matrixplot2/expected.png b/tests/_images/matrixplot2/expected.png index b4cdc8dc02..58990e2526 100644 Binary files a/tests/_images/matrixplot2/expected.png and b/tests/_images/matrixplot2/expected.png differ diff --git a/tests/_images/matrixplot_std_scale_group/expected.png b/tests/_images/matrixplot_std_scale_group/expected.png index 6d1970b3bb..05fe80da7d 100644 Binary files a/tests/_images/matrixplot_std_scale_group/expected.png and b/tests/_images/matrixplot_std_scale_group/expected.png differ diff --git a/tests/_images/stacked_violin/expected.png b/tests/_images/stacked_violin/expected.png index 8130c0e8d8..1cadbe8ad7 100644 Binary files a/tests/_images/stacked_violin/expected.png and b/tests/_images/stacked_violin/expected.png differ diff --git a/tests/_images/stacked_violin_no_cat_obs/expected.png b/tests/_images/stacked_violin_no_cat_obs/expected.png index 08c6a1fc82..750a346b0d 100644 Binary files a/tests/_images/stacked_violin_no_cat_obs/expected.png and b/tests/_images/stacked_violin_no_cat_obs/expected.png differ diff --git a/tests/_images/stacked_violin_std_scale_group/expected.png b/tests/_images/stacked_violin_std_scale_group/expected.png index 963cab263a..af4bf8948b 100644 Binary files a/tests/_images/stacked_violin_std_scale_group/expected.png and b/tests/_images/stacked_violin_std_scale_group/expected.png differ diff --git a/tests/_images/stacked_violin_std_scale_var_dict/expected.png b/tests/_images/stacked_violin_std_scale_var_dict/expected.png index a648f2ff8a..de1c02455e 100644 Binary files a/tests/_images/stacked_violin_std_scale_var_dict/expected.png and b/tests/_images/stacked_violin_std_scale_var_dict/expected.png differ diff --git a/tests/test_plotting.py b/tests/test_plotting.py index b2d14b52a7..60f1a774af 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -167,9 +167,9 @@ def test_clustermap(image_comparer, obs_keys, name): save_and_compare_images(name) -@pytest.mark.parametrize( - ("id", "fn"), - [ +params_dotplot_matrixplot_stacked_violin = [ + pytest.param(id, fn, id=id) + for id, fn in [ ( "dotplot", partial( @@ -317,10 +317,13 @@ def test_clustermap(image_comparer, obs_keys, name): figsize=(8, 2.5), ), ), - ], -) + ] +] + + +@pytest.mark.parametrize(("id", "fn"), params_dotplot_matrixplot_stacked_violin) def test_dotplot_matrixplot_stacked_violin(image_comparer, id, fn): - save_and_compare_images = partial(image_comparer, ROOT, tol=15) + save_and_compare_images = partial(image_comparer, ROOT, tol=5) adata = krumsiek11() adata.obs["numeric_column"] = adata.X[:, 0]