Skip to content

Commit 48953b8

Browse files
authored
Improve mixscape parameter names & prepare 1.0.3 (#848)
* Replace figshare with scverse AWS Signed-off-by: Lukas Heumos <[email protected]> * move settings import Signed-off-by: Lukas Heumos <[email protected]> * use anndata read Signed-off-by: Lukas Heumos <[email protected]> * add changelog Signed-off-by: Lukas Heumos <[email protected]> * test burczynski_crohn Signed-off-by: Lukas Heumos <[email protected]> * revert Signed-off-by: Lukas Heumos <[email protected]> * reset datasets Signed-off-by: Lukas Heumos <[email protected]> * reset datasets Signed-off-by: Lukas Heumos <[email protected]> * Fix scgen Signed-off-by: Lukas Heumos <[email protected]> * remove data Signed-off-by: Lukas Heumos <[email protected]> * fix mixscape Signed-off-by: Lukas Heumos <[email protected]> --------- Signed-off-by: Lukas Heumos <[email protected]>
1 parent a2824dd commit 48953b8

File tree

11 files changed

+93
-103
lines changed

11 files changed

+93
-103
lines changed

.github/release-drafter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name-template: "1.0.2 🌈"
2-
tag-template: 1.0.2
1+
name-template: "1.0.3 🌈"
2+
tag-template: 1.0.3
33
exclude-labels:
44
- "skip-changelog"
55

docs/changelog.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## v1.0.3
9+
10+
### 🚀 Features
11+
12+
* Move from figshare to scverse AWS S3 ([#848](https://github.com/scverse/pertpy/pull/848)) @Zethson
13+
* Rename `label_transfer` `column` parameter to `target_column` ([#848](https://github.com/scverse/pertpy/pull/848)) @Zethson
14+
* Rename `mixscape` `labels` parameter to `pert_key` ([#848](https://github.com/scverse/pertpy/pull/848)) @Zethson
15+
816
## v1.0.2
917

1018
### 🐛 Bug Fixes
1119

12-
* Fix: Validate 'type' parameter in Tasccoda.load ([#839](https://github.com/scverse/pertpy/pull/839)) @JuanTejedor
20+
* Fix Validate 'type' parameter in Tasccoda.load ([#839](https://github.com/scverse/pertpy/pull/839)) @JuanTejedor
1321
* Partial fixes for make_arviz ([#834](https://github.com/scverse/pertpy/pull/834)) @jpintar
1422
* Fix setting of `rng_key` in `make_arviz` ([#831](https://github.com/scverse/pertpy/pull/831)) @jpintar
15-
* Fixed GDSC and PRISM annotation warnings ([#835](https://github.com/scverse/pertpy/pull/835)) @Lilly-May
23+
* Fix GDSC and PRISM annotation warnings ([#835](https://github.com/scverse/pertpy/pull/835)) @Lilly-May
1624

1725
## v1.0.1
1826

docs/tutorials/notebooks

pertpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = "Lukas Heumos"
44
__email__ = "[email protected]"
5-
__version__ = "1.0.2"
5+
__version__ = "1.0.3"
66

77
import warnings
88

pertpy/metadata/_drug.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
from ._metadata import MetaData
1515

1616
if TYPE_CHECKING:
17+
from collections.abc import Mapping
18+
1719
from anndata import AnnData
1820

1921

2022
def _download_drug_annotation(
2123
source: Literal["chembl", "dgidb", "pharmgkb"] = "chembl",
22-
) -> pd.DataFrame | dict[str, dict[str, list[str]]]:
24+
) -> pd.DataFrame | Mapping[str, Mapping[str, list[str]]]:
2325
if source == "chembl":
2426
# Prepared in https://github.com/theislab/pertpy-datasets/blob/main/chembl_data.ipynb
2527
chembl_path = Path(settings.cachedir) / "chembl.json"
@@ -232,7 +234,7 @@ def df(self) -> pd.DataFrame:
232234
self.set()
233235
return self.dataframe
234236

235-
def dict(self) -> dict[str, list[str]] | dict[str, dict[str, list[str]]]:
237+
def dict(self) -> Mapping[str, list[str]] | Mapping[str, Mapping[str, list[str]]]:
236238
if not self.loaded:
237239
self.set()
238240
return self.dictionary

pertpy/tools/_coda/_sccoda.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from lamin_utils import logger
1212
from mudata import MuData
1313
from numpyro.infer import Predictive
14-
from rich import print
1514

1615
from pertpy.tools._coda._base_coda import CompositionalModel2, from_scanpy
1716

@@ -25,24 +24,6 @@
2524
class Sccoda(CompositionalModel2):
2625
r"""Statistical model for single-cell differential composition analysis with specification of a reference cell type.
2726
28-
This is the standard scCODA model and recommended for all uses.
29-
30-
The hierarchical formulation of the model for one sample is:
31-
32-
.. math::
33-
y|x &\\sim DirMult(\\phi, \\bar{y}) \\\\
34-
\\log(\\phi) &= \\alpha + x \\beta \\\\
35-
\\alpha_k &\\sim N(0, 5) \\quad &\\forall k \\in [K] \\\\
36-
\\beta_{m, \\hat{k}} &= 0 &\\forall m \\in [M]\\\\
37-
\\beta_{m, k} &= \\tau_{m, k} \\tilde{\\beta}_{m, k} \\quad &\\forall m \\in [M], k \\in \\{[K] \\smallsetminus \\hat{k}\\} \\\\
38-
\\tau_{m, k} &= \\frac{\\exp(t_{m, k})}{1+ \\exp(t_{m, k})} \\quad &\\forall m \\in [M], k \\in \\{[K] \\smallsetminus \\hat{k}\\} \\\\
39-
\\frac{t_{m, k}}{50} &\\sim N(0, 1) \\quad &\\forall m \\in [M], k \\in \\{[K] \\smallsetminus \\hat{k}\\} \\\\
40-
\\tilde{\\beta}_{m, k} &= \\sigma_m^2 \\cdot \\gamma_{m, k} \\quad &\\forall m \\in [M], k \\in \\{[K] \\smallsetminus \\hat{k}\\} \\\\
41-
\\sigma_m^2 &\\sim HC(0, 1) \\quad &\\forall m \\in [M] \\\\
42-
\\gamma_{m, k} &\\sim N(0,1) \\quad &\\forall m \\in [M], k \\in \\{[K] \\smallsetminus \\hat{k}\\} \\\\
43-
44-
with y being the cell counts and x the covariates.
45-
4627
For further information, see `scCODA is a Bayesian model for compositional single-cell data analysis`
4728
(Büttner, Ostner et al., NatComms, 2021)
4829
"""

pertpy/tools/_coda/_tasccoda.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,6 @@
3333
class Tasccoda(CompositionalModel2):
3434
r"""Statistical model for tree-aggregated differential composition analysis (tascCODA, Ostner et al., 2021).
3535
36-
The hierarchical formulation of the model for one sample is:
37-
38-
.. math::
39-
\\begin{align*}
40-
Y_i &\\sim \\textrm{DirMult}(\\bar{Y}_i, \\textbf{a}(\\textbf{x})_i)\\\\
41-
\\log(\\textbf{a}(X))_i &= \\alpha + X_{i, \\cdot} \\beta\\\\
42-
\\alpha_j &\\sim \\mathcal{N}(0, 10) & \\forall j\\in[p]\\\\
43-
\\beta &= \\hat{\\beta} A^T \\\\
44-
\\hat{\\beta}_{l, k} &= 0 & \\forall k \\in \\hat{v}, l \\in [d]\\\\
45-
\\hat{\\beta}_{l, k} &= \\theta \\tilde{\\beta}_{1, l, k} + (1- \\theta) \\tilde{\\beta}_{0, l, k} \\quad & \\forall k\\in\\{[v] \\smallsetminus \\hat{v}\\}, l \\in [d]\\\\
46-
\\tilde{\\beta}_{m, l, k} &= \\sigma_{m, l, k} * b_{m, l, k} \\quad & \\forall k\\in\\{[v] \\smallsetminus \\hat{v}\\}, m \\in \\{0, 1\\}, l \\in [d]\\\\
47-
\\sigma_{m, l, k} &\\sim \\textrm{Exp}(\\lambda_{m, l, k}^2/2) \\quad & \\forall k\\in\\{[v] \\smallsetminus \\hat{v}\\}, l \\in \\{0, 1\\}, l \\in [d]\\\\
48-
b_{m, l, k} &\\sim N(0,1) \\quad & \\forall k\\in\\{[v] \\smallsetminus \\hat{v}\\}, l \\in \\{0, 1\\}, l \\in [d]\\\\
49-
\\theta &\\sim \\textrm{Beta}(1, \\frac{1}{|\\{[v] \\smallsetminus \\hat{v}\\}|})
50-
\\end{align*}
51-
52-
with Y being the cell counts, X the covariates, and v the set of nodes of the underlying tree structure.
53-
5436
For further information, see `tascCODA: Bayesian Tree-Aggregated Analysis of Compositional Amplicon and Single-Cell Data`
5537
(Ostner et al., 2021)
5638
"""
@@ -75,11 +57,14 @@ def load(
7557
modality_key_1: str = "rna",
7658
modality_key_2: str = "coda",
7759
) -> MuData:
78-
"""Prepare a MuData object for subsequent processing. If type is "cell_level", then create a compositional analysis dataset from the input adata. If type is "sample_level", generate ete tree for tascCODA models from dendrogram information or cell-level observations.
60+
"""Prepare a MuData object for subsequent processing.
61+
62+
If type is "cell_level", then create a compositional analysis dataset from the input adata.
63+
If type is "sample_level", generate ete tree for tascCODA models from dendrogram information or cell-level observations.
7964
80-
When using ``type="cell_level"``, ``adata`` needs to have a column in ``adata.obs`` that contains the cell type assignment.
65+
When using `type="cell_level"`, `adata` needs to have a column in `adata.obs` that contains the cell type assignment.
8166
Further, it must contain one column or a set of columns (e.g. subject id, treatment, disease status) that uniquely identify each (statistical) sample.
82-
Further covariates (e.g. subject age) can either be specified via addidional column names in ``adata.obs``, a key in ``adata.uns``, or as a separate DataFrame.
67+
Further covariates (e.g. subject age) can either be specified via addidional column names in `adata.obs`, a key in `adata.uns`, or as a separate DataFrame.
8368
8469
Args:
8570
adata: AnnData object.
@@ -90,10 +75,13 @@ def load(
9075
covariate_obs: If type is "cell_level", specify list of keys for adata.obs, where covariate values are stored.
9176
covariate_df: If type is "cell_level", specify dataFrame with covariates.
9277
dendrogram_key: Key to the scanpy.tl.dendrogram result in `.uns` of original cell level anndata object.
93-
levels_orig: List that indicates which columns in `.obs` of the original data correspond to tree levels. The list must begin with the root level, and end with the leaf level.
94-
levels_agg: List that indicates which columns in `.var` of the aggregated data correspond to tree levels. The list must begin with the root level, and end with the leaf level.
78+
levels_orig: List that indicates which columns in `.obs` of the original data correspond to tree levels.
79+
The list must begin with the root level, and end with the leaf level.
80+
levels_agg: List that indicates which columns in `.var` of the aggregated data correspond to tree levels.
81+
The list must begin with the root level, and end with the leaf level.
9582
add_level_name: If True, internal nodes in the tree will be named as "{level_name}_{node_name}" instead of just {level_name}.
96-
key_added: If not specified, the tree is stored in .uns[‘tree’]. If `data` is AnnData, save tree in `data`. If `data` is MuData, save tree in data[modality_2].
83+
key_added: If not specified, the tree is stored in `.uns['tree']`.
84+
If `data` is AnnData, save tree in `data`. If `data` is MuData, save tree in data[modality_2].
9785
modality_key_1: Key to the cell-level AnnData in the MuData object.
9886
modality_key_2: Key to the aggregated sample-level AnnData object in the MuData object.
9987

0 commit comments

Comments
 (0)