From 6aaa10772763707ccc139d953311f91dd0fb0235 Mon Sep 17 00:00:00 2001 From: jhaberbe <140021343+jhaberbe@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:15:48 -0700 Subject: [PATCH 1/7] Updated the rankby_obsm function to optionally accept keys to test as an argument. --- src/decoupler/tl/_rankby_obsm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/decoupler/tl/_rankby_obsm.py b/src/decoupler/tl/_rankby_obsm.py index 6d70f03..a9ee184 100644 --- a/src/decoupler/tl/_rankby_obsm.py +++ b/src/decoupler/tl/_rankby_obsm.py @@ -34,6 +34,7 @@ def rankby_obsm( adata: AnnData, key: str, uns_key: str | None = "rank_obsm", + obs_keys: list | None = None ) -> None | pd.DataFrame: """ Ranks features in ``adata.obsm`` by the significance of their association with metadata in ``adata.obs``. @@ -68,6 +69,10 @@ def rankby_obsm( assert isinstance(uns_key, str) or uns_key is None, "uns_key must be str or None" # Extract df, x_vars, y_vars = _input_rank_obsm(adata=adata, key=key) + + if obs_keys != None: + x_vars = obs_keys + # Test res = [] for x_var in x_vars: From 520cc98c7f780b00806fd721e5275099742d41ec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 19:18:42 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/decoupler/tl/_rankby_obsm.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/decoupler/tl/_rankby_obsm.py b/src/decoupler/tl/_rankby_obsm.py index a9ee184..4d0c2e4 100644 --- a/src/decoupler/tl/_rankby_obsm.py +++ b/src/decoupler/tl/_rankby_obsm.py @@ -31,10 +31,7 @@ def _input_rank_obsm( @docs.dedent def rankby_obsm( - adata: AnnData, - key: str, - uns_key: str | None = "rank_obsm", - obs_keys: list | None = None + adata: AnnData, key: str, uns_key: str | None = "rank_obsm", obs_keys: list | None = None ) -> None | pd.DataFrame: """ Ranks features in ``adata.obsm`` by the significance of their association with metadata in ``adata.obs``. From 7062a54415520e0a9041052437f3fee154a952bc Mon Sep 17 00:00:00 2001 From: jhaberbe <140021343+jhaberbe@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:22:06 -0700 Subject: [PATCH 3/7] Updated to make it "is not None" --- src/decoupler/tl/_rankby_obsm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decoupler/tl/_rankby_obsm.py b/src/decoupler/tl/_rankby_obsm.py index 4d0c2e4..55def5b 100644 --- a/src/decoupler/tl/_rankby_obsm.py +++ b/src/decoupler/tl/_rankby_obsm.py @@ -67,7 +67,7 @@ def rankby_obsm( # Extract df, x_vars, y_vars = _input_rank_obsm(adata=adata, key=key) - if obs_keys != None: + if obs_keys is not None: x_vars = obs_keys # Test From 9e451270e93b1ed550fba1aa19862638cd45d8af Mon Sep 17 00:00:00 2001 From: jhaberbe <140021343+jhaberbe@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:28:10 -0700 Subject: [PATCH 4/7] Updated the docstring. --- src/decoupler/tl/_rankby_obsm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/decoupler/tl/_rankby_obsm.py b/src/decoupler/tl/_rankby_obsm.py index 55def5b..aaf93d3 100644 --- a/src/decoupler/tl/_rankby_obsm.py +++ b/src/decoupler/tl/_rankby_obsm.py @@ -46,6 +46,8 @@ def rankby_obsm( %(key)s uns_key ``adata.uns`` key to store the results. + obs_keys + list of columns in adata.obs to use for testing. Returns ------- @@ -62,6 +64,9 @@ def rankby_obsm( sc.pp.scale(adata) sc.tl.pca(adata) dc.tl.rankby_obsm(adata, "X_pca") + + # or, to perform based on a subset of obs columns. + dc.tl.rankby_obsm(adata, "X_pca", obs_keys = ["condition"]) """ assert isinstance(uns_key, str) or uns_key is None, "uns_key must be str or None" # Extract From 7c608076d5a0f8c52ff0830fefa170a4487ede9c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 19:28:19 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/decoupler/tl/_rankby_obsm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decoupler/tl/_rankby_obsm.py b/src/decoupler/tl/_rankby_obsm.py index aaf93d3..29fc81f 100644 --- a/src/decoupler/tl/_rankby_obsm.py +++ b/src/decoupler/tl/_rankby_obsm.py @@ -66,7 +66,7 @@ def rankby_obsm( dc.tl.rankby_obsm(adata, "X_pca") # or, to perform based on a subset of obs columns. - dc.tl.rankby_obsm(adata, "X_pca", obs_keys = ["condition"]) + dc.tl.rankby_obsm(adata, "X_pca", obs_keys=["condition"]) """ assert isinstance(uns_key, str) or uns_key is None, "uns_key must be str or None" # Extract From 979e35652233c4770afce641f79d23d8e149cc61 Mon Sep 17 00:00:00 2001 From: Pau Badia i Mompel <44896790+PauBadiaM@users.noreply.github.com> Date: Fri, 25 Jul 2025 18:08:38 -0700 Subject: [PATCH 6/7] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f5d964c..534ecdc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = [ "hatchling" ] [project] name = "decoupler" -version = "2.1.1" +version = "2.1.2" description = "Python package to perform enrichment analysis from omics data." readme = "README.md" license = { file = "LICENSE" } From a492d45d0b090a86cdc99ce9806e233bca219619 Mon Sep 17 00:00:00 2001 From: Pau Badia i Mompel <44896790+PauBadiaM@users.noreply.github.com> Date: Fri, 25 Jul 2025 18:11:17 -0700 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9123295..931f437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning][]. [keep a changelog]: https://keepachangelog.com/en/1.0.0/ [semantic versioning]: https://semver.org/spec/v2.0.0.html +## 2.1.2 + +### Changes + +- `tl.rankby_obsm` now accepts `AnnData.obs` column names specified in the `obs_keys` argument. + ## 2.1.1 ### Added