From 10ebaa6f20b3864284c140ecce8ae0c8fc89fddf Mon Sep 17 00:00:00 2001 From: Tim Treis Date: Mon, 17 Mar 2025 17:17:34 +0100 Subject: [PATCH 1/4] mvp --- pyproject.toml | 5 +++++ src/scanpy/plotting/_stacked_violin.py | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index b699adceb4..9d4fa5eea3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,7 @@ dependencies = [ "session-info2", "legacy-api-wrap>=1.4", # for positional API deprecations "typing-extensions; python_version < '3.13'", + "anndata-plot @ git+https://github.com/scverse/anndata-plot.git@add_phils_wrapper", ] dynamic = [ "version" ] @@ -139,6 +140,8 @@ dev = [ "pre-commit", # static checking "towncrier", # release note management ] + + # Algorithms paga = [ "igraph" ] louvain = [ "igraph", "louvain>=0.6.0,!=0.6.2" ] # Louvain community detection @@ -160,6 +163,8 @@ packages = [ "src/testing", "src/scanpy" ] source = "vcs" raw-options.version_scheme = "release-branch-semver" +[tool.hatch.metadata] +allow-direct-references = true [tool.pytest.ini_options] addopts = [ "--import-mode=importlib", diff --git a/src/scanpy/plotting/_stacked_violin.py b/src/scanpy/plotting/_stacked_violin.py index 0e883c07f4..2e93ab9166 100644 --- a/src/scanpy/plotting/_stacked_violin.py +++ b/src/scanpy/plotting/_stacked_violin.py @@ -3,12 +3,16 @@ import warnings from typing import TYPE_CHECKING +import holoviews as hv +import anndata_plot as adp import numpy as np import pandas as pd from matplotlib import pyplot as plt from matplotlib.colors import is_color_like from packaging.version import Version +import scanpy as sc + from .. import logging as logg from .._compat import old_positionals from .._settings import settings @@ -23,6 +27,9 @@ savefig_or_show, ) +hv.extension("bokeh") + + if TYPE_CHECKING: from collections.abc import Mapping, Sequence from typing import Literal, Self @@ -202,6 +209,7 @@ def __init__( norm: Normalize | None = None, **kwds, ): + BasePlot.__init__( self, adata, @@ -346,6 +354,8 @@ def style( ... .style(row_palette='Blues', linewidth=0).show() """ + + super().style(cmap=cmap) if row_palette is not _empty: @@ -847,6 +857,21 @@ def stacked_violin( yticklabels=yticklabels, linewidth=kwds.get("linewidth", _empty), ).legend(title=colorbar_title) + + + + hv.extension("matplotlib") + + adata = sc.datasets.pbmc3k() + sc.pp.neighbors(adata) + sc.tl.umap(adata) + sc.tl.leiden(adata) + print(adata) + + return hv.Scatter(adata, "obsm.X_umap.0", ["obsm.X_umap.1", "obs.leiden"]).opts( + color="obs.leiden", cmap="Category20" + ) + if return_fig: return vp vp.make_figure() From 1e1b667b36323962016ceefdcfacd7133b0e065d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:20:49 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 4 ++-- src/scanpy/plotting/_stacked_violin.py | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9d4fa5eea3..b35dcbf783 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ dependencies = [ "tqdm", "scikit-learn>=1.1,<1.6", "statsmodels>=0.13", - "patsy!=1.0.0", # https://github.com/pydata/patsy/issues/215 + "patsy!=1.0.0", # https://github.com/pydata/patsy/issues/215 "networkx>=2.8", "natsort", "joblib", @@ -65,7 +65,7 @@ dependencies = [ "pynndescent>=0.5", "packaging>=21.3", "session-info2", - "legacy-api-wrap>=1.4", # for positional API deprecations + "legacy-api-wrap>=1.4", # for positional API deprecations "typing-extensions; python_version < '3.13'", "anndata-plot @ git+https://github.com/scverse/anndata-plot.git@add_phils_wrapper", ] diff --git a/src/scanpy/plotting/_stacked_violin.py b/src/scanpy/plotting/_stacked_violin.py index 2e93ab9166..97ed3eb4bf 100644 --- a/src/scanpy/plotting/_stacked_violin.py +++ b/src/scanpy/plotting/_stacked_violin.py @@ -4,7 +4,6 @@ from typing import TYPE_CHECKING import holoviews as hv -import anndata_plot as adp import numpy as np import pandas as pd from matplotlib import pyplot as plt @@ -209,7 +208,6 @@ def __init__( norm: Normalize | None = None, **kwds, ): - BasePlot.__init__( self, adata, @@ -354,8 +352,6 @@ def style( ... .style(row_palette='Blues', linewidth=0).show() """ - - super().style(cmap=cmap) if row_palette is not _empty: @@ -857,9 +853,7 @@ def stacked_violin( yticklabels=yticklabels, linewidth=kwds.get("linewidth", _empty), ).legend(title=colorbar_title) - - - + hv.extension("matplotlib") adata = sc.datasets.pbmc3k() @@ -871,7 +865,7 @@ def stacked_violin( return hv.Scatter(adata, "obsm.X_umap.0", ["obsm.X_umap.1", "obs.leiden"]).opts( color="obs.leiden", cmap="Category20" ) - + if return_fig: return vp vp.make_figure() From cc2f6caebe6a60a3dff32d451538602467f89b83 Mon Sep 17 00:00:00 2001 From: Tim Treis Date: Mon, 17 Mar 2025 17:25:44 +0100 Subject: [PATCH 3/4] updated pip install ref --- pyproject.toml | 2 +- src/scanpy/plotting/_stacked_violin.py | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9d4fa5eea3..c83353b36c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ dependencies = [ "session-info2", "legacy-api-wrap>=1.4", # for positional API deprecations "typing-extensions; python_version < '3.13'", - "anndata-plot @ git+https://github.com/scverse/anndata-plot.git@add_phils_wrapper", + "anndata-plot @ git+https://github.com/scverse/anndata-plot.git", ] dynamic = [ "version" ] diff --git a/src/scanpy/plotting/_stacked_violin.py b/src/scanpy/plotting/_stacked_violin.py index 2e93ab9166..923ad8d867 100644 --- a/src/scanpy/plotting/_stacked_violin.py +++ b/src/scanpy/plotting/_stacked_violin.py @@ -3,8 +3,10 @@ import warnings from typing import TYPE_CHECKING -import holoviews as hv import anndata_plot as adp +import holoviews as hv + +_ = adp # so linters don't complain import numpy as np import pandas as pd from matplotlib import pyplot as plt @@ -209,7 +211,6 @@ def __init__( norm: Normalize | None = None, **kwds, ): - BasePlot.__init__( self, adata, @@ -354,8 +355,6 @@ def style( ... .style(row_palette='Blues', linewidth=0).show() """ - - super().style(cmap=cmap) if row_palette is not _empty: @@ -857,9 +856,7 @@ def stacked_violin( yticklabels=yticklabels, linewidth=kwds.get("linewidth", _empty), ).legend(title=colorbar_title) - - - + hv.extension("matplotlib") adata = sc.datasets.pbmc3k() @@ -871,7 +868,7 @@ def stacked_violin( return hv.Scatter(adata, "obsm.X_umap.0", ["obsm.X_umap.1", "obs.leiden"]).opts( color="obs.leiden", cmap="Category20" ) - + if return_fig: return vp vp.make_figure() From 208a7bd66b574c47a16b64c8010c0e1ac376ef09 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:29:25 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c7da66df66..12f21a2aa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ dependencies = [ "tqdm", "scikit-learn>=1.1,<1.6", "statsmodels>=0.13", - "patsy!=1.0.0", # https://github.com/pydata/patsy/issues/215 + "patsy!=1.0.0", # https://github.com/pydata/patsy/issues/215 "networkx>=2.8", "natsort", "joblib", @@ -65,7 +65,7 @@ dependencies = [ "pynndescent>=0.5", "packaging>=21.3", "session-info2", - "legacy-api-wrap>=1.4", # for positional API deprecations + "legacy-api-wrap>=1.4", # for positional API deprecations "typing-extensions; python_version < '3.13'", "anndata-plot @ git+https://github.com/scverse/anndata-plot.git", ]