Skip to content

Commit

Permalink
Merge branch 'development' into implement_additional_distance_metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Zethson authored Aug 7, 2023
2 parents c33f9ce + 5dc2b9b commit b2baac4
Show file tree
Hide file tree
Showing 46 changed files with 4,041 additions and 2,344 deletions.
5 changes: 0 additions & 5 deletions .bandit.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .cookietemple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ full_name: Lukas Heumos
email: [email protected]
project_name: pertpy
project_short_description: Perturbation Analysis in the Scanpy ecosystem.
version: 0.5.0
version: 0.6.0
license: MIT
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: "0.5.0 🌈" # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.5.0 # <<COOKIETEMPLE_FORCE_BUMP>>
name-template: "0.6.0 🌈" # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.6.0 # <<COOKIETEMPLE_FORCE_BUMP>>
exclude-labels:
- "skip-changelog"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
python: ["3.8", "3.10"]
python: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install Poetry
run: |
Expand All @@ -30,7 +30,7 @@ jobs:
poetry build --ansi
- name: Publish package on PyPI
uses: pypa/[email protected].6
uses: pypa/[email protected].8
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,6 @@ cache

# Apple stuff
.DS_Store

lightning_logs/*
*/lightning_logs/*
17 changes: 9 additions & 8 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ version: 2
sphinx:
configuration: docs/conf.py

formats:
- htmlzip
formats: []

python:
version: 3.8
install:
- method: pip
path: .
- requirements: docs/requirements.txt
build:
os: ubuntu-22.04
tools:
python: "3.10"
jobs:
post_install:
- pip install .
- pip install -r docs/requirements.txt

submodules:
include: all
2 changes: 1 addition & 1 deletion cookietemple.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.0
current_version = 0.6.0

[bumpversion_files_whitelisted]
init_file = pertpy/__init__.py
Expand Down
Binary file added docs/_static/tutorials/ontology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
author = "Lukas Heumos"
github_repo = "pertpy"

version = "0.5.0"
release = "0.5.0"
version = "0.6.0"
release = "0.6.0"

extensions = [
"myst_parser",
Expand All @@ -33,7 +33,6 @@
"sphinx_gallery.load_style",
"sphinx_remove_toctrees",
"sphinx_design",
"sphinxext.opengraph",
]

# remove_from_toctrees = ["tutorials/notebooks/*", "api/reference/*"]
Expand Down Expand Up @@ -184,4 +183,5 @@
"tutorials/notebooks/distance_tests": "_static/tutorials/distances_tests.png",
"tutorials/notebooks/scgen_perturbation_prediction": "_static/tutorials/scgen_perturbation_prediction.png",
"tutorials/notebooks/scgen_batch_removal": "_static/tutorials/scgen_batch_removal.png",
"tutorials/notebooks/ontology_mapping": "_static/tutorials/ontology.png",
}
3 changes: 1 addition & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributor Guide

Thank you for your interest in improving this project.
This project is open-source under the [Apache2.0 license] and
This project is open-source under the MIT license and
highly welcomes contributions in the form of bug reports, feature requests, and pull requests.

Here is a list of important resources for contributors:
Expand Down Expand Up @@ -120,7 +120,6 @@ $ nox --session=pre-commit -- install
It is recommended to open an issue before starting work on anything.
This will allow a chance to talk it over with the owners and validate your approach.

[apache2.0 license]: https://opensource.org/licenses/Apache2.0
[code of conduct]: https://github.com/theislab/pertpy/CODE_OF_CONDUCT.md
[documentation]: https://pertpy.readthedocs.io/
[issue tracker]: https://github.com/theislab/pertpy/issues
Expand Down
14 changes: 6 additions & 8 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
Sphinx
sphinx
sphinx-automodapi
sphinx-autodoc-annotation
sphinx-autodoc-typehints
sphinx-design
sphinx-gallery
sphinx_last_updated_by_git
sphinxcontrib-spelling
sphinx-autodoc-typehints
sphinx_gallery<0.11
sphinxcontrib-bibtex
sphinx-copybutton
nbsphinx
nbsphinx-link
sphinx-copybutton
furo
myst-parser
sphinx-remove-toctrees
sphinx-design
sphinxext-opengraph
ete3
pyqt5
sphinx-remove-toctrees
1 change: 1 addition & 0 deletions docs/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ For questions about the usage of pertpy use [Github Discussions].
notebooks/distance_tests
notebooks/scgen_perturbation_prediction
notebooks/scgen_batch_removal
notebooks/ontology_mapping
```

### Glossary
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/notebooks
146 changes: 81 additions & 65 deletions docs/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Example implementation:
import pertpy as pt
import scanpy as sc

mdata = pt.data.papalexi_2021()
mdata = pt.dt.papalexi_2021()
gdo = mdata.mod['gdo']
gdo.layers['counts'] = gdo.X.copy()
sc.pp.log1p(gdo)
Expand All @@ -112,50 +112,6 @@ pt.pl.guide.heatmap(gdo, layer='assigned_guides')

## Tools

### Cell type prioritization

#### Augur

The Python implementation of [Augur R package](https://github.com/neurorestore/Augur)
Skinnider, M.A., Squair, J.W., Kathe, C. et al. [Cell type prioritization in single-cell data](https://doi.org/10.1038/s41587-020-0605-1). Nat Biotechnol 39, 30–34 (2021).

Augur aims to rank or prioritize cell types according to their response to experimental perturbations given high dimensional single-cell sequencing data.
The basic idea is that in the space of molecular measurements cells reacting heavily to induced perturbations are
more easily separated into perturbed and unperturbed than cell types with little or no response.
This separability is quantified by measuring how well experimental labels (eg. treatment and control) can be predicted within each cell type.
Augur trains a machine learning model predicting experimental labels for each cell type in multiple cross validation runs and
then prioritizes cell type response according to metric scores measuring the accuracy of the model.
For categorical data the area under the curve is the default metric and for numerical data the concordance correlation coefficient
is used as a proxy for how accurate the model is which in turn approximates perturbation response.

Example implementation:

```python
import pertpy as pt

adata = pt.dt.sc_sim_augur()
ag = pt.tl.Augur(estimator="random_forest_classifier")
adata = ag.load(adata)
adata, results = ag.predict(adata)

# metrics for each cell type
results['summary_metrics']
```

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

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

```{eval-rst}
.. autosummary::
:toctree: tools
:nosignatures:
tools.Augur
```

### Pooled CRISPR screens

#### Mixscape
Expand Down Expand Up @@ -219,7 +175,7 @@ Example implementation:
import pertpy as pt
import scanpy as sc

adata = pt.data.stephenson_2021_subsampled()
adata = pt.dt.stephenson_2021_subsampled()
adata.obs['COVID_severity'] = adata.obs['Status_on_day_collection_summary'].copy()
adata.obs[['patient_id', 'COVID_severity']].drop_duplicates()
adata = adata[adata.obs['Status'] != 'LPS'].copy()
Expand Down Expand Up @@ -319,8 +275,8 @@ all_results, new_mcps = dl.multilevel_modeling(ct_subs=ct_subs,

### Distances and Permutation Tests

General purpose functions for distances and permutation tests. Reimplements
functions from [scperturb](http://projects.sanderlab.org/scperturb/) package.
General purpose functions for distances and permutation tests.
Reimplements functions from [scperturb](http://projects.sanderlab.org/scperturb/) package.

```{eval-rst}
.. currentmodule:: pertpy
Expand Down Expand Up @@ -377,6 +333,48 @@ Available databases for cell line metadata:

### Response prediction

#### Augur

The Python implementation of [Augur R package](https://github.com/neurorestore/Augur)
Skinnider, M.A., Squair, J.W., Kathe, C. et al. [Cell type prioritization in single-cell data](https://doi.org/10.1038/s41587-020-0605-1). Nat Biotechnol 39, 30–34 (2021).

Augur aims to rank or prioritize cell types according to their response to experimental perturbations given high dimensional single-cell sequencing data.
The basic idea is that in the space of molecular measurements cells reacting heavily to induced perturbations are
more easily separated into perturbed and unperturbed than cell types with little or no response.
This separability is quantified by measuring how well experimental labels (eg. treatment and control) can be predicted within each cell type.
Augur trains a machine learning model predicting experimental labels for each cell type in multiple cross validation runs and
then prioritizes cell type response according to metric scores measuring the accuracy of the model.
For categorical data the area under the curve is the default metric and for numerical data the concordance correlation coefficient
is used as a proxy for how accurate the model is which in turn approximates perturbation response.

Example implementation:

```python
import pertpy as pt

adata = pt.dt.sc_sim_augur()
ag = pt.tl.Augur(estimator="random_forest_classifier")
adata = ag.load(adata)
adata, results = ag.predict(adata)

# metrics for each cell type
results['summary_metrics']
```

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

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

```{eval-rst}
.. autosummary::
:toctree: tools
:nosignatures:
tools.Augur
```

#### scGen

Reimplementation of scGen for perturbation response prediction of scRNA-seq data in Jax.
Expand Down Expand Up @@ -419,41 +417,46 @@ pred, delta = model.predict(
pred.obs['condition'] = 'pred'
```

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

### Representation
### Perturbation space

Various modules for calculating and evaluating perturbation spaces.

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

```{eval-rst}
.. autosummary::
:toctree: tools
tools.kernel_pca
tools.DiscriminatorClassifierSpace
tools.CentroidSpace
tools.DBSCANSpace
tools.KMeansSpace
tools.PseudobulkSpace
```

## Plots

### Preprocessing

```{eval-rst}
.. autosummary::
:toctree: plot
Example implementation:

plot.guide
```python
import pertpy as pt

# TODO will be added soon.
```

### Cell type prioritization
See [perturbation space tutorial](https://pertpy.readthedocs.io/en/latest/tutorials/notebooks/perturbation_space.html) for a more elaborate tutorial.

#### Augur
## Plots

### Preprocessing

```{eval-rst}
.. autosummary::
:toctree: plot
plot.ag.dp_scatter
plot.ag.important_features
plot.ag.lollipop
plot.ag.scatterplot
plot.guide
```

Expand Down Expand Up @@ -503,6 +506,19 @@ See [augur tutorial](https://pertpy.readthedocs.io/en/latest/tutorials/notebooks

### Response prediction

#### Augur

```{eval-rst}
.. autosummary::
:toctree: plot
plot.ag.dp_scatter
plot.ag.important_features
plot.ag.lollipop
plot.ag.scatterplot
```

#### scGen

```{eval-rst}
Expand Down
Loading

0 comments on commit b2baac4

Please sign in to comment.