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 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" } diff --git a/src/decoupler/tl/_rankby_obsm.py b/src/decoupler/tl/_rankby_obsm.py index 6d70f03..29fc81f 100644 --- a/src/decoupler/tl/_rankby_obsm.py +++ b/src/decoupler/tl/_rankby_obsm.py @@ -31,9 +31,7 @@ def _input_rank_obsm( @docs.dedent def rankby_obsm( - adata: AnnData, - key: str, - uns_key: str | None = "rank_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``. @@ -48,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 ------- @@ -64,10 +64,17 @@ 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 df, x_vars, y_vars = _input_rank_obsm(adata=adata, key=key) + + if obs_keys is not None: + x_vars = obs_keys + # Test res = [] for x_var in x_vars: