Skip to content

Commit

Permalink
fix: documentation generation
Browse files Browse the repository at this point in the history
  • Loading branch information
matq007 committed Sep 13, 2024
1 parent 5e2a870 commit 51e8eab
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $ uv sync
## Build documentation

```console
$ sphinx-build -M html docs docs/_build
$ rm -rf docs/{generated,_build} && sphinx-build -M html docs docs/_build
```

## Citation
Expand Down
29 changes: 18 additions & 11 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
# API

## scanvi_explainer
```
import scanvi_explainer
```

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

### Utilities: `utils`
## 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
:toctree: generated/
:nosignatures:
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
```
13 changes: 8 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from importlib.metadata import metadata
from pathlib import Path

HERE = Path(__file__).parent
sys.path[:0] = [str(HERE.parent)]

# -- Project information -----------------------------------------------------

# NOTE: If you installed your project in editable mode, this might be stale.
Expand Down Expand Up @@ -120,8 +123,8 @@

pygments_style = "default"

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"),
]
# 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.
# ("py:class", "py:obj", "optional"),
# ]
14 changes: 7 additions & 7 deletions docs/notebooks/Example.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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 Down
3 changes: 2 additions & 1 deletion src/scanvi_explainer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib.util

from . import plots, utils
from .scanvi_deep import SCANVIDeep

if not importlib.util.find_spec("torch"):
Expand All @@ -8,4 +9,4 @@
if not importlib.util.find_spec("scvi"):
raise ImportError("Missing torch package! Run pip install torch")

__all__ = ["SCANVIDeep", "utils", "plots"]
__all__ = ["plots", "SCANVIDeep", "utils"]
16 changes: 8 additions & 8 deletions src/scanvi_explainer/plots.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import matplotlib.pyplot as plt
import numpy.typing as npt
import numpy.typing as ntp
import pandas as pd
import seaborn as sns
from scvi import REGISTRY_KEYS

from .scanvi_deep import SCANVIDeep
from scanvi_explainer.scanvi_deep import SCANVIDeep


def feature_plot(
explainer: SCANVIDeep,
shap_values: npt.NDArray,
shap_values: ntp.ArrayLike,
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.typing.ArrayLike` Expected SHAP values
subset : :obj:`bool`, optional
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
6 changes: 3 additions & 3 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 Down Expand Up @@ -60,9 +60,9 @@ def train_test_group_split(
Annotated dataset
groupby : str
Column in metadata by which the dataset should be split by
train_size : float, optional
train_size : :obj:`float`, optional
Training size (background), by default 0.8
batch_size : int, optional
batch_size : :obj:`int`, optional
Number of cells used from each group, by default 128
Returns
Expand Down

0 comments on commit 51e8eab

Please sign in to comment.