Skip to content

Commit

Permalink
release: v0.2.1
Browse files Browse the repository at this point in the history
fix: missing seaborn dependency
  • Loading branch information
matq007 committed Sep 14, 2024
1 parent 56b329e commit cf8b62a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 40 deletions.
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ python:
path: .
extra_requirements:
- doc

27 changes: 17 additions & 10 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
# API

## scanvi_explainer
```
import scanvi_explainer
```

### Utilities: `utils`
```{eval-rst}
.. currentmodule:: scanvi_explainer
```

## SCANVIDeep

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

```{eval-rst}
.. autosummary::
:toctree: generated
:toctree: generated/
:nosignatures:
utils.train_test_group_split
scanvi_deep.SCANVIDeep
```

### Plots: `plots`
## Utilities

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

```{eval-rst}
.. autosummary::
:toctree: generated
:nosignatures:
:toctree: generated/
plots.feature_plot
utils.train_test_group_split
```

## SCANVIDeep
## Plots

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

```{eval-rst}
.. autosummary::
:toctree: generated
:toctree: generated/
:nosignatures:
scanvi_deep
plots.feature_plot
```
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@
nitpick_ignore = [
# If building the documentation fails because of a missing link that is outside your control,
# you can add an exception to this list.
("optional"),
("py:class", "type"),
("py:class", "scvi.model.SCANVI"),
("py:class", "scvi.model._scanvi.SCANVI"),
]
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "scanvi-explainer"
version = "0.2.0"
version = "0.2.1"
description = "Exapliner of scANVI using SHAP"
authors = [
{name = "Martin Proks", email = "[email protected]"},
Expand All @@ -17,6 +17,8 @@ keywords = ["shap", "scanvi", "explainer", "interpretability"]
dependencies = [
"anndata",
"rich",
"seaborn",
"scvi-tools",
"shap>=0.41.0",
]
classifiers = [
Expand All @@ -36,10 +38,10 @@ Issues = "https://github.com/brickmanlab/scanvi-explainer/issues"
Changelog = "https://github.com/brickmanlab/scanvi-explainer/blob/master/CHANGELOG.md"

[project.optional-dependencies]
dev = ["ruff", "scvi-tools", "huggingface_hub"]
dev = ["ruff", "huggingface_hub"]
doc = [
"setuptools",
"sphinx",
"sphinx>=4.0",
"myst-nb>=1.1",
"sphinx-book-theme>=1",
"sphinxcontrib-bibtex>=1"
Expand Down
2 changes: 1 addition & 1 deletion src/scanvi_explainer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
raise ImportError("Missing torch package! Run pip install torch")

if not importlib.util.find_spec("scvi"):
raise ImportError("Missing torch package! Run pip install torch")
raise ImportError("Missing torch package! Run pip install scvi-tools")

__all__ = ["SCANVIDeep", "utils", "plots"]
14 changes: 7 additions & 7 deletions src/scanvi_explainer/plots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import matplotlib.pyplot as plt
import numpy.typing as npt
import numpy as np
import pandas as pd
import seaborn as sns
from scvi import REGISTRY_KEYS
Expand All @@ -9,19 +9,19 @@

def feature_plot(
explainer: SCANVIDeep,
shap_values: npt.NDArray,
shap_values: np.ndarray,
subset: bool = False,
top_n: int = 10,
) -> None:
"""Prints feature contribution (absolute mean SHAP value) for each cell type (top 10).
Parameters
----------
explainer : SCANVIDeep
SCANVIDeep explainer
shap_values : npt.NDArray
Expected SHAP values
subset : bool, optional
explainer
:class:`~scanvi_explainer.scanvi_deep.SCANVIDeep` explainer
shap_values
:class:`~numpy.ndarray` Expected SHAP values
subset
When set to true, calculate contribution by subsetting for test cells which belong to that
particual classifier.
When set to false, be generic and return contributing features even when testing set has
Expand Down
16 changes: 8 additions & 8 deletions src/scanvi_explainer/scanvi_deep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import rich
from packaging import version
from scvi import REGISTRY_KEYS
from scvi.model._scanvi import SCANVI
from scvi.model import SCANVI
from shap import Explainer
from torch import Tensor
from tqdm.auto import tqdm
Expand All @@ -20,7 +20,7 @@ class SCANVIDeep(Explainer):
Parameters
----------
Explainer : type[Explainer]
Explainer
Main Explainer class from shap package
"""

Expand All @@ -36,12 +36,12 @@ def __init__(
Parameters
----------
model : SCANVI
Trained scANVI model
train_size : float, optional
Training size (background), by default 0.8
batch_size : int, optional
Number of cells used from each group, by default 128
model
Trained :class:`~scvi.model.SCANVI` model
train_size
:obj:`float` Training size (background), by default 0.8
batch_size
:obj:`int` Number of cells used from each group, by default 128
To ignore the batch_size subsetting, set batch_size=-1
"""
import torch
Expand Down
20 changes: 10 additions & 10 deletions src/scanvi_explainer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import torch
from scvi import REGISTRY_KEYS
from scvi.model._scanvi import SCANVI
from scvi.model import SCANVI
from sklearn.model_selection import train_test_split


Expand All @@ -14,7 +14,7 @@ def get_labels_key(model: SCANVI) -> str:
Parameters
----------
model : SCANVI
SCANVI model
:class:`~scvi.model.SCANVI` model
Returns
-------
Expand All @@ -29,8 +29,8 @@ def get_layer_key(model: SCANVI) -> str:
Parameters
----------
model : SCANVI
SCANVI model
model
:class:`~scvi.model.SCANVI` model
Returns
-------
Expand All @@ -56,14 +56,14 @@ def train_test_group_split(
Parameters
----------
adata : anndata.AnnData
Annotated dataset
adata
:class:`~anndata.AnnData` Annotated dataset
groupby : str
Column in metadata by which the dataset should be split by
train_size : float, optional
Training size (background), by default 0.8
batch_size : int, optional
Number of cells used from each group, by default 128
train_size
:obj:`float` Training size (background), by default 0.8
batch_size
:obj:`int` Number of cells used from each group, by default 128
Returns
-------
Expand Down

0 comments on commit cf8b62a

Please sign in to comment.