[go: nahoru, domu]

Skip to content

Commit

Permalink
add moran from scanpy (#317)
Browse files Browse the repository at this point in the history
* add moran from scanpy

* add abs to pvalue

* fix pvalues

* add standard approx from perm pvalue (pysal dep return)

* change req

* update tests and req

* add gearys' and unify function

* add analytic pvalues

* fix tests and docstring

* explicilty add leiden

* explicilty add leiden

* Fix tests

* resolve comments

* more fixes

* Add CI job

* Pass mode instead of function

* Force restore tox cache, fix not passing env var

* Pass backend as env

* Fix doc linting condition

* remove pysal from setup

* remaining comments, modify return excluding nan

* fix tests

* Fix docs, mypy, and some pet peeves

* Fix wrong requirement

* [ci skip] Remove doc linting

Co-authored-by: Michal Klein <michal.klein@protonmail.com>
  • Loading branch information
giovp and michalk8 committed Apr 9, 2021
1 parent 5a53dfd commit d8c20d7
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 127 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,12 @@ jobs:
with:
path: .tox
key: tox-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
tox-${{ runner.os }}-${{ env.pythonLocation }}-
tox-${{ runner.os }}-

- name: Testing
run: |
tox -vv
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42

Expand Down
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ disallow_any_generics = True
strict_optional = True
strict_equality = True
warn_return_any = True
warn_unreachable = True
warn_unreachable = False
check_untyped_defs = True
; because of docrep
allow_untyped_decorators = True
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default_stages:
minimum_pre_commit_version: 2.9.3
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.800
rev: v0.812
hooks:
- id: mypy
additional_dependencies: [numpy, scipy, pandas]
Expand All @@ -17,7 +17,7 @@ repos:
- id: black
additional_dependencies: [toml]
- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
rev: 5.8.0
hooks:
- id: isort
additional_dependencies: [toml]
Expand Down Expand Up @@ -61,12 +61,12 @@ repos:
- id: autoflake
args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.0
hooks:
- id: flake8
additional_dependencies: [flake8-tidy-imports, flake8-docstrings, flake8-rst-docstrings, flake8-comprehensions, flake8-bugbear, flake8-logging-format, flake8-blind-except, flake8-builtins, flake8-pytest-style, flake8-mock, flake8-string-format]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
rev: 2.1.5
hooks:
- id: script-must-have-extension
name: Check executable files use .sh extension
Expand All @@ -77,7 +77,7 @@ repos:
hooks:
- id: rstcheck
- repo: https://github.com/asottile/blacken-docs
rev: v1.9.2
rev: v1.10.0
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
Expand All @@ -87,7 +87,7 @@ repos:
- id: pyupgrade
args: [--py3-plus, --py37-plus]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
rev: v1.8.0
hooks:
- id: python-no-eval
- id: python-use-type-annotations
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Graph
gr.centrality_scores
gr.interaction_matrix
gr.ligrec
gr.moran
gr.spatial_autocorr
gr.ripley_k
gr.co_occurrence

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
pandas=("https://pandas.pydata.org/pandas-docs/stable/", None),
anndata=("https://anndata.readthedocs.io/en/stable/", None),
scanpy=("https://scanpy.readthedocs.io/en/stable/", None),
matplotlib=("https://matplotlib.org/", None),
matplotlib=("https://matplotlib.org/stable/", None),
seaborn=("https://seaborn.pydata.org/", None),
joblib=("https://joblib.readthedocs.io/en/latest/", None),
networkx=("https://networkx.org/documentation/stable/", None),
Expand Down
4 changes: 4 additions & 0 deletions docs/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def _download_dir(url: str, *, path: Union[str, Path], depth: int) -> Tuple[bool


def _download_notebooks(org: str, repo: str, raise_exc: bool = False) -> None:
if not int(os.environ.get("SQUIDPY_DOWNLOAD_NOTEBOOKS", 1)):
info("Not downloading notebooks because a flag is set")
return

ep = ENDPOINT_FMT.format(org=org, repo=repo)
for path in [FIXED_TUTORIALS_DIR, TUTORIALS_DIR, EXAMPLES_DIR, GENMOD_DIR]:
ok, reason = _download_dir(urljoin(ep, path), path=path, depth=DEPTH)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ anndata>=0.7.4
dask>=2.30
docrep>=0.3.1
ipywidgets>=7.5.1 # progress bar
leidenalg>=0.8.2
omnipath>=1.0.4
pandas>=1.2.0
rasterio>=1.1.8
scanpy[leiden]>=1.7.0
scanpy @ git+https://github.com/theislab/scanpy@master # scanpy[leiden]>=1.7.0
scikit-image>=0.17.1
statsmodels>=0.12.0
tifffile>=2020.10.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
if not l.startswith("-r")
],
interactive=["PyQt5>=5.15.0", "napari>=0.4.2"],
all=["PyQt5>=5.15.0", "napari>=0.4.2", "esda>=2.3.1", "libpysal>=4.3.0", "astropy>=4.1"],
all=["PyQt5>=5.15.0", "napari>=0.4.2", "astropy>=4.1"],
),
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
6 changes: 6 additions & 0 deletions squidpy/_constants/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ class DendrogramAxis(ModeEnum): # noqa: D101
class Symbol(ModeEnum): # noqa: D101
DISC = "disc"
SQUARE = "square"


@unique
class SpatialAutocorr(ModeEnum): # noqa: D101
MORAN = "moran"
GEARY = "geary"
2 changes: 1 addition & 1 deletion squidpy/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _unique_order_preserving(iterable: Iterable[Hashable]) -> Tuple[List[Hashabl


class Signal(Enum):
"""Signalling values when informing parallelizer."""
"""Signaling values when informing parallelizer."""

NONE = 0
UPDATE = 1
Expand Down
2 changes: 1 addition & 1 deletion squidpy/gr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from squidpy.gr._build import spatial_neighbors
from squidpy.gr._nhood import nhood_enrichment, centrality_scores, interaction_matrix
from squidpy.gr._ligrec import ligrec
from squidpy.gr._ppatterns import moran, ripley_k, co_occurrence
from squidpy.gr._ppatterns import ripley_k, co_occurrence, spatial_autocorr
Loading

0 comments on commit d8c20d7

Please sign in to comment.