From 77e6b49e192ae0a8f7588c89d2b3fecaae90db64 Mon Sep 17 00:00:00 2001 From: Philipp Weiler Date: Tue, 1 Oct 2024 15:19:21 +0200 Subject: [PATCH] Update docs (#1279) * Update `conf.py` Update to latest sphinx version. * Update vignette index * Update docstrings Replace `Arguments:` by `Parameters` * Remove redundant import Removes `pca` which is merely imported from and defined in Scanpy. * Update `perspectives/index.rst` Fix notebook linking. * Update index page - Remove reference to veloVI. - Update bibtex references * Update references - Update list of references. - Use consistent ID `AuthorYY` for references. - Properly cite papers in docstrings. * Update `docs/api.rst` - Remove `pca`. - Add empty line for consistent formatting. * Update `conf.py` Refactor sphinx config. * Update `set_figure_params` Update type hint of argument `format`. * Fix unit tests Fix import of removed `pca` function. * Update `getting_started.rst` Update docs according to latest changes; The syntax `scv.read` no longer works and needs to be used with Scanpy directly. * Update `pyproject.toml` --- docs/source/api.rst | 2 +- docs/source/conf.py | 408 +++---------------- docs/source/getting_started.rst | 7 +- docs/source/index.rst | 7 +- docs/source/perspectives/index.rst | 4 +- docs/source/references.bib | 139 +++++-- docs/source/vignettes/index.rst | 14 +- pyproject.toml | 5 +- scvelo/core/_anndata.py | 60 +-- scvelo/core/_arithmetic.py | 20 +- scvelo/core/_linear_models.py | 4 +- scvelo/core/_metrics.py | 4 +- scvelo/core/_models.py | 4 +- scvelo/datasets/_datasets.py | 34 +- scvelo/inference/_metabolic_labeling.py | 50 +-- scvelo/plotting/heatmap.py | 4 +- scvelo/plotting/paga.py | 4 +- scvelo/plotting/proportions.py | 4 +- scvelo/plotting/scatter.py | 4 +- scvelo/plotting/utils.py | 8 +- scvelo/plotting/velocity.py | 4 +- scvelo/plotting/velocity_embedding.py | 4 +- scvelo/plotting/velocity_embedding_grid.py | 4 +- scvelo/plotting/velocity_embedding_stream.py | 4 +- scvelo/plotting/velocity_graph.py | 4 +- scvelo/preprocessing/__init__.py | 3 +- scvelo/preprocessing/moments.py | 18 +- scvelo/preprocessing/neighbors.py | 6 +- scvelo/preprocessing/utils.py | 4 +- scvelo/settings.py | 6 +- scvelo/tools/_em_model_core.py | 18 +- scvelo/tools/_em_model_utils.py | 4 +- scvelo/tools/rank_velocity_genes.py | 4 +- scvelo/tools/score_genes_cell_cycle.py | 2 +- scvelo/tools/terminal_states.py | 12 +- scvelo/tools/transition_matrix.py | 8 +- scvelo/tools/utils.py | 4 +- scvelo/tools/velocity.py | 8 +- scvelo/tools/velocity_confidence.py | 8 +- scvelo/tools/velocity_embedding.py | 4 +- scvelo/tools/velocity_graph.py | 4 +- scvelo/tools/velocity_pseudotime.py | 8 +- tests/core/test_base.py | 4 +- tests/test_basic.py | 8 +- 44 files changed, 369 insertions(+), 570 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 5db5ff1b..65192462 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -33,7 +33,6 @@ Preprocessing (pp) .. autosummary:: :toctree: . - pp.pca pp.neighbors pp.moments @@ -86,6 +85,7 @@ Tools (tl) tl.velocity_confidence tl.score_genes_cell_cycle + Inference from metabolic labeling information --------- diff --git a/docs/source/conf.py b/docs/source/conf.py index 3b3f9a8c..9c48db50 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,143 +1,63 @@ -import inspect +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- import logging -import os import sys from datetime import datetime -from pathlib import Path, PurePosixPath -from typing import Dict, List, Mapping, Optional, Tuple, Union +from pathlib import Path from urllib.error import URLError from urllib.request import urlretrieve -import sphinx_autodoc_typehints -from docutils import nodes -from jinja2.defaults import DEFAULT_FILTERS -from sphinx import addnodes -from sphinx.application import Sphinx -from sphinx.domains.python import PyObject, PyTypedField -from sphinx.environment import BuildEnvironment -from sphinx.ext import autosummary - -import matplotlib - -HERE = Path(__file__).parent -sys.path.insert(0, str(HERE.parent.parent)) -sys.path.insert(0, os.path.abspath("_ext")) - -import scvelo # isort:skip # noqa E402 - -# remove PyCharm’s old six module +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +import scvelo -if "six" in sys.modules: - print(*sys.path, sep="\n") - for pypath in list(sys.path): - if any(p in pypath for p in ["PyCharm", "pycharm"]) and "helpers" in pypath: - sys.path.remove(pypath) - del sys.modules["six"] - -matplotlib.use("agg") +sys.path.insert(0, str(Path(__file__).parent / "_ext")) logger = logging.getLogger(__name__) +# -- Project information ----------------------------------------------------- +project = "scVelo" +author = "Volker Bergen, Philipp Weiler" +version = scvelo.__version__.replace(".dirty", "") +copyright = f"{datetime.now():%Y}, Theislab" -# -- Basic notebooks and those stored under /vignettes and /perspectives -- - -notebooks_url = "https://github.com/theislab/scvelo_notebooks/raw/master/" -notebooks = [] -notebook = [ - "VelocityBasics.ipynb", - "DynamicalModeling.ipynb", - "DifferentialKinetics.ipynb", -] -notebooks.extend(notebook) - -notebook = [ - "Pancreas.ipynb", - "DentateGyrus.ipynb", - "NatureBiotechCover.ipynb", - "Fig1_concept.ipynb", - "Fig2_dentategyrus.ipynb", - "Fig3_pancreas.ipynb", - "FigS9_runtime.ipynb", - "FigSuppl.ipynb", -] -notebooks.extend([f"vignettes/{nb}" for nb in notebook]) - -notebook = ["Perspectives.ipynb", "Perspectives_parameters.ipynb"] -notebooks.extend([f"perspectives/{nb}" for nb in notebook]) - -# -- Retrieve all notebooks -- - -for nb in notebooks: - url = notebooks_url + nb - try: - urlretrieve(url, nb) - except URLError as e: - logger.error(f"Unable to retrieve notebook: `{url}`. Reason: `{e}`") - - -# -- General configuration ------------------------------------------------ - -needs_sphinx = "1.7" +# -- General configuration --------------------------------------------------- +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. extensions = [ "sphinx.ext.autodoc", - "sphinx.ext.doctest", - "sphinx.ext.coverage", - "sphinx.ext.mathjax", - "sphinx.ext.autosummary", "sphinx.ext.napoleon", + "sphinx.ext.mathjax", "sphinx.ext.intersphinx", + "sphinx.ext.autosummary", + "sphinxcontrib.bibtex", + "sphinx.ext.doctest", + "sphinx.ext.coverage", "sphinx.ext.githubpages", + "edit_on_github", "sphinx_autodoc_typehints", "nbsphinx", - "edit_on_github", - "sphinxcontrib.bibtex", ] - -# Generate the API documentation when building -autosummary_generate = True -napoleon_google_docstring = False -napoleon_numpy_docstring = True -napoleon_include_init_with_doc = False -napoleon_use_rtype = False -napoleon_custom_sections = [("Params", "Parameters")] - intersphinx_mapping = { "python": ("https://docs.python.org/3", None), "anndata": ("https://anndata.readthedocs.io/en/latest/", None), "scanpy": ("https://scanpy.readthedocs.io/en/latest/", None), "cellrank": ("https://cellrank.readthedocs.io/en/latest/", None), } - -templates_path = ["_templates"] -source_suffix = [".rst", ".ipynb"] master_doc = "index" - -# General information about the project. -project = "scVelo" -author = "Volker Bergen" -title = "RNA Velocity generalized through dynamical modeling" -copyright = f"{datetime.now():%Y}, {author}" - -version = scvelo.__version__.replace(".dirty", "") -release = version -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] pygments_style = "sphinx" -todo_include_todos = False - -# Add notebooks prolog to Google Colab and nbviewer -nbsphinx_prolog = r""" -{% set docname = 'github/theislab/scvelo_notebooks/blob/master/' + env.doc2path(env.docname, base=None) %} -.. raw:: html +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"] -
- - Open In Colab - - Open In nbviewer -
-""" +nitpicky = True # bibliography bibtex_bibfiles = ["references.bib"] @@ -151,251 +71,37 @@ github_nb_repo = "scvelo_notebooks" html_static_path = ["_static"] +# -- Basic notebooks and those stored under /vignettes and /perspectives -- -# TODO: Add docstrings -def setup(app): - """TODO.""" - app.add_css_file("custom.css") - - -# -- Options for other output ------------------------------------------ - -htmlhelp_basename = "scvelodoc" -title_doc = f"{project} documentation" - -latex_documents = [(master_doc, f"{project}.tex", title_doc, author, "manual")] -man_pages = [(master_doc, project, title_doc, [author], 1)] -texinfo_documents = [ - (master_doc, project, title_doc, author, project, title, "Miscellaneous") +notebooks_url = "https://github.com/theislab/scvelo_notebooks/raw/master/" +notebooks = [] +notebook = [ + "VelocityBasics.ipynb", + "DynamicalModeling.ipynb", + "DifferentialKinetics.ipynb", ] +notebooks.extend(notebook) +notebook = [ + "Pancreas.ipynb", + "DentateGyrus.ipynb", + "NatureBiotechCover.ipynb", + "Fig1_concept.ipynb", + "Fig2_dentategyrus.ipynb", + "Fig3_pancreas.ipynb", + "FigS9_runtime.ipynb", + "FigSuppl.ipynb", +] +notebooks.extend([f"vignettes/{nb}" for nb in notebook]) -# -- generate_options override ------------------------------------------ - - -# TODO: Add docstrings -def process_generate_options(app: Sphinx): - """TODO.""" - genfiles = app.config.autosummary_generate - - if genfiles and not hasattr(genfiles, "__len__"): - env = app.builder.env - genfiles = [ - env.doc2path(x, base=None) - for x in env.found_docs - if Path(env.doc2path(x)).is_file() - ] - if not genfiles: - return - - from sphinx.ext.autosummary.generate import generate_autosummary_docs - - ext = app.config.source_suffix - genfiles = [ - genfile + (not genfile.endswith(tuple(ext)) and ext[0] or "") - for genfile in genfiles - ] - - suffix = autosummary.get_rst_suffix(app) - if suffix is None: - return - - generate_autosummary_docs( - genfiles, - builder=app.builder, - warn=logger.warning, - info=logger.info, - suffix=suffix, - base_path=app.srcdir, - imported_members=True, - app=app, - ) - - -autosummary.process_generate_options = process_generate_options - - -# -- GitHub URLs for class and method pages ------------------------------------------ - - -# TODO: Finish docstrings -def get_obj_module(qualname): - """Get a module/class/attribute and its original module by qualname.""" - modname = qualname - classname = None - attrname = None - while modname not in sys.modules: - attrname = classname - modname, classname = modname.rsplit(".", 1) - - # retrieve object and find original module name - if classname: - cls = getattr(sys.modules[modname], classname) - modname = cls.__module__ - obj = getattr(cls, attrname) if attrname else cls - else: - obj = None - - return obj, sys.modules[modname] - - -# TODO: Finish docstrings -def get_linenos(obj): - """Get an object’s line numbers.""" - try: - lines, start = inspect.getsourcelines(obj) - except TypeError: - return None, None - else: - return start, start + len(lines) - 1 - - -# set project_dir: project/docs/source/conf.py/../../.. → project/ -project_dir = Path(__file__).parent.parent.parent -github_url_scvelo = "https://github.com/theislab/scvelo/tree/main" -github_url_read_loom = "https://github.com/theislab/anndata/tree/master/anndata" -github_url_read = "https://github.com/theislab/scanpy/tree/master" -github_url_scanpy = "https://github.com/theislab/scanpy/tree/master/scanpy" +notebook = ["Perspectives.ipynb", "Perspectives_parameters.ipynb"] +notebooks.extend([f"perspectives/{nb}" for nb in notebook]) +# -- Retrieve all notebooks -- -# TODO: Finish docstrings -def modurl(qualname): - """Get the full GitHub URL for some object’s qualname.""" - obj, module = get_obj_module(qualname) - github_url = github_url_scvelo +for nb in notebooks: + url = notebooks_url + nb try: - path = PurePosixPath(Path(module.__file__).resolve().relative_to(project_dir)) - except ValueError: - # trying to document something from another package - github_url = ( - github_url_read_loom - if "read_loom" in qualname - else github_url_read - if "read" in qualname - else github_url_scanpy - ) - path = "/".join(module.__file__.split("/")[-2:]) - start, end = get_linenos(obj) - fragment = f"#L{start}-L{end}" if start and end else "" - return f"{github_url}/{path}{fragment}" - - -# TODO: Add docstrings -def api_image(qualname: str) -> Optional[str]: - """TODO.""" - path = Path(__file__).parent / f"{qualname}.png" - print(path, path.is_file()) - return ( - f".. image:: {path.name}\n :width: 200\n :align: right" - if path.is_file() - else "" - ) - - -# modify the default filters - -DEFAULT_FILTERS.update(modurl=modurl, api_image=api_image) - -# -- Override some classnames in autodoc -------------------------------------------- - -qualname_overrides = { - "anndata.base.AnnData": "anndata.AnnData", - "scvelo.pl.scatter": "scvelo.plotting.scatter", -} - -fa_orig = sphinx_autodoc_typehints.format_annotation - - -# TODO: Add docstrings -def format_annotation(annotation): - """TODO.""" - if getattr(annotation, "__origin__", None) is Union or hasattr( - annotation, "__union_params__" - ): - params = getattr(annotation, "__union_params__", None) or getattr( - annotation, "__args__", None - ) - return ", ".join(map(format_annotation, params)) - if getattr(annotation, "__origin__", None) is Mapping: - return ":class:`~typing.Mapping`" - if inspect.isclass(annotation): - full_name = f"{annotation.__module__}.{annotation.__qualname__}" - override = qualname_overrides.get(full_name) - if override is not None: - return f":py:class:`~{qualname_overrides[full_name]}`" - return fa_orig(annotation) - - -sphinx_autodoc_typehints.format_annotation = format_annotation - - -# -- Prettier Param docs -------------------------------------------- - - -# TODO: Add docstrings -class PrettyTypedField(PyTypedField): - """TODO.""" - - list_type = nodes.definition_list - - # TODO: Add docstrings - def make_field( - self, - types: Dict[str, List[nodes.Node]], - domain: str, - items: Tuple[str, List[nodes.inline]], - env: BuildEnvironment = None, - ) -> nodes.field: - """TODO.""" - - def makerefs(rolename, name, node): - return self.make_xrefs(rolename, domain, name, node, env=env) - - def handle_item( - fieldarg: str, content: List[nodes.inline] - ) -> nodes.definition_list_item: - head = nodes.term() - head += makerefs(self.rolename, fieldarg, addnodes.literal_strong) - fieldtype = types.pop(fieldarg, None) - if fieldtype is not None: - head += nodes.Text(" : ") - if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text): - (text_node,) = fieldtype # type: nodes.Text - head += makerefs( - self.typerolename, text_node.astext(), addnodes.literal_emphasis - ) - else: - head += fieldtype - - body_content = nodes.paragraph("", "", *content) - body = nodes.definition("", body_content) - - return nodes.definition_list_item("", head, body) - - fieldname = nodes.field_name("", self.label) - if len(items) == 1 and self.can_collapse: - fieldarg, content = items[0] - bodynode = handle_item(fieldarg, content) - else: - bodynode = self.list_type() - for fieldarg, content in items: - bodynode += handle_item(fieldarg, content) - fieldbody = nodes.field_body("", bodynode) - return nodes.field("", fieldname, fieldbody) - - -# replace matching field types with ours -PyObject.doc_field_types = [ - PrettyTypedField( - ft.name, - names=ft.names, - typenames=ft.typenames, - label=ft.label, - rolename=ft.rolename, - typerolename=ft.typerolename, - can_collapse=ft.can_collapse, - ) - if isinstance(ft, PyTypedField) - else ft - for ft in PyObject.doc_field_types -] + urlretrieve(url, nb) + except URLError as e: + logger.error(f"Unable to retrieve notebook: `{url}`. Reason: `{e}`") diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index bcba545d..1d96d086 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -11,8 +11,9 @@ counting pipeline. scVelo workflow at a glance ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Import scvelo as:: +Import Scanpy and scvelo as:: + import scanpy as sc import scvelo as scv For beautified visualization you can change the matplotlib settings to our defaults with:: @@ -23,7 +24,7 @@ Read your data '''''''''''''' Read your data file (loom, h5ad, csv, ...) using:: - adata = scv.read(filename, cache=True) + adata = sc.read(filename, cache=True) which stores the data matrix (``adata.X``), annotation of cells / observations (``adata.obs``) and genes / variables (``adata.var``), unstructured annotation such @@ -35,7 +36,7 @@ as graphs (``adata.uns``) and additional data layers where spliced and unspliced If you already have an existing preprocessed adata object you can simply merge the spliced/unspliced counts via:: - ldata = scv.read(filename.loom, cache=True) + ldata = sc.read(filename.loom, cache=True) adata = scv.utils.merge(adata, ldata) If you do not have a datasets yet, you can still play around using one of the in-built datasets, e.g.:: diff --git a/docs/source/index.rst b/docs/source/index.rst index 41a4331b..7298f830 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -13,8 +13,7 @@ scVelo - RNA velocity generalized through dynamical modeling enables the recovery of directed dynamic information by leveraging splicing kinetics :cite:p:`LaManno18`. scVelo collects different methods for inferring RNA velocity using an expectation-maximization framework -:cite:p:`Bergen20`, deep generative modeling :cite:p:`Gayoso2023`, -or metabolically labeled transcripts :cite:p:`Weiler2024`. +:cite:p:`Bergen20` or metabolically labeled transcripts :cite:p:`Weiler24`. scVelo's key applications ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +48,7 @@ If you use the *EM* (*dynamical*) or *steady-state model*, cite author = {Bergen, Volker and Lange, Marius and Peidli, Stefan and Wolf, F. Alexander and Theis, Fabian J.}, year = {2020}, month = aug, - pages = {1408–1414} + pages = {1408-1414} } **RNA velocity inference through metabolic labeling information** @@ -68,7 +67,7 @@ information, cite journal = {Nature Methods}, month = jun, number = {7}, - pages = {1196--1205}, + pages = {1196-1205}, title = {CellRank 2: unified fate mapping in multiview single-cell data}, volume = {21}, year = {2024}, diff --git a/docs/source/perspectives/index.rst b/docs/source/perspectives/index.rst index 0767bc45..579b499f 100644 --- a/docs/source/perspectives/index.rst +++ b/docs/source/perspectives/index.rst @@ -19,7 +19,7 @@ Potential pitfalls This notebook reproduces Fig. 2 with several use cases, including multiple kinetics in Dentate Gyrus, transcriptional boost in erythroid lineage, and misleading arrow projections in mature PBMCs. -Notebook: `Perspectives `_ +Notebook: :doc:`Perspectives ` Kinetic parameter analysis ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,4 +30,4 @@ Kinetic parameter analysis This notebook reproduces Fig. 3, where we demonstrate how time-variable kinetic rates shape the curvature patterns of gene activation. -Notebook: `Kinetic parameter analysis `_ +Notebook: :doc:`Kinetic parameter analysis ` diff --git a/docs/source/references.bib b/docs/source/references.bib index bbfd5783..8be9262c 100644 --- a/docs/source/references.bib +++ b/docs/source/references.bib @@ -1,3 +1,18 @@ +@article{BastidasPonce19, + title = {Comprehensive single cell mRNA profiling reveals a detailed roadmap for pancreatic endocrinogenesis}, + volume = {146}, + ISSN = {0950-1991}, + url = {http://dx.doi.org/10.1242/dev.173849}, + DOI = {10.1242/dev.173849}, + number = {12}, + journal = {Development}, + publisher = {The Company of Biologists}, + author = {Bastidas-Ponce, Aimée and Tritschler, Sophie and Dony, Leander and Scheibner, Katharina and Tarquis-Medina, Marta and Salinno, Ciro and Schirge, Silvia and Burtscher, Ingo and B\"{o}ttcher, Anika and Theis, Fabian J. and Lickert, Heiko and Bakhti, Mostafa}, + editor = {Klein, Allon and Treutlein, Barbara}, + year = {2019}, + month = jun +} + @article{Bergen20, doi = {10.1038/s41587-020-0591-3}, url = {https://doi.org/10.1038/s41587-020-0591-3}, @@ -12,6 +27,36 @@ @article{Bergen20 journal = {Nature Biotechnology} } +@article{Haghverdi16, + title = {Diffusion pseudotime robustly reconstructs lineage branching}, + volume = {13}, + ISSN = {1548-7105}, + url = {http://dx.doi.org/10.1038/nmeth.3971}, + DOI = {10.1038/nmeth.3971}, + number = {10}, + journal = {Nature Methods}, + publisher = {Springer Science and Business Media LLC}, + author = {Haghverdi, Laleh and B\"{u}ttner, Maren and Wolf, F Alexander and Buettner, Florian and Theis, Fabian J}, + year = {2016}, + month = aug, + pages = {845-848} +} + +@article{Hochgerner18, + title = {Conserved properties of dentate gyrus neurogenesis across postnatal development revealed by single-cell RNA sequencing}, + volume = {21}, + ISSN = {1546-1726}, + url = {http://dx.doi.org/10.1038/s41593-017-0056-2}, + DOI = {10.1038/s41593-017-0056-2}, + number = {2}, + journal = {Nature Neuroscience}, + publisher = {Springer Science and Business Media LLC}, + author = {Hochgerner, Hannah and Zeisel, Amit and L\"{o}nnerberg, Peter and Linnarsson, Sten}, + year = {2018}, + month = jan, + pages = {290-299} +} + @article{LaManno18, doi = {10.1038/s41586-018-0414-6}, url = {https://doi.org/10.1038/s41586-018-0414-6}, @@ -37,6 +82,66 @@ @article{McInnes18 copyright = {arXiv.org perpetual, non-exclusive license} } +@article{PijuanSala19, + title = {A single-cell molecular map of mouse gastrulation and early organogenesis}, + volume = {566}, + ISSN = {1476-4687}, + url = {http://dx.doi.org/10.1038/s41586-019-0933-9}, + DOI = {10.1038/s41586-019-0933-9}, + number = {7745}, + journal = {Nature}, + publisher = {Springer Science and Business Media LLC}, + author = {Pijuan-Sala, Blanca and Griffiths, Jonathan A. and Guibentif, Carolina and Hiscock, Tom W. and Jawaid, Wajid and Calero-Nieto, Fernando J. and Mulas, Carla and Ibarra-Soria, Ximena and Tyser, Richard C. V. and Ho, Debbie Lee Lian and Reik, Wolf and Srinivas, Shankar and Simons, Benjamin D. and Nichols, Jennifer and Marioni, John C. and G\"{o}ttgens, Berthold}, + year = {2019}, + month = feb, + pages = {490-495} +} + +@article{Setty19, + title = {Characterization of cell fate probabilities in single-cell data with Palantir}, + volume = {37}, + ISSN = {1546-1696}, + url = {http://dx.doi.org/10.1038/s41587-019-0068-4}, + DOI = {10.1038/s41587-019-0068-4}, + number = {4}, + journal = {Nature Biotechnology}, + publisher = {Springer Science and Business Media LLC}, + author = {Setty, Manu and Kiseliovas, Vaidotas and Levine, Jacob and Gayoso, Adam and Mazutis, Linas and Pe’er, Dana}, + year = {2019}, + month = mar, + pages = {451-460} +} + +@article{Tirosh16, + title = {Dissecting the multicellular ecosystem of metastatic melanoma by single-cell RNA-seq}, + volume = {352}, + ISSN = {1095-9203}, + url = {http://dx.doi.org/10.1126/science.aad0501}, + DOI = {10.1126/science.aad0501}, + number = {6282}, + journal = {Science}, + publisher = {American Association for the Advancement of Science (AAAS)}, + author = {Tirosh, Itay and Izar, Benjamin and Prakadan, Sanjay M. and Wadsworth, Marc H. and Treacy, Daniel and Trombetta, John J. and Rotem, Asaf and Rodman, Christopher and Lian, Christine and Murphy, George and Fallahi-Sichani, Mohammad and Dutton-Regester, Ken and Lin, Jia-Ren and Cohen, Ofir and Shah, Parin and Lu, Diana and Genshaft, Alex S. and Hughes, Travis K. and Ziegler, Carly G. K. and Kazer, Samuel W. and Gaillard, Aleth and Kolb, Kellie E. and Villani, Alexandra-Chloé and Johannessen, Cory M. and Andreev, Aleksandr Y. and Van Allen, Eliezer M. and Bertagnolli, Monica and Sorger, Peter K. and Sullivan, Ryan J. and Flaherty, Keith T. and Frederick, Dennie T. and Jané-Valbuena, Judit and Yoon, Charles H. and Rozenblatt-Rosen, Orit and Shalek, Alex K. and Regev, Aviv and Garraway, Levi A.}, + year = {2016}, + month = apr, + pages = {189-196} +} + +@article{Weiler24, + author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe'er, Dana and Theis, Fabian}, + publisher = {Springer Science and Business Media LLC}, + url = {http://dx.doi.org/10.1038/s41592-024-02303-9}, + doi = {10.1038/s41592-024-02303-9}, + issn = {1548-7105}, + journal = {Nature Methods}, + month = jun, + number = {7}, + pages = {1196-1205}, + title = {CellRank 2: unified fate mapping in multiview single-cell data}, + volume = {21}, + year = {2024}, +} + @article{Wolf18, doi = {10.1186/s13059-017-1382-0}, url = {https://doi.org/10.1186/s13059-017-1382-0}, @@ -63,28 +168,16 @@ @article{Wolf19 journal = {Genome Biology} } -@article{Gayoso2023, - title = {Deep generative modeling of transcriptional dynamics for RNA velocity analysis in single cells}, - url = {http://dx.doi.org/10.1038/s41592-023-01994-w}, - doi = {10.1038/s41592-023-01994-w}, - journal = {Nature Methods}, - publisher = {Springer Science and Business Media LLC}, - author = {Adam Gayoso and Philipp Weiler and Mohammad Lotfollahi and Dominik Klein and Justin Hong and Aaron Streets and Fabian J. Theis and Nir Yosef}, - year = {2023}, - month = sep -} - -@article{Weiler2024, - author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe'er, Dana and Theis, Fabian}, +@article{Zheng17, + title = {Massively parallel digital transcriptional profiling of single cells}, + volume = {8}, + ISSN = {2041-1723}, + url = {http://dx.doi.org/10.1038/ncomms14049}, + DOI = {10.1038/ncomms14049}, + number = {1}, + journal = {Nature Communications}, publisher = {Springer Science and Business Media LLC}, - url = {http://dx.doi.org/10.1038/s41592-024-02303-9}, - doi = {10.1038/s41592-024-02303-9}, - issn = {1548-7105}, - journal = {Nature Methods}, - month = jun, - number = {7}, - pages = {1196--1205}, - title = {CellRank 2: unified fate mapping in multiview single-cell data}, - volume = {21}, - year = {2024}, + author = {Zheng, Grace X. Y. and Terry, Jessica M. and Belgrader, Phillip and Ryvkin, Paul and Bent, Zachary W. and Wilson, Ryan and Ziraldo, Solongo B. and Wheeler, Tobias D. and McDermott, Geoff P. and Zhu, Junjie and Gregory, Mark T. and Shuga, Joe and Montesclaros, Luz and Underwood, Jason G. and Masquelier, Donald A. and Nishimura, Stefanie Y. and Schnall-Levin, Michael and Wyatt, Paul W. and Hindson, Christopher M. and Bharadwaj, Rajiv and Wong, Alexander and Ness, Kevin D. and Beppu, Lan W. and Deeg, H. Joachim and McFarland, Christopher and Loeb, Keith R. and Valente, William J. and Ericson, Nolan G. and Stevens, Emily A. and Radich, Jerald P. and Mikkelsen, Tarjei S. and Hindson, Benjamin J. and Bielas, Jason H.}, + year = {2017}, + month = jan } diff --git a/docs/source/vignettes/index.rst b/docs/source/vignettes/index.rst index f20f7b06..7f2ab445 100644 --- a/docs/source/vignettes/index.rst +++ b/docs/source/vignettes/index.rst @@ -3,17 +3,17 @@ Other Vignettes Example Datasets ^^^^^^^^^^^^^^^^ -- `Dentate Gyrus `_ -- `Pancreas `_ +- :doc:`Dentate Gyrus `, +- :doc:`Pancreas ` Nature Biotech Figures ^^^^^^^^^^^^^^^^^^^^^^ -- NBT Cover | `cover `__ | `notebook `__ -- Fig.1 Concept | `figure `__ | `notebook `__ -- Fig.2 Dentate Gyrus | `figure `__ | `notebook `__ -- Fig.3 Pancreas | `figure `__ | `notebook `__ -- Suppl. Figures | `figure `__ | `notebook `__ | `runtime `__ +- NBT Cover | `cover `__ | :doc:`notebook ` +- Fig.1 Concept | `figure `__ | :doc:`notebook ` +- Fig.2 Dentate Gyrus | `figure `__ | :doc:`notebook ` +- Fig.3 Pancreas | `figure `__ | :doc:`notebook ` +- Suppl. Figures | `figure `__ | `notebook `__ | :doc:`runtime ` All notebooks are deposited at `GitHub `_. Found a bug? Feel free to submit an `issue `_. diff --git a/pyproject.toml b/pyproject.toml index 9b663f55..bec32768 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,12 +85,11 @@ docs = [ "setuptools_scm", "importlib_metadata", "sphinx_rtd_theme>=0.3", - "sphinx_autodoc_typehints<=1.6", + "sphinx_autodoc_typehints>=1.10.3", "sphinxcontrib-bibtex>=2.3.0", - "Jinja2<3.1", # converting notebooks to html "ipykernel", - "sphinx>=1.7", + "sphinx>=1.7,<8.0", "nbsphinx>=0.7,<0.8.7" ] diff --git a/scvelo/core/_anndata.py b/scvelo/core/_anndata.py index 9a2021d5..f68bdbe9 100644 --- a/scvelo/core/_anndata.py +++ b/scvelo/core/_anndata.py @@ -31,8 +31,8 @@ def clean_obs_names( then saved in obs['sample_batch']. The genetic codes are identified according to according to https://www.neb.com/tools-and-resources/usage-guidelines/the-genetic-code. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix. alphabet @@ -92,8 +92,8 @@ def cleanup( ) -> Optional[AnnData]: """Delete not needed attributes. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix. clean @@ -154,8 +154,8 @@ def get_df( Return values for specified key (in obs, var, obsm, varm, obsp, varp, uns, or layers) as a dataframe. - Arguments: - --------- + Parameters + ---------- data AnnData object or a numpy array to get values from. keys @@ -313,8 +313,8 @@ def get_initial_size( ) -> Optional[ndarray]: """Get initial counts per observation of a layer. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix. layer @@ -354,8 +354,8 @@ def get_initial_size( def get_modality(adata: AnnData, modality: Optional[str]) -> Union[ndarray, spmatrix]: """Extract data of one modality. - Arguments: - --------- + Parameters + ---------- adata Annotated data to extract modality from. modality @@ -381,8 +381,8 @@ def get_modality(adata: AnnData, modality: Optional[str]) -> Union[ndarray, spma def get_size(adata: AnnData, modality: Optional[str] = None) -> ndarray: """Get counts per observation in a modality. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix. modality @@ -402,8 +402,8 @@ def make_dense( ) -> Optional[AnnData]: """Densify sparse AnnData entry. - Arguments: - --------- + Parameters + ---------- adata Annotated data object. modality @@ -437,8 +437,8 @@ def make_sparse( ) -> Optional[AnnData]: """Make AnnData entry sparse. - Arguments: - --------- + Parameters + ---------- adata Annotated data object. modality @@ -475,8 +475,8 @@ def merge( ) -> Optional[AnnData]: """Merge two annotated data matrices. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix (reference data set). ldata @@ -564,8 +564,8 @@ def merge( def obs_df(adata: AnnData, keys: List[str], layer: Optional[str] = None) -> DataFrame: """Extract layer as Pandas DataFrame indexed by observation. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix (reference data set). keys @@ -598,8 +598,8 @@ def set_initial_size(adata: AnnData, layers: Optional[str] = None) -> None: The initial size is only set if it does not already exist. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix. layers @@ -632,8 +632,8 @@ def set_modality( ) -> Optional[AnnData]: """Set modality of annotated data object to new value. - Arguments: - --------- + Parameters + ---------- adata Annotated data object. new_value @@ -670,8 +670,8 @@ def show_proportions( The proportions are printed. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix. layers @@ -708,8 +708,8 @@ def show_proportions( def var_df(adata: AnnData, keys: List[str], layer: Optional[str] = None): """Extract layer as Pandas DataFrame indexed by features. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix (reference data set). keys @@ -741,8 +741,8 @@ def var_df(adata: AnnData, keys: List[str], layer: Optional[str] = None): def verify_dtypes(adata: AnnData) -> None: """Verify that AnnData object is not corrupted. - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix to check. diff --git a/scvelo/core/_arithmetic.py b/scvelo/core/_arithmetic.py index 02b98f1a..b9d867bd 100644 --- a/scvelo/core/_arithmetic.py +++ b/scvelo/core/_arithmetic.py @@ -9,8 +9,8 @@ def clipped_log(x: ndarray, lb: float = 0, ub: float = 1, eps: float = 1e-6) -> ndarray: """Logarithmize between [lb + epsilon, ub - epsilon]. - Arguments: - --------- + Parameters + ---------- x Array to invert. lb @@ -31,8 +31,8 @@ def clipped_log(x: ndarray, lb: float = 0, ub: float = 1, eps: float = 1e-6) -> def invert(x: ndarray) -> ndarray: """Invert array and set infinity to NaN. - Arguments: - --------- + Parameters + ---------- x Array to invert. @@ -52,8 +52,8 @@ def multiply( ) -> Union[ndarray, spmatrix]: """Point-wise multiplication of arrays or sparse matrices. - Arguments: - --------- + Parameters + ---------- a First array/sparse matrix. b @@ -77,8 +77,8 @@ def prod_sum( ) -> ndarray: """Take sum of product of two arrays along given axis. - Arguments: - --------- + Parameters + ---------- a1 First array. a2 @@ -103,8 +103,8 @@ def prod_sum( def sum(a: Union[ndarray, spmatrix], axis: Optional[int] = None) -> ndarray: """Sum array elements over a given axis. - Arguments: - --------- + Parameters + ---------- a Elements to sum. axis diff --git a/scvelo/core/_linear_models.py b/scvelo/core/_linear_models.py index c704bab0..c5ddb10e 100644 --- a/scvelo/core/_linear_models.py +++ b/scvelo/core/_linear_models.py @@ -10,8 +10,8 @@ class LinearRegression: """Extreme quantile and constraint least square linear regression. - Arguments: - --------- + Parameters + ---------- percentile Percentile of data on which linear regression line is fit. If `None`, all data is used, if a single value is given, it is interpreted as the upper quantile. diff --git a/scvelo/core/_metrics.py b/scvelo/core/_metrics.py index 05a1f7cf..f422b346 100644 --- a/scvelo/core/_metrics.py +++ b/scvelo/core/_metrics.py @@ -9,8 +9,8 @@ def l2_norm(x: Union[ndarray, spmatrix], axis: int = 1) -> Union[float, ndarray]: """Calculate l2 norm along a given axis. - Arguments: - --------- + Parameters + ---------- x Array to calculate l2 norm of. axis diff --git a/scvelo/core/_models.py b/scvelo/core/_models.py index 9d9e9372..58680af7 100644 --- a/scvelo/core/_models.py +++ b/scvelo/core/_models.py @@ -13,8 +13,8 @@ class SplicingDynamics(DynamicsBase): """Splicing dynamics. - Arguments: - --------- + Parameters + ---------- alpha Transcription rate. beta diff --git a/scvelo/datasets/_datasets.py b/scvelo/datasets/_datasets.py index 94231eff..fdf32e53 100644 --- a/scvelo/datasets/_datasets.py +++ b/scvelo/datasets/_datasets.py @@ -19,7 +19,7 @@ def bonemarrow( ): """Human bone marrow. - Data from `Setty et al. (2019) `__. + Data from :cite:p:`Setty19`. The bone marrow is the primary site of new blood cell production or haematopoiesis. It is composed of hematopoietic cells, marrow adipose tissue, and supportive stromal @@ -45,7 +45,7 @@ def bonemarrow( def dentategyrus(file_path: Optional[Union[str, Path]] = None, adjusted=True): """Dentate Gyrus neurogenesis. - Data from `Hochgerner et al. (2018) `__. + Data from :cite:p:`Hochgerner18`. Dentate gyrus (DG) is part of the hippocampus involved in learning, episodic memory formation and spatial coding. The experiment from the developing DG comprises two @@ -60,8 +60,8 @@ def dentategyrus(file_path: Optional[Union[str, Path]] = None, adjusted=True): .. image:: https://user-images.githubusercontent.com/31883718/79433223-255b8700-7fcd-11ea-8ecf-3dc9eb1a6159.png :width: 600px - Arguments: - --------- + Parameters + ---------- file_path Path where to save dataset and read it from. @@ -102,7 +102,7 @@ def dentategyrus_lamanno( ): """Dentate Gyrus neurogenesis. - From `La Manno et al. (2018) `__. + From :cite:p:`LaManno18`. The experiment from the developing mouse hippocampus comprises two time points (P0 and P5) and reveals the complex manifold with multiple branching lineages @@ -145,13 +145,13 @@ def dentategyrus_lamanno( def forebrain(file_path: Union[str, Path] = "data/ForebrainGlut/hgForebrainGlut.loom"): """Developing human forebrain. - From `La Manno et al. (2018) `__. + From :cite:p:`LaManno18`. Forebrain tissue of a human week 10 embryo, focusing on glutamatergic neuronal lineage, obtained from elective routine abortions (10 weeks post-conception). - Arguments: - --------- + Parameters + ---------- file_path Path where to save dataset and read it from. @@ -170,7 +170,7 @@ def gastrulation( ): """Mouse gastrulation. - Data from `Pijuan-Sala et al. (2019) `__. + Data from :cite:p:`PijuanSala19`. Gastrulation represents a key developmental event during which embryonic pluripotent cells diversify into lineage-specific precursors that will generate the adult @@ -201,7 +201,7 @@ def gastrulation_e75( ): """Mouse gastrulation subset to E7.5. - Data from `Pijuan-Sala et al. (2019) `__. + Data from :cite:p:`PijuanSala19`. Gastrulation represents a key developmental event during which embryonic pluripotent cells diversify into lineage-specific precursors that will generate the adult @@ -225,7 +225,7 @@ def gastrulation_erythroid( ): """Mouse gastrulation subset to erythroid lineage. - Data from `Pijuan-Sala et al. (2019) `__. + Data from :cite:p:`PijuanSala19`. Gastrulation represents a key developmental event during which embryonic pluripotent cells diversify into lineage-specific precursors that will generate the adult @@ -247,7 +247,7 @@ def gastrulation_erythroid( def pancreas(file_path: Union[str, Path] = "data/Pancreas/endocrinogenesis_day15.h5ad"): """Pancreatic endocrinogenesis. - Data from `Bastidas-Ponce et al. (2019) `__. + Data from :cite:p:`BastidasPonce19`. Pancreatic epithelial and Ngn3-Venus fusion (NVF) cells during secondary transition with transcriptome profiles sampled from embryonic day 15.5. @@ -260,8 +260,8 @@ def pancreas(file_path: Union[str, Path] = "data/Pancreas/endocrinogenesis_day15 .. image:: https://user-images.githubusercontent.com/31883718/67709134-a0989480-f9bd-11e9-8ae6-f6391f5d95a0.png :width: 600px - Arguments: - --------- + Parameters + ---------- file_path Path where to save dataset and read it from. @@ -278,7 +278,7 @@ def pancreas(file_path: Union[str, Path] = "data/Pancreas/endocrinogenesis_day15 def pbmc68k(file_path: Optional[Union[str, Path]] = "data/PBMC/pbmc68k.h5ad"): """Peripheral blood mononuclear cells. - Data from `Zheng et al. (2017) `__. + Data from :cite:p:`Zheng17`. This experiment contains 68k peripheral blood mononuclear cells (PBMC) measured using 10X. @@ -308,8 +308,8 @@ def toy_data( ): """Randomly sampled from the Dentate Gyrus dataset. - Arguments: - --------- + Parameters + ---------- file_path Path where to save dataset and read it from. n_obs: `int` (default: `None`) diff --git a/scvelo/inference/_metabolic_labeling.py b/scvelo/inference/_metabolic_labeling.py index 1e7d40cc..3ba2b075 100644 --- a/scvelo/inference/_metabolic_labeling.py +++ b/scvelo/inference/_metabolic_labeling.py @@ -15,8 +15,8 @@ def _get_bounds(experiment: np.ndarray): """Returns bounds for constraint optimization problem. - Arguments: - --------- + Parameters + ---------- experiment Type of experiment (``"chase"`` or ``"pulse"``) that observation was generated from. @@ -43,8 +43,8 @@ def get_mse( ): """Calculates mean squared error (MSE) between predicted and measurmed, newly synthesized mRNA. - Arguments: - --------- + Parameters + ---------- x Parameter estimate. measured_new @@ -87,8 +87,8 @@ def _get_n_neighbors( ) -> pd.DataFrame: """Get number of neighbors required to include ``n_nontrivial_counts`` counts per labeling time. - Arguments: - --------- + Parameters + ---------- X Gene expression. labeling_times @@ -143,10 +143,10 @@ def _get_n_neighbors( def get_labeling_times(adata, time_key) -> List: """Get labeling times in dataset. - See :cite:p:`Weiler2024`. + See :cite:p:`Weiler24`. - Arguments: - --------- + Parameters + ---------- adata AnnData object. time_key @@ -164,10 +164,10 @@ def get_labeling_time_mask( ) -> Dict[float, np.ndarray]: """Get number of neighbors required to include ``n_nontrivial_counts`` counts per labeling time. - See :cite:p:`Weiler2024`. + See :cite:p:`Weiler24`. - Arguments: - --------- + Parameters + ---------- adata AnnData object. time_key @@ -191,10 +191,10 @@ def get_obs_dist_argsort( ) -> Dict[float, np.ndarray]: """Calculate argsorted pairwise distances per labeling_time_point. - See :cite:p:`Weiler2024`. + See :cite:p:`Weiler24`. - Arguments: - --------- + Parameters + ---------- adata AnnData object. labeling_time_mask @@ -232,10 +232,10 @@ def get_n_neighbors( ) -> Dict[str, pd.DataFrame]: """Get number of neighbors required to include ``n_nontrivial_counts`` counts per labeling time. - See :cite:p:`Weiler2024`. + See :cite:p:`Weiler24`. - Arguments: - --------- + Parameters + ---------- adata AnnData object. labeling_time_mask @@ -285,8 +285,8 @@ def get_n_neighbors( def get_counts(gex, labeling_time_mask, obs_dist_argsort, obs_id, neighbors): """Return gex counts used for fitting parameters. - Arguments: - --------- + Parameters + ---------- gex GEX vector of a given gene. time_masks @@ -329,8 +329,8 @@ def _get_parameters( ): """Estimates parameters of splicing kinetics from metabolic labeling data. - Arguments: - --------- + Parameters + ---------- measured_labeled Measured labeled RNA. labeling_times @@ -389,10 +389,10 @@ def get_parameters( ): """Estimates parameters of splicing kinetics from metabolic labeling data. - See :cite:p:`Weiler2024`. + See :cite:p:`Weiler24`. - Arguments: - --------- + Parameters + ---------- adata AnnData object containing data. use_rep diff --git a/scvelo/plotting/heatmap.py b/scvelo/plotting/heatmap.py index 69fd5f48..475e877f 100644 --- a/scvelo/plotting/heatmap.py +++ b/scvelo/plotting/heatmap.py @@ -36,8 +36,8 @@ def heatmap( ): """Plot time series for genes as heatmap. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. var_names: `str`, list of `str` diff --git a/scvelo/plotting/paga.py b/scvelo/plotting/paga.py index 0cee178a..84111cc6 100644 --- a/scvelo/plotting/paga.py +++ b/scvelo/plotting/paga.py @@ -75,8 +75,8 @@ def paga( PAGA graph with connectivities (dashed) and transitions (solid/arrows). - Arguments: - --------- + Parameters + ---------- adata Annotated data matrix. threshold diff --git a/scvelo/plotting/proportions.py b/scvelo/plotting/proportions.py index ce7f9452..43fecce5 100644 --- a/scvelo/plotting/proportions.py +++ b/scvelo/plotting/proportions.py @@ -22,8 +22,8 @@ def proportions( ): """Plot pie chart of spliced/unspliced proprtions. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. groupby: `str` (default: 'clusters') diff --git a/scvelo/plotting/scatter.py b/scvelo/plotting/scatter.py index cd4c452a..6733af44 100644 --- a/scvelo/plotting/scatter.py +++ b/scvelo/plotting/scatter.py @@ -124,8 +124,8 @@ def scatter( ): """Scatter plot along observations or variables axes. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. x: `str`, `np.ndarray` or `None` (default: `None`) diff --git a/scvelo/plotting/utils.py b/scvelo/plotting/utils.py index e4ba2c95..3244ac43 100644 --- a/scvelo/plotting/utils.py +++ b/scvelo/plotting/utils.py @@ -1016,8 +1016,8 @@ def adjust_palette(palette, length): def rgb_custom_colormap(colors=None, alpha=None, N=256): """Creates a custom colormap. Colors can be given as names or rgb values. - Arguments: - --------- + Parameters + ---------- colors: : `list` or `array` (default `['royalblue', 'white', 'forestgreen']`) List of colors, either as names or rgb values. alpha: `list`, `np.ndarray` or `None` (default: `None`) @@ -1470,8 +1470,8 @@ def hist( ): """Plot a histogram. - Arguments: - --------- + Parameters + ---------- arrays: : `list` or `array` (default `['royalblue', 'white', 'forestgreen']`) List of colors, either as names or rgb values. alpha: `list`, `np.ndarray` or `None` (default: `None`) diff --git a/scvelo/plotting/velocity.py b/scvelo/plotting/velocity.py index 9b79f231..d9f8f836 100644 --- a/scvelo/plotting/velocity.py +++ b/scvelo/plotting/velocity.py @@ -50,8 +50,8 @@ def velocity( The phase plot shows spliced against unspliced expressions with steady-state fit. Further the embedding is shown colored by velocity and expression. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. var_names: `str` or list of `str` (default: `None`) diff --git a/scvelo/plotting/velocity_embedding.py b/scvelo/plotting/velocity_embedding.py index e8faaf26..e283db7c 100644 --- a/scvelo/plotting/velocity_embedding.py +++ b/scvelo/plotting/velocity_embedding.py @@ -70,8 +70,8 @@ def velocity_embedding( ): """Scatter plot of velocities on the embedding. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. density: `float` (default: 1) diff --git a/scvelo/plotting/velocity_embedding_grid.py b/scvelo/plotting/velocity_embedding_grid.py index c0d74131..b8877380 100644 --- a/scvelo/plotting/velocity_embedding_grid.py +++ b/scvelo/plotting/velocity_embedding_grid.py @@ -152,8 +152,8 @@ def velocity_embedding_grid( ): """Scatter plot of velocities on a grid. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. density: `float` (default: 1) diff --git a/scvelo/plotting/velocity_embedding_stream.py b/scvelo/plotting/velocity_embedding_stream.py index 7d48c703..c309f273 100644 --- a/scvelo/plotting/velocity_embedding_stream.py +++ b/scvelo/plotting/velocity_embedding_stream.py @@ -73,8 +73,8 @@ def velocity_embedding_stream( ): """Stream plot of velocities on the embedding. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. density: `float` (default: 2) diff --git a/scvelo/plotting/velocity_graph.py b/scvelo/plotting/velocity_graph.py index 754bb28a..c01eddef 100644 --- a/scvelo/plotting/velocity_graph.py +++ b/scvelo/plotting/velocity_graph.py @@ -49,8 +49,8 @@ def velocity_graph( Velocity graph with connectivities (dashed) and transitions (solid/arrows). - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. which_graph: `'velocity_graph'` or `'connectivities'` (default: `None`) diff --git a/scvelo/preprocessing/__init__.py b/scvelo/preprocessing/__init__.py index cf061ce8..9221015f 100644 --- a/scvelo/preprocessing/__init__.py +++ b/scvelo/preprocessing/__init__.py @@ -1,5 +1,5 @@ from .moments import moments -from .neighbors import neighbors, pca, remove_duplicate_cells +from .neighbors import neighbors, remove_duplicate_cells from .utils import ( filter_and_normalize, filter_genes, @@ -17,7 +17,6 @@ "moments", "neighbors", "normalize_per_cell", - "pca", "recipe_velocity", "remove_duplicate_cells", ] diff --git a/scvelo/preprocessing/moments.py b/scvelo/preprocessing/moments.py index 498d801a..5cf5c168 100644 --- a/scvelo/preprocessing/moments.py +++ b/scvelo/preprocessing/moments.py @@ -24,8 +24,8 @@ def moments( First-/second-order moments are computed for each cell across its nearest neighbors, where the neighbor graph is obtained from euclidean distances in PCA space. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. n_neighbors: `int` (default: 30) @@ -39,7 +39,7 @@ def moments( method : {{'umap', 'hnsw', 'sklearn', `None`}} (default: `'umap'`) Method to compute neighbors, only differs in runtime. Connectivities are computed with adaptive kernel width as proposed in - Haghverdi et al. 2016 (https://doi.org/10.1038/nmeth.3971). + :cite:p:`Haghverdi16`. use_rep : `None`, `'X'` or any key for `.obsm` (default: None) Use the indicated representation. If `None`, the representation is chosen automatically: for .n_vars < 50, .X is used, otherwise ‘X_pca’ is used. @@ -111,8 +111,8 @@ def moments( def second_order_moments(adata, adjusted=False): """Computes second order moments for stochastic velocity estimation. - Arguments: - --------- + Parameters + ---------- adata: `AnnData` Annotated data matrix. @@ -141,8 +141,8 @@ def second_order_moments(adata, adjusted=False): def second_order_moments_u(adata): """Computes second order moments for stochastic velocity estimation. - Arguments: - --------- + Parameters + ---------- adata: `AnnData` Annotated data matrix. @@ -170,8 +170,8 @@ def get_moments( First and second order moments. If centered, that corresponds to means and variances across nearest neighbors. - Arguments: - --------- + Parameters + ---------- adata: `AnnData` Annotated data matrix. layer: `str` (default: `None`) diff --git a/scvelo/preprocessing/neighbors.py b/scvelo/preprocessing/neighbors.py index da427fc7..ac316449 100644 --- a/scvelo/preprocessing/neighbors.py +++ b/scvelo/preprocessing/neighbors.py @@ -168,7 +168,7 @@ def neighbors( The neighbor graph methods (umap, hnsw, sklearn) only differ in runtime and yield the same result as Scanpy :cite:p:`Wolf18`. Connectivities are computed with - adaptive kernel width as proposed in Haghverdi et al. 2016 (doi:10.1038/nmeth.3971). + adaptive kernel width as proposed in :cite:p:`Haghverdi16`. Parameters ---------- @@ -188,7 +188,7 @@ def neighbors( or 30 components are used when PCA is computed internally. use_rep : `None`, `'X'` or any key for `.obsm` (default: None) Use the indicated representation. If `None`, the representation is chosen - automatically: for .n_vars < 50, .X is used, otherwise ‘X_pca’ is used. + automatically: for .n_vars < 50, .X is used, otherwise 'X_pca' is used. use_highly_variable: `bool` (default: True) Whether to use highly variable genes only, stored in .var['highly_variable']. knn @@ -203,7 +203,7 @@ def neighbors( The 'hnsw' method is most efficient and requires to `pip install hnswlib`. Connectivities are computed with adaptive kernel. metric - A known metric’s name or a callable that returns a distance. + A known metric's name or a callable that returns a distance. metric_kwds Options for the metric. num_threads diff --git a/scvelo/preprocessing/utils.py b/scvelo/preprocessing/utils.py index c84497df..aed12bf1 100644 --- a/scvelo/preprocessing/utils.py +++ b/scvelo/preprocessing/utils.py @@ -631,8 +631,8 @@ def filter_and_normalize( scv.pp.log1p(adata) - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. min_counts: `int` (default: `None`) diff --git a/scvelo/settings.py b/scvelo/settings.py index c39f91af..7f4edd00 100644 --- a/scvelo/settings.py +++ b/scvelo/settings.py @@ -262,8 +262,8 @@ def set_figure_params( ): """Set resolution/size, styling and format of figures. - Arguments: - --------- + Parameters + ---------- style : `str` (default: `None`) Init default values for ``matplotlib.rcParams`` suited for `scvelo` or `scanpy`. Use `None` for the default matplotlib values. @@ -289,7 +289,7 @@ def set_figure_params( facecolor : `str` (default: `None`) Sets backgrounds `rcParams['figure.facecolor']` and `rcParams['axes.facecolor']` to `facecolor`. - format : {'png', 'pdf', 'svg', etc.} (default: 'pdf') + format : `str` (default: 'pdf') This sets the default format for saving figures: `file_format_figs`. ipython_format : list of `str` (default: 'png2x') Only concerns the notebook/IPython environment; see diff --git a/scvelo/tools/_em_model_core.py b/scvelo/tools/_em_model_core.py index 0081026f..c40c092b 100644 --- a/scvelo/tools/_em_model_core.py +++ b/scvelo/tools/_em_model_core.py @@ -430,8 +430,8 @@ def recover_dynamics( .. image:: https://user-images.githubusercontent.com/31883718/69636459-ef862800-1056-11ea-8803-0a787ede5ce9.png - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. var_names: `str`, list of `str` (default: `'velocity_genes'`) @@ -671,8 +671,8 @@ def align_dynamics( ): """Align dynamics to a common set of parameters. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. t_max: `float`, `False` or `None` (default: `None`) @@ -796,8 +796,8 @@ def latent_time( .. image:: https://user-images.githubusercontent.com/31883718/69636500-03318e80-1057-11ea-9e14-ae9f907711cc.png - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix vkey: `str` (default: `'velocity'`) @@ -975,8 +975,8 @@ def differential_kinetic_test( .. image:: https://user-images.githubusercontent.com/31883718/78930730-dc737200-7aa4-11ea-92f6-269b7609c3a5.png - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. var_names: `str`, list of `str` (default: `'velocity_genes`) @@ -1106,7 +1106,7 @@ def rank_dynamical_genes(data, n_genes=100, groupby=None, copy=False): This ranks genes by their likelihood obtained from the dynamical model grouped by clusters specified in groupby. - Arguments: + Parameters ---------- data : :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/_em_model_utils.py b/scvelo/tools/_em_model_utils.py index 6475817c..f05acc90 100644 --- a/scvelo/tools/_em_model_utils.py +++ b/scvelo/tools/_em_model_utils.py @@ -252,8 +252,8 @@ def compute_divergence( ): """Estimates the divergence of ODE to observations (avaiable metrics: distance, mse, likelihood, loglikelihood). - Arguments: - --------- + Parameters + ---------- mode: `'distance'`, `'mse'`, `'likelihood'` (default: `'distance'`) """ diff --git a/scvelo/tools/rank_velocity_genes.py b/scvelo/tools/rank_velocity_genes.py index 1ab248e8..a982eeb4 100644 --- a/scvelo/tools/rank_velocity_genes.py +++ b/scvelo/tools/rank_velocity_genes.py @@ -94,7 +94,7 @@ def velocity_clusters( .. image:: https://user-images.githubusercontent.com/31883718/69625627-484dc480-1047-11ea-847f-6607a3430427.png :width: 600px - Arguments: + Parameters ---------- data : :class:`~anndata.AnnData` Annotated data matrix. @@ -238,7 +238,7 @@ def rank_velocity_genes( .. image:: https://user-images.githubusercontent.com/31883718/69626572-30774000-1049-11ea-871f-e8a30c42f10e.png :width: 600px - Arguments: + Parameters ---------- data : :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/score_genes_cell_cycle.py b/scvelo/tools/score_genes_cell_cycle.py index 44cf24a2..58e73057 100644 --- a/scvelo/tools/score_genes_cell_cycle.py +++ b/scvelo/tools/score_genes_cell_cycle.py @@ -54,7 +54,7 @@ def score_genes_cell_cycle(adata, s_genes=None, g2m_genes=None, copy=False, **kw """Score cell cycle genes. Calculates scores and assigns a cell cycle phase (G1, S, G2M) using the list of cell - cycle genes defined in Tirosh et al, 2015 (https://doi.org/10.1126/science.aad0501). + cycle genes defined in :cite:p:`Tirosh16`. Parameters ---------- diff --git a/scvelo/tools/terminal_states.py b/scvelo/tools/terminal_states.py index bc5f05f9..603f1e62 100644 --- a/scvelo/tools/terminal_states.py +++ b/scvelo/tools/terminal_states.py @@ -20,8 +20,8 @@ def cell_fate( ): """Computes individual cell endpoints. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. groupby: `str` (default: `'clusters'`) @@ -86,8 +86,8 @@ def cell_origin( ): """Computes individual cell root points. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. groupby: `str` (default: `'clusters'`) @@ -239,8 +239,8 @@ def terminal_states( Alternatively, we recommend to use :func:`cellrank.tl.terminal_states` providing an improved/generalized approach of identifying terminal states. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) diff --git a/scvelo/tools/transition_matrix.py b/scvelo/tools/transition_matrix.py index 5af048e7..7aa516ce 100644 --- a/scvelo/tools/transition_matrix.py +++ b/scvelo/tools/transition_matrix.py @@ -39,8 +39,8 @@ def transition_matrix( Alternatively, use :func:`cellrank.tl.transition_matrix` to account for uncertainty in the velocity estimates. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) @@ -171,8 +171,8 @@ def get_cell_transitions( ): """Simulate cell transitions. - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix. starting_cell: `int` (default: `0`) diff --git a/scvelo/tools/utils.py b/scvelo/tools/utils.py index 29c3c361..d302e27d 100644 --- a/scvelo/tools/utils.py +++ b/scvelo/tools/utils.py @@ -439,8 +439,8 @@ def vcorrcoef(X, y, mode="pearsons", axis=-1): Use Pearsons / Spearmans to test for linear / monotonic relationship. - Arguments: - --------- + Parameters + ---------- X: `np.ndarray` Data vector or matrix y: `np.ndarray` diff --git a/scvelo/tools/velocity.py b/scvelo/tools/velocity.py index 32fbdc9f..4fbdb223 100644 --- a/scvelo/tools/velocity.py +++ b/scvelo/tools/velocity.py @@ -267,8 +267,8 @@ def velocity( .. image:: https://user-images.githubusercontent.com/31883718/69636491-ff057100-1056-11ea-90b7-d04098112ce1.png - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) @@ -498,8 +498,8 @@ def velocity_genes( ): """Estimates velocities in a gene-specific manner. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) diff --git a/scvelo/tools/velocity_confidence.py b/scvelo/tools/velocity_confidence.py index f8e795e3..502728be 100644 --- a/scvelo/tools/velocity_confidence.py +++ b/scvelo/tools/velocity_confidence.py @@ -19,8 +19,8 @@ def velocity_confidence(data, vkey="velocity", copy=False): :width: 600px - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) @@ -78,8 +78,8 @@ def velocity_confidence(data, vkey="velocity", copy=False): def velocity_confidence_transition(data, vkey="velocity", scale=10, copy=False): """Computes confidences of velocity transitions. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) diff --git a/scvelo/tools/velocity_embedding.py b/scvelo/tools/velocity_embedding.py index 20a455b1..1d1802ed 100644 --- a/scvelo/tools/velocity_embedding.py +++ b/scvelo/tools/velocity_embedding.py @@ -61,8 +61,8 @@ def velocity_embedding( \delta_{ij}. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. basis: `str` (default: `'tsne'`) diff --git a/scvelo/tools/velocity_graph.py b/scvelo/tools/velocity_graph.py index faba33ad..61428aa8 100644 --- a/scvelo/tools/velocity_graph.py +++ b/scvelo/tools/velocity_graph.py @@ -294,8 +294,8 @@ def velocity_graph( = \frac{\delta_{ij}^T \nu_i}{\left\lVert\delta_{ij}\right\rVert \left\lVert \nu_i \right\rVert}. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. vkey: `str` (default: `'velocity'`) diff --git a/scvelo/tools/velocity_pseudotime.py b/scvelo/tools/velocity_pseudotime.py index 9554574c..818002eb 100644 --- a/scvelo/tools/velocity_pseudotime.py +++ b/scvelo/tools/velocity_pseudotime.py @@ -12,8 +12,8 @@ def principal_curve(data, basis="pca", n_comps=4, clusters_list=None, copy=False): """Computes the principal curve. - Arguments: - --------- + Parameters + ---------- data: :class:`~anndata.AnnData` Annotated data matrix. basis: `str` (default: `'pca'`) @@ -167,8 +167,8 @@ def velocity_pseudotime( .. image:: https://user-images.githubusercontent.com/31883718/69545487-33fbc000-0f92-11ea-969b-194dc68400b0.png :width: 600px - Arguments: - --------- + Parameters + ---------- adata: :class:`~anndata.AnnData` Annotated data matrix vkey: `str` (default: `'velocity'`) diff --git a/tests/core/test_base.py b/tests/core/test_base.py index 062db52f..b374cc4a 100644 --- a/tests/core/test_base.py +++ b/tests/core/test_base.py @@ -44,8 +44,8 @@ def get_adata( The largest possible value of a numerical entry is `1e5`. - Arguments: - --------- + Parameters + ---------- n_obs Number of observations. If set to `None`, a random integer between `1` and `max_obs` will be drawn. Defaults to `None`. diff --git a/tests/test_basic.py b/tests/test_basic.py index 0336d88b..29e24195 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,5 +1,7 @@ import numpy as np +import scanpy as sc + import scvelo as scv from scvelo.tools import ExpectationMaximizationModel @@ -30,7 +32,7 @@ def test_pipeline(): adata = scv.datasets.simulation(random_seed=0, n_vars=10) scv.pp.filter_and_normalize(adata, n_top_genes=5) - scv.pp.pca(adata) + sc.pp.pca(adata) scv.pp.moments(adata) em_model = ExpectationMaximizationModel(adata=adata) @@ -76,8 +78,8 @@ def test_highly_variable_subset(): scv.pp.filter_and_normalize(adata, n_top_genes=5, subset_highly_variable=True) scv.pp.filter_and_normalize(bdata, n_top_genes=5, subset_highly_variable=False) - scv.pp.pca(adata) - scv.pp.pca(bdata) + sc.pp.pca(adata) + sc.pp.pca(bdata) scv.pp.moments(adata, use_rep="pca") scv.pp.moments(bdata, use_rep="pca")