Skip to content

Commit

Permalink
Merge branch 'main' into feature/docs_examples
Browse files Browse the repository at this point in the history
# Conflicts:
#	pertpy/tools/_distances/_distances.py
  • Loading branch information
Lilly-May committed Oct 4, 2023
2 parents 61cef23 + 2308f58 commit 51fb500
Show file tree
Hide file tree
Showing 17 changed files with 1,228 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
# https://github.com/jupyterlab/jupyterlab/issues/12675
language_version: "17.9.1"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.288
rev: v0.0.292
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/notebooks
51 changes: 51 additions & 0 deletions docs/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,48 @@ pred.obs["condition"] = "pred"

See [scgen tutorial](https://pertpy.readthedocs.io/en/latest/tutorials/notebooks/scgen_perturbation_prediction.html) for a more elaborate tutorial.

#### CINEMA-OT

An implementation of [CINEMA-OT](https://github.com/vandijklab/CINEMA-OT) with the ott-jax library.
CINEMA-OT is a causal framework for perturbation effect analysis to identify individual treatment effects and synergy at the single cell level.
CINEMA-OT separates confounding sources of variation from perturbation effects to obtain an optimal transport matching that reflects counterfactual cell pairs.
These cell pairs represent causal perturbation responses permitting a number of novel analyses, such as individual treatment effect analysis, response clustering, attribution analysis, and synergy analysis.
See [Causal identification of single-cell experimental perturbation effects with CINEMA-OT](https://www.biorxiv.org/content/10.1101/2022.07.31.502173v3.abstract) for more details.

```{eval-rst}
.. currentmodule:: pertpy
```

```{eval-rst}
.. autosummary::
:toctree: tools
tools.Cinemaot
```

Example implementation:

```python
import pertpy as pt

adata = pt.dt.cinemaot_example()

model = pt.tl.Cinemaot()
de = model.causaleffect(
adata,
pert_key="perturbation",
control="No stimulation",
return_matching=True,
thres=0.5,
smoothness=1e-5,
eps=1e-3,
solver="Sinkhorn",
preweight_label="cell_type0528",
)
```

See [CINEMA-OT tutorial](https://pertpy.readthedocs.io/en/latest/tutorials/notebooks/cinemaot.html) for a more elaborate tutorial.

### Perturbation space

Various modules for calculating and evaluating perturbation spaces.
Expand Down Expand Up @@ -559,3 +601,12 @@ See [perturbation space tutorial](https://pertpy.readthedocs.io/en/latest/tutori
plot.scg.reg_var_plot
plot.scg.binary_classifier
```

#### CINEMA-OT

```{eval-rst}
.. autosummary::
:toctree: plot
plot.cot.vis_matching
```
1 change: 1 addition & 0 deletions pertpy/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
bhattacherjee,
burczynski_crohn,
chang_2021,
cinemaot_example,
datlinger_2017,
datlinger_2021,
dialogue_example,
Expand Down
2 changes: 1 addition & 1 deletion pertpy/data/_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _download( # pragma: no cover
response = requests.get(url, stream=True)
total = int(response.headers.get("content-length", 0))

with Progress(refresh_per_second=1500) as progress:
with Progress(refresh_per_second=100) as progress:
task = progress.add_task("[red]Downloading...", total=total)
Path(output_path).mkdir(parents=True, exist_ok=True)
with Path(download_to_path).open("wb") as file:
Expand Down
Loading

0 comments on commit 51fb500

Please sign in to comment.