Skip to content

Commit

Permalink
Expand tests (#22)
Browse files Browse the repository at this point in the history
* Added simulation framework tests.

* Add initialization test.

* Update `README` to better reflect current dev workflow.

Also make some formatting improvements.

* Added multigroup test for spatial affinity groups.

* Remove deprecated arguments in `load_anndata`.

Also reformat `io.py`.

* Add linter configurations to `pyproject.toml`.

* Fix import name for `test_util.py`.

* Add configuration for pre-commit.

* Update test data.

* Fix analysis tests.

Fix analysis functions to match new tests.
Fix code style.

* Add tests for and refactor `simulation_framework.py`.

* Finish `MultiReplicateSyntheticDataset` tests.
Refactor accordingly.
Add test data/expected outputs.

* Fixes to `_canvas.py` and `simulation_framework.py`.

* Add documentation for simulations.

Fix intiialization tests.

* Fix up binning test.

Also update dependencies to use compatible versions of newest `squidpy` and `anndata`. See `https://github.com/scverse/squidpy/pull/891`.
  • Loading branch information
alam-shahul authored Sep 23, 2024
1 parent 9ed6df9 commit cf49313
Show file tree
Hide file tree
Showing 137 changed files with 73,767 additions and 46,014 deletions.
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: [-c=.yamllint.yml]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
- id: pyupgrade

- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: ["--safe"]

- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
name: Format docstring
args: [--in-place, --wrap-summaries, "80", --wrap-descriptions, "80", --blank]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
name: Format markdown
additional_dependencies:
- mdformat-gfm
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Popari


Popari is a versatile framework for joint analysis and investigation of complex spatial transcriptomics datasets. Read the documentation (including installation instructions) [here](https://popari.readthedocs.io/en/latest/).

> :warning: **Popari is still under active development.** Check back in a bit for a more complete user experience!
Expand All @@ -9,14 +8,12 @@ Popari is a versatile framework for joint analysis and investigation of complex
<img src="./popari_overview_v5.png" width="800">
</p>

## Dev Instructions
### Install
## Dev instructions

```
pip install popari
```
For development, create a fresh Python environment; this should not contain the PyPI-published
version of the package.

### Publishing
### PyPI publishing

```
pip install hatch
Expand All @@ -25,41 +22,53 @@ pip install keyrings.alt
hatch build
hatch publish
```

Username: `__token__`
Password: `{API token for PyPI}`

### Tests
### Running `pytest` tests

To run the provided tests and ensure that SpiceMix can run on your platform, follow the instructions below:
To run the provided tests and ensure that Popari can run on your platform, follow the instructions below:

- Download this repo.
```console
git clone https://github.com/alam-shahul/SpiceMixPlus.git
```
- Install `pytest` in your environment.

```console
pip install pytest
```
- Navigate to the root directory of this repo.
- Run the following command. With GPU resources, this test should execute without errors in ~2.5 minutes:

- Navigate to the root directory of this repo, and run all tests with

```console
python -m pytest -s
```

- Alternatively, run a single test suite as below:

```console
python -m pytest -s tests/test_popari_shared.py
```

### Building Documentation

Assuming you have CMake:

1. Navigate to `docs/`.

```console
cd docs/
```

2. Install Sphinx requirements.

```console
pip install -r requirements.txt
```

3. Clean and build.

```console
make clean
make html
```

4. Push to GitHub, and documentation will automatically build.
27 changes: 22 additions & 5 deletions docs/source/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Tools for loading and saving Popari data and parameters.
.. autosummary::
:toctree: api/
:recursive:
io.save_anndata
io.load_anndata
```
Expand All @@ -42,7 +42,7 @@ Entry points for implementations of the Popari algorithm.
.. autosummary::
:toctree: api/
:recursive:
model.Popari
model.load_trained_model
```
Expand All @@ -58,7 +58,7 @@ Objects that are helpful for working with Popari.
.. autosummary::
:toctree: api/
:recursive:
components.PopariDataset
```

Expand All @@ -73,7 +73,7 @@ Functions for visualizing and evaluating Popari results.
.. autosummary::
:toctree: api/
:recursive:
tl.preprocess_embeddings
tl.leiden
tl.compute_ari_scores
Expand All @@ -98,11 +98,28 @@ Functions for visualizing and evaluating Popari results.
.. autosummary::
:toctree: api/
:recursive:
pl.in_situ
pl.all_embeddings
pl.metagene_embedding
pl.multireplicate_heatmap
pl.multigroup_heatmap
pl.confusion_matrix
```

## Simulation

Tools to generate simulated (multisample) spatially-resolved transcriptomics, or (m)SRT.

```{eval-rst}
.. module:: popari.simulation_framework
.. currentmodule:: popari
.. autosummary::
:toctree: api/
:recursive:
simulation_framework.SimulationParameters
simulation_framework.SyntheticDataset
simulation_framework.MultiReplicateSyntheticDataset
```
38 changes: 19 additions & 19 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))

sys.path.insert(0, os.path.abspath("../.."))


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

project = 'popari'
copyright = 'Ma Lab @ CMU, 2022'
author = 'Shahul Alam'
project = "popari"
copyright = "Ma Lab @ CMU, 2024"
author = "Shahul Alam"

# The full version, including alpha/beta/rc tags
release = '0.0.1'
release = "0.0.1"


# -- General configuration ---------------------------------------------------
Expand All @@ -31,21 +32,21 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
'sphinx.ext.autodoc.typehints',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'myst_nb',
'sphinx_copybutton',
'sphinx_remove_toctrees'
"sphinx.ext.autosummary",
"sphinx.ext.autodoc",
"sphinx.ext.autodoc.typehints",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"myst_nb",
"sphinx_copybutton",
"sphinx_remove_toctrees",
]

# filetypes to use for documentation
source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -58,16 +59,16 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_book_theme'
html_theme = "sphinx_book_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# -- Options for included extensions -----------------------------------------

autosummary_generate=True
autosummary_generate = True
# nbsphinx_execute = 'never'
# nbsphinx_allow_directives = True
nb_execution_mode = "off"
Expand All @@ -80,4 +81,3 @@
"repository_url": "https://github.com/alam-shahul/popari",
"use_repository_button": True,
}

Loading

0 comments on commit cf49313

Please sign in to comment.