diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61dc7c6a..ac9690cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,10 +4,10 @@ default_language_version: default_stages: - commit - push -minimum_pre_commit_version: 2.9.0 +minimum_pre_commit_version: 2.9.3 repos: - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.790 + rev: v0.800 hooks: - id: mypy additional_dependencies: [numpy>=1.15.0, scipy>=1.5.0, pandas] @@ -70,13 +70,13 @@ repos: - id: script-must-have-extension name: Check executable files use .sh extension types: [shell, executable] - - id: shellcheck +# - id: shellcheck # TODO: The hook `shellcheck` specifies `additional_dependencies` but is using language `script` which does not install an environment. Perhaps you meant to use a specific language? - repo: https://github.com/myint/rstcheck - rev: master + rev: 3f92957478422df87bd730abde66f089cc1ee19b hooks: - id: rstcheck - repo: https://github.com/asottile/blacken-docs - rev: v1.9.1 + rev: v1.9.2 hooks: - id: blacken-docs additional_dependencies: [black==20.8b1] diff --git a/.rstcheck.cfg b/.rstcheck.cfg index 9f31d855..e6d17658 100644 --- a/.rstcheck.cfg +++ b/.rstcheck.cfg @@ -1,3 +1,3 @@ [rstcheck] -ignore_messages=Unknown target name:.*|No (directive|role) entry for "(auto)?(class|method|property|function|func|mod|module)" in module "docutils\.parsers\.rst\.languages\.en"\. +ignore_messages=Unknown target name:.*|No (directive|role) entry for "(auto)?(bibliography|class|method|property|function|func|mod|module)" in module "docutils\.parsers\.rst\.languages\.en"\. report=info diff --git a/docs/requirements.txt b/docs/requirements.txt index edbb3055..9a84a20f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,3 +6,4 @@ sphinx-autodoc-typehints>=1.10.3 sphinx_gallery sphinx_last_updated_by_git sphinx_rtd_theme +sphinxcontrib-bibtex>=2.1.0 diff --git a/docs/source/conf.py b/docs/source/conf.py index d864837c..b7203389 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -49,6 +49,7 @@ "sphinx.ext.autosummary", "sphinx_last_updated_by_git", "sphinx_gallery.load_style", + "sphinxcontrib.bibtex", "edit_on_github", "typed_returns", ] @@ -63,7 +64,7 @@ matplotlib=("https://matplotlib.org/", None), seaborn=("https://seaborn.pydata.org/", None), joblib=("https://joblib.readthedocs.io/en/latest/", None), - networkx=("https://networkx.github.io/documentation/stable/", None), + networkx=("https://networkx.org/documentation/stable", None), astropy=("https://docs.astropy.org/en/stable/", None), esda=("https://pysal.org/esda/", None), dask=("https://docs.dask.org/en/latest/", None), @@ -109,6 +110,10 @@ # 403 Client Error: Forbidden for url: https://www.jstor.org/stable/2332142?origin=crossref linkcheck_ignore = ["https://doi.org/10.2307/2332142"] +bibtex_bibfiles = ["references.bib"] +bibtex_reference_style = ["author_year"] +bibtex_default_style = "alpha" + # 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". diff --git a/docs/source/index.rst b/docs/source/index.rst index dd5f9c2a..655a3c36 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -29,7 +29,6 @@ Squidpy auto_examples/index.rst - .. |PyPI| image:: https://img.shields.io/pypi/v/squidpy.svg :target: https://img.shields.io/pypi/v/squidpy.svg :alt: PyPI diff --git a/docs/source/references.bib b/docs/source/references.bib new file mode 100644 index 00000000..981418e4 --- /dev/null +++ b/docs/source/references.bib @@ -0,0 +1,51 @@ +@article {celloracle, + author = {Kamimoto, Kenji and Hoffmann, Christy M. and Morris, Samantha A.}, + title = {CellOracle: Dissecting cell identity via network inference and in silico gene perturbation}, + journal = {bioRxiv}, + year = {2020}, + publisher = {Cold Spring Harbor Laboratory}, + doi = {10.1101/2020.02.17.947416} +} + +@article{cellphonedb, + author={Efremova, Mirjana and Vento-Tormo, Miquel and Teichmann, Sarah A and Vento-Tormo, Roser}, + title={CellPhoneDB: inferring cell--cell communication from combined expression of multi-subunit ligand--receptor complexes}, + journal={Nature protocols}, + year={2020}, + volume={15}, + number={4}, + pages={1484--1506}, + publisher={Nature Publishing Group}, + doi = {10.1038/s41596-020-0292-x} +} + +@incollection{pysal, + title={PySAL: A Python library of spatial analytical methods}, + author={Rey, Sergio J and Anselin, Luc}, + booktitle={Handbook of applied spatial analysis}, + pages={175--193}, + year={2010}, + publisher={Springer}, + doi = {10.1007/978-3-642-03647-7_11} +} + +@article{omnipath, + title={OmniPath: guidelines and gateway for literature-curated signaling pathway resources}, + author={T{\"u}rei, D{\'e}nes and Korcsm{\'a}ros, Tam{\'a}s and Saez-Rodriguez, Julio}, + journal={Nature methods}, + year={2016}, + volume={13}, + number={12}, + pages={966--967}, + publisher={Nature Publishing Group}, + doi = {10.1038/nmeth.4077} +} + +@techreport{networkx, + title={Exploring network structure, dynamics, and function using NetworkX}, + author={Hagberg, Aric and Swart, Pieter and S Chult, Daniel}, + year={2008}, + place = {United States}, + institution={Los Alamos National Lab.(LANL), Los Alamos, NM (United States)}, + URL = {https://www.osti.gov/biblio/960616}, +} diff --git a/docs/source/references.rst b/docs/source/references.rst index 84591d9e..4497b53a 100644 --- a/docs/source/references.rst +++ b/docs/source/references.rst @@ -1,32 +1,5 @@ -.. |br| raw:: html - -
- References ----------- - -.. [CellOracle20] - Kamimoto, K., Hoffmann, C. M, Morris, S. A., |br| - *Dissecting cell identity via network inference and in silico gene perturbation*, |br| - `bioRxiv 2020.02.17.947416 `__. - -.. [CellPhoneDB20] Efremova, M., Vento-Tormo, M., Teichmann, S. A. et al., |br| - *CellPhoneDB: inferring cell–cell communication from combined expression of multi-subunit - ligand–receptor complexes.*, |br| - `Nat Protoc 15, 1484–1506 (2020) `__. - -.. [Moran50] Rey, Sergio J. and Anselin, Luc, |br| - *PySAL: A Python Library of Spatial Analytical Methods*, |br| - `The Review of Regional Studies, vol. 37, 1, 2007, pp. 17–23 `__. - -.. [OmniPath16] Türei, D., Korcsmáros, T., Saez-Rodriguez, J., |br| - *OmniPath: guidelines and gateway for literature-curated signaling pathway resources.*, |br| - `Nat Methods 13, 966–967 (2016) `__. - -.. [Visium] 10X Genomics |br| - `Visium `__. +========== -.. [NetworkX08] - Aric A. Hagberg, Daniel A. Schult and Pieter J. Swart, |br| - *Exploring Network Structure, Dynamics, and Function using NetworkX*, |br| - `SciPyProceedings_11 2008 `__. +.. bibliography:: + :cited: diff --git a/squidpy/gr/_ligrec.py b/squidpy/gr/_ligrec.py index f4e425e9..2becc7ce 100644 --- a/squidpy/gr/_ligrec.py +++ b/squidpy/gr/_ligrec.py @@ -231,8 +231,8 @@ def prepare( complex_policy Policy on how to handle complexes. Valid options are: - - `{cp.MIN.s!r}` - select gene with the minimum average expression. - This is the same as in [CellPhoneDB20]_. + - `{cp.MIN.s!r}` - select gene with the minimum average expression. This is the same as in + :cite:`cellphonedb`. - `{cp.ALL.s!r}` - select all possible combinations between `{src!r}` and `{tgt!r}` complexes. Returns @@ -320,7 +320,7 @@ def test( **kwargs: Any, ) -> Optional[LigrecResult]: """ - Perform the permutation test as described in [CellPhoneDB20]_. + Perform the permutation test as described in :cite:`cellphonedb`. Parameters ---------- @@ -483,7 +483,7 @@ def _filter_interactions_complexes(self, complex_policy: ComplexPolicy) -> None: Policy on how to handle complexes. Valid options are: - `{cp.MIN.s!r}` - select gene with the minimum average expression. This is the same as in - [CellPhoneDB20]_. + :cite:`cellphonedb`. - `{cp.ALL.s!r}` - select all possible combinations between `{src!r}` and `{tgt!r}` complexes. Returns @@ -571,7 +571,8 @@ def prepare( %(PT_prepare.parameters)s interactions_params Keyword arguments for :func:`omnipath.interactions.import_intercell_network` defining the interactions. - These datasets from [OmniPath16]_ are default: `omnipath`, `pathwayextra`, `kinaseextra`, `ligrecextra`. + These datasets from :cite:`omnipath` are used by default: `omnipath`, `pathwayextra`, `kinaseextra` and + `ligrecextra`. transmitter_params Keyword arguments for :func:`omnipath.interactions.import_intercell_network` defining the transmitter side of intercellular connections. @@ -668,7 +669,7 @@ def _analysis( **kwargs: Any, ) -> TempResult: """ - Run the analysis as described in [CellPhoneDB20]_. + Run the analysis as described in :cite:`cellphonedb`. This function runs the mean, percent and shuffled analysis. diff --git a/squidpy/gr/build.py b/squidpy/gr/build.py index 32b9d8b5..ba145ebe 100644 --- a/squidpy/gr/build.py +++ b/squidpy/gr/build.py @@ -38,13 +38,13 @@ def spatial_neighbors( coord_type Type of coordinate system. Can be one of the following: - - `{c.VISIUM!r}`: [Visium]_ coordinates. + - `{c.VISIUM!r}`: Visium coordinates. - `{c.GENERIC!r}`: generic coordinates. If `None`, use `{c.VISIUM!r}` if ``spatial_key`` is present in :attr:`anndata.AnnData.obsm`, otherwise use `{c.GENERIC!r}`. n_rings - Number of rings of neighbors for [Visium]_ data. + Number of rings of neighbors for Visium data. n_neigh Number of neighborhoods to consider for non-Visium data. radius diff --git a/squidpy/gr/nhood.py b/squidpy/gr/nhood.py index 2b0399bb..f6a31c00 100644 --- a/squidpy/gr/nhood.py +++ b/squidpy/gr/nhood.py @@ -190,14 +190,14 @@ def centrality_scores( """ Compute centrality scores per cluster or cell type. - Inspired by usage in Gene Regulatory Networks (GRNs) in [CellOracle20]_. + Inspired by usage in Gene Regulatory Networks (GRNs) in :cite:`celloracle`. Parameters ---------- %(adata)s %(cluster_key)s score - Centrality measures as described in :class:`networkx.algorithms.centrality` [NetworkX08]_. + Centrality measures as described in :class:`networkx.algorithms.centrality` :cite:`networkx`. If `None`, use all the options below. Valid options are: - `{c.CLOSENESS.s!r}` - measure of how close the group is to other nodes. diff --git a/squidpy/gr/ppatterns.py b/squidpy/gr/ppatterns.py index 6696552b..e1a1e4b2 100644 --- a/squidpy/gr/ppatterns.py +++ b/squidpy/gr/ppatterns.py @@ -159,10 +159,10 @@ def moran( %(conn_key)s genes List of gene names, as stored in :attr:`anndata.AnnData.var_names`, used to compute Moran's I statistics - [Moran50]_. + :cite:`pysal`. - If `None`, it's computed for `'highly_variable'` in :attr:`anndata.AnnData.var`, if present. - Otherwise, it's computed for all genes. + If `None`, it's computed :attr:`anndata.AnnData.var` ``['highly_variable']``, if present. Otherwise, + it's computed for all genes. transformation Transformation to be used, as reported in :class:`esda.Moran`. Default is `"B"`, binary. %(n_perms)s diff --git a/squidpy/im/object.py b/squidpy/im/object.py index b8ae95d5..be9d32ca 100644 --- a/squidpy/im/object.py +++ b/squidpy/im/object.py @@ -574,7 +574,7 @@ def interactive( Interactive view of this container. Screenshot of the canvas can be taken by :meth:`squidpy.pl.Interactive.screenshot`. """ - from squidpy.pl import Interactive + from squidpy.pl import Interactive # type: ignore[attr-defined] return Interactive( # type: ignore[no-any-return] img=self, diff --git a/squidpy/pl/_interactive/_controller.py b/squidpy/pl/_interactive/_controller.py index b4f5ddd2..e8774ec2 100644 --- a/squidpy/pl/_interactive/_controller.py +++ b/squidpy/pl/_interactive/_controller.py @@ -15,7 +15,7 @@ from squidpy.im import ImageContainer # type: ignore[attr-defined] from squidpy._docs import d -from squidpy._utils import singledispatchmethod +from squidpy._utils import singledispatchmethod # type: ignore[attr-defined] from squidpy.pl._utils import _points_inside_triangles from squidpy.pl._interactive._view import ImageView from squidpy.pl._interactive._model import ImageModel diff --git a/tox.ini b/tox.ini index b29d4b45..129ae58b 100644 --- a/tox.ini +++ b/tox.ini @@ -42,6 +42,7 @@ rst-roles = attr paramref ref + cite rst-directives = envvar exception @@ -155,7 +156,7 @@ commands = [testenv:lint] description = Perform linting. basepython = python3.8 -deps = pre-commit>=2.9.0 +deps = pre-commit>=2.9.3 skip_install = true commands = pre-commit run --all-files --show-diff-on-failure {posargs:}