diff --git a/README.md b/README.md index a3ca4954..eba86411 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,13 @@ -**scVelo** is a scalable toolkit for RNA velocity analysis in single cells, based on -[Bergen et al. (Nature Biotech, 2020](https://doi.org/10.1038/s41587-020-0591-3). - -RNA velocity enables the recovery of directed dynamic information by leveraging splicing kinetics. -scVelo generalizes the concept of RNA velocity -[La Manno et al., Nature, 2018](https://doi.org/10.1038/s41586-018-0414-6>) -by relaxing previously made assumptions with a stochastic and a dynamical model that solves the full -transcriptional dynamics. It thereby adapts RNA velocity to widely varying specifications such as non-stationary populations. - -scVelo is compatible with scanpy\_ and hosts efficient implementations of all RNA velocity models. +**scVelo** is a scalable toolkit for RNA velocity analysis in single cells; RNA velocity +enables the recovery of directed dynamic information by leveraging splicing kinetics +[1](https://doi.org/10.1038/s41586-018-0414-6). scVelo collects different +methods for inferring RNA velocity using an expectation-maximization framework +[2](https://doi.org/10.1038/s41587-020-0591-3), deep generative modeling +[3](https://doi.org/10.1038/s41592-023-01994-w), +or metabolically labeled transcripts[4](https://doi.org/10.1101/2023.07.19.549685). ## scVelo's key applications @@ -32,28 +29,66 @@ scVelo is compatible with scanpy\_ and hosts efficient implementations of all RN - estimate reaction rates of transcription, splicing and degradation. - use statistical tests, e.g., to detect different kinetics regimes. -scVelo has, for instance, recently been used to study immune response in COVID-19 -patients and dynamic processes in human lung regeneration. Find out more in this list of -[application examples](https://scholar.google.com/scholar?cites=18195185735875895912). - -## Latest news - -- Aug/2021: [Perspectives paper out in MSB](https://doi.org/10.15252/msb.202110282) -- Feb/2021: scVelo goes multi-core -- Dec/2020: Cover of [Nature Biotechnology](https://www.nature.com/nbt/volumes/38) -- Nov/2020: Talk at [Single Cell Biology](https://coursesandconferences.wellcomegenomecampus.org/our-events/single-cell-biology-2020/) -- Oct/2020: [Helmholtz Best Paper Award](https://twitter.com/ICBmunich/status/1318611467722199041) -- Oct/2020: Map cell fates with [CellRank](https://cellrank.org) -- Sep/2020: Talk at [Single Cell Omics](https://twitter.com/fabian_theis/status/1305621028056465412) -- Aug/2020: [scVelo out in Nature Biotech](https://www.helmholtz-muenchen.de/en/aktuelles/latest-news/press-information-news/article/48658/index.html) - -## References - -[La Manno _et al._ (2018), RNA velocity of single cells, Nature](https://doi.org/10.1038/s41586-018-0414-6). - -[Bergen _et al._ (2020), Generalizing RNA velocity to transient cell states through dynamical modeling, Nature Biotech](https://doi.org/10.1038/s41587-020-0591-3). - -[Bergen _et al._ (2021), RNA velocity - current challenges and future perspectives, Molecular Systems Biology](https://doi.org/10.15252/msb.202110282). +## Citing scVelo + +If you include or rely on scVelo when publishing research, please adhere to the +following citation guide: + +### EM and steady-state model + +If you use the _EM_ (_dynamical_) or _steady-state model_, cite + +```bibtex +@article{Bergen2020, + title = {Generalizing RNA velocity to transient cell states through dynamical modeling}, + volume = {38}, + ISSN = {1546-1696}, + url = {http://dx.doi.org/10.1038/s41587-020-0591-3}, + DOI = {10.1038/s41587-020-0591-3}, + number = {12}, + journal = {Nature Biotechnology}, + publisher = {Springer Science and Business Media LLC}, + author = {Bergen, Volker and Lange, Marius and Peidli, Stefan and Wolf, F. Alexander and Theis, Fabian J.}, + year = {2020}, + month = aug, + pages = {1408–1414} +} +``` + +### veloVI + +If you use _veloVI_ (_VI model_), cite + +```bibtex +@article{Gayoso2023, + title = {Deep generative modeling of transcriptional dynamics for RNA velocity analysis in single cells}, + ISSN = {1548-7105}, + 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 = {Gayoso, Adam and Weiler, Philipp and Lotfollahi, Mohammad and Klein, Dominik and Hong, Justin and Streets, Aaron and Theis, Fabian J. and Yosef, Nir}, + year = {2023}, + month = sep +} +``` + +### RNA velocity inference through metabolic labeling information + +If you use the implemented method for estimating RNA velocity from metabolic labeling +information, cite + +```bibtex +@article{Weiler2023, + title = {Unified fate mapping in multiview single-cell data}, + url = {http://dx.doi.org/10.1101/2023.07.19.549685}, + DOI = {10.1101/2023.07.19.549685}, + publisher = {Cold Spring Harbor Laboratory}, + author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe’er, Dana and Theis, Fabian J.}, + year = {2023}, + month = jul +} +``` ## Support @@ -61,6 +96,5 @@ Found a bug or would like to see a feature implemented? Feel free to submit an [issue](https://github.com/theislab/scvelo/issues/new/choose). Have a question or would like to start a new discussion? Head over to [GitHub discussions](https://github.com/theislab/scvelo/discussions). -In either case, you can also always send us an [email](mailto:mail@scvelo.org). Your help to improve scVelo is highly appreciated. For further information visit [scvelo.org](https://scvelo.org). diff --git a/docs/source/api.rst b/docs/source/api.rst index e4215c57..b8ce5a37 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -76,6 +76,7 @@ Tools (tl) tl.recover_dynamics tl.differential_kinetic_test + tl.VELOVI **Dynamical genes** @@ -105,6 +106,18 @@ Tools (tl) tl.velocity_confidence tl.score_genes_cell_cycle +Inference from metabolic labeling information +--------- + +.. autosummary:: + :toctree: . + + inference.get_labeling_time_mask + inference.get_labeling_times + inference.get_n_neighbors + inference.get_obs_dist_argsort + inference.get_parameters + Plotting (pl) ------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index a12b2be9..3d2ed3f2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -9,16 +9,12 @@ scVelo - RNA velocity generalized through dynamical modeling .. include:: _key_contributors.rst -**scVelo** is a scalable toolkit for RNA velocity analysis in single cells, based on -`Bergen et al. (Nature Biotech, 2020) `_. - -RNA velocity enables the recovery of directed dynamic information by leveraging splicing kinetics. -scVelo generalizes the concept of RNA velocity -(`La Manno et al., Nature, 2018 `_) -by relaxing previously made assumptions with a stochastic and a dynamical model that solves the full -transcriptional dynamics. It thereby adapts RNA velocity to widely varying specifications such as non-stationary populations. - -scVelo is compatible with Scanpy_ and hosts efficient implementations of all RNA velocity models. +**scVelo** is a scalable toolkit for RNA velocity analysis in single cells; RNA velocity +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:`Weiler2023`. scVelo's key applications ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,30 +24,69 @@ scVelo's key applications - estimate reaction rates of transcription, splicing and degradation. - use statistical tests, e.g., to detect different kinetics regimes. -scVelo has, for instance, recently been used to study immune response in COVID-19 -patients and dynamic processes in human lung regeneration. Find out more in this list of -`application examples `_. -Latest news -^^^^^^^^^^^ -- Aug/2021: `Perspectives paper out in MSB `_ -- Feb/2021: scVelo goes multi-core -- Dec/2020: Cover of `Nature Biotechnology `_ -- Nov/2020: Talk at `Single Cell Biology `_ -- Oct/2020: `Helmholtz Best Paper Award `_ -- Oct/2020: Map cell fates with `CellRank `_ -- Sep/2020: Talk at `Single Cell Omics `_ -- Aug/2020: `scVelo out in Nature Biotech `_ +Citing scVelo +^^^^^^^^^^^^^ + +If you include or rely on scVelo when publishing research, please adhere to the +following citation guide: + +**EM and steady-state model** + +If you use the *EM* (*dynamical*) or *steady-state model*, cite + +.. code-block:: bibtex + + @article{Bergen2020, + title = {Generalizing RNA velocity to transient cell states through dynamical modeling}, + volume = {38}, + ISSN = {1546-1696}, + url = {http://dx.doi.org/10.1038/s41587-020-0591-3}, + DOI = {10.1038/s41587-020-0591-3}, + number = {12}, + journal = {Nature Biotechnology}, + publisher = {Springer Science and Business Media LLC}, + author = {Bergen, Volker and Lange, Marius and Peidli, Stefan and Wolf, F. Alexander and Theis, Fabian J.}, + year = {2020}, + month = aug, + pages = {1408–1414} + } + + +**veloVI** -References -^^^^^^^^^^ -La Manno *et al.* (2018), RNA velocity of single cells, `Nature `_. +If you use *veloVI* (*VI model*), cite -Bergen *et al.* (2020), Generalizing RNA velocity to transient cell states through dynamical modeling, -`Nature Biotech `_. +.. code-block:: bibtex -Bergen *et al.* (2021), RNA velocity - current challenges and future perspectives, -`Molecular Systems Biology `_. + @article{Gayoso2023, + title = {Deep generative modeling of transcriptional dynamics for RNA velocity analysis in single cells}, + ISSN = {1548-7105}, + 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 = {Gayoso, Adam and Weiler, Philipp and Lotfollahi, Mohammad and Klein, Dominik and Hong, Justin and Streets, Aaron and Theis, Fabian J. and Yosef, Nir}, + year = {2023}, + month = sep + } + +**RNA velocity inference through metabolic labeling information** + +If you use the implemented method for estimating RNA velocity from metabolic labeling +information, cite + +.. code-block:: bibtex + + @article{Weiler2023, + title = {Unified fate mapping in multiview single-cell data}, + url = {http://dx.doi.org/10.1101/2023.07.19.549685}, + DOI = {10.1101/2023.07.19.549685}, + publisher = {Cold Spring Harbor Laboratory}, + author = {Weiler, Philipp and Lange, Marius and Klein, Michal and Pe’er, Dana and Theis, Fabian J.}, + year = {2023}, + month = jul + } Support ^^^^^^^ @@ -59,9 +94,7 @@ Found a bug or would like to see a feature implemented? Feel free to submit an `issue `_. Have a question or would like to start a new discussion? Head over to `GitHub discussions `_. -In either case, you can also always send us an `email `_. Your help to improve scVelo is highly appreciated. -For further information visit `scvelo.org `_. .. toctree:: @@ -103,25 +136,12 @@ For further information visit `scvelo.org `_. .. |Docs| image:: https://readthedocs.org/projects/scvelo/badge/?version=latest :target: https://scvelo.readthedocs.io -.. |travis| image:: https://travis-ci.org/theislab/scvelo.svg?branch=main - :target: https://travis-ci.org/theislab/scvelo - .. _Scanpy: https://scanpy.readthedocs.io -.. _calendly: https://calendly.com/scvelo - .. |br| raw:: html
-.. |meet| raw:: html - - - - - here - - .. |dim| raw:: html diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 9e85c911..891d94aa 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -19,12 +19,12 @@ Development Version To work with the latest development version, install from GitHub_ using:: - pip install git+https://github.com/theislab/scvelo@develop + pip install git+https://github.com/theislab/scvelo@main or:: git clone https://github.com/theislab/scvelo && cd scvelo - git checkout --track origin/develop + git checkout --track origin/main pip install -e . ``-e`` is short for ``--editable`` and links the package to the original cloned diff --git a/docs/source/perspectives/index.rst b/docs/source/perspectives/index.rst index 4460ec37..0767bc45 100644 --- a/docs/source/perspectives/index.rst +++ b/docs/source/perspectives/index.rst @@ -21,7 +21,6 @@ transcriptional boost in erythroid lineage, and misleading arrow projections in Notebook: `Perspectives `_ -| Kinetic parameter analysis ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. image:: https://user-images.githubusercontent.com/31883718/130656606-00bd44be-9071-4008-be1b-244fa9c2d244.png diff --git a/docs/source/references.bib b/docs/source/references.bib index a29162f4..14bab723 100644 --- a/docs/source/references.bib +++ b/docs/source/references.bib @@ -62,3 +62,24 @@ @article{Wolf19 title = {{PAGA}: graph abstraction reconciles clustering with trajectory inference through a topology preserving map of single cells}, 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{Weiler2023, + title = {Unified fate mapping in multiview single-cell data}, + url = {http://dx.doi.org/10.1101/2023.07.19.549685}, + DOI = {10.1101/2023.07.19.549685}, + publisher = {Cold Spring Harbor Laboratory}, + author = {Philipp Weiler and Marius Lange and Michal Klein and Dana Pe{\textquotesingle}er and Fabian J. Theis}, + year = {2023}, + month = jul +} diff --git a/scvelo/core/_anndata.py b/scvelo/core/_anndata.py index 782d0265..eac66cb6 100644 --- a/scvelo/core/_anndata.py +++ b/scvelo/core/_anndata.py @@ -30,7 +30,7 @@ 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 + Arguments: --------- adata Annotated data matrix. @@ -91,7 +91,7 @@ def cleanup( ) -> Optional[AnnData]: """Delete not needed attributes. - Arguments + Arguments: --------- adata Annotated data matrix. @@ -153,7 +153,7 @@ def get_df( Return values for specified key (in obs, var, obsm, varm, obsp, varp, uns, or layers) as a dataframe. - Arguments + Arguments: --------- data AnnData object or a numpy array to get values from. @@ -301,7 +301,7 @@ def get_initial_size( ) -> Optional[ndarray]: """Get initial counts per observation of a layer. - Arguments + Arguments: --------- adata Annotated data matrix. @@ -342,7 +342,7 @@ def get_initial_size( def get_modality(adata: AnnData, modality: Optional[str]) -> Union[ndarray, spmatrix]: """Extract data of one modality. - Arguments + Arguments: --------- adata Annotated data to extract modality from. @@ -369,7 +369,7 @@ 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 + Arguments: --------- adata Annotated data matrix. @@ -390,7 +390,7 @@ def make_dense( ) -> Optional[AnnData]: """Densify sparse AnnData entry. - Arguments + Arguments: --------- adata Annotated data object. @@ -425,7 +425,7 @@ def make_sparse( ) -> Optional[AnnData]: """Make AnnData entry sparse. - Arguments + Arguments: --------- adata Annotated data object. @@ -463,7 +463,7 @@ def merge( ) -> Optional[AnnData]: """Merge two annotated data matrices. - Arguments + Arguments: --------- adata Annotated data matrix (reference data set). @@ -552,7 +552,7 @@ def merge( def obs_df(adata: AnnData, keys: List[str], layer: Optional[str] = None) -> DataFrame: """Extract layer as Pandas DataFrame indexed by observation. - Arguments + Arguments: --------- adata Annotated data matrix (reference data set). @@ -586,7 +586,7 @@ def set_initial_size(adata: AnnData, layers: Optional[str] = None) -> None: The initial size is only set if it does not already exist. - Arguments + Arguments: --------- adata Annotated data matrix. @@ -620,7 +620,7 @@ def set_modality( ) -> Optional[AnnData]: """Set modality of annotated data object to new value. - Arguments + Arguments: --------- adata Annotated data object. @@ -658,7 +658,7 @@ def show_proportions( The proportions are printed. - Arguments + Arguments: --------- adata Annotated data matrix. @@ -696,7 +696,7 @@ def show_proportions( def var_df(adata: AnnData, keys: List[str], layer: Optional[str] = None): """Extract layer as Pandas DataFrame indexed by features. - Arguments + Arguments: --------- adata Annotated data matrix (reference data set). @@ -729,7 +729,7 @@ 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 + Arguments: --------- adata Annotated data matrix to check. diff --git a/scvelo/core/_arithmetic.py b/scvelo/core/_arithmetic.py index 8200cb98..02b98f1a 100644 --- a/scvelo/core/_arithmetic.py +++ b/scvelo/core/_arithmetic.py @@ -9,7 +9,7 @@ def clipped_log(x: ndarray, lb: float = 0, ub: float = 1, eps: float = 1e-6) -> ndarray: """Logarithmize between [lb + epsilon, ub - epsilon]. - Arguments + Arguments: --------- x Array to invert. @@ -31,7 +31,7 @@ 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 + Arguments: --------- x Array to invert. @@ -52,7 +52,7 @@ def multiply( ) -> Union[ndarray, spmatrix]: """Point-wise multiplication of arrays or sparse matrices. - Arguments + Arguments: --------- a First array/sparse matrix. @@ -77,7 +77,7 @@ def prod_sum( ) -> ndarray: """Take sum of product of two arrays along given axis. - Arguments + Arguments: --------- a1 First array. @@ -103,7 +103,7 @@ def prod_sum( def sum(a: Union[ndarray, spmatrix], axis: Optional[int] = None) -> ndarray: """Sum array elements over a given axis. - Arguments + Arguments: --------- a Elements to sum. diff --git a/scvelo/core/_base.py b/scvelo/core/_base.py index 2b525e9d..be7a40d7 100644 --- a/scvelo/core/_base.py +++ b/scvelo/core/_base.py @@ -14,7 +14,7 @@ def get_solution( ) -> Union[Dict, Tuple[ndarray], ndarray]: """Calculate solution of dynamics. - Arguments + Arguments: --------- t Time steps at which to evaluate solution. @@ -38,7 +38,7 @@ def get_steady_states( ) -> Union[Dict[str, ndarray], Tuple[ndarray], ndarray]: """Return steady state of system. - Arguments + Arguments: --------- stacked Whether to stack states or return them individually. Defaults to `True`. diff --git a/scvelo/core/_linear_models.py b/scvelo/core/_linear_models.py index dc4b9624..05d3c673 100644 --- a/scvelo/core/_linear_models.py +++ b/scvelo/core/_linear_models.py @@ -10,7 +10,7 @@ class LinearRegression: """Extreme quantile and constraint least square linear regression. - Arguments + Arguments: --------- percentile Percentile of data on which linear regression line is fit. If `None`, all data @@ -59,7 +59,7 @@ def __init__( def _trim_data(self, data: List) -> List: """Trim data to extreme values. - Arguments + Arguments: --------- data Data to be trimmed to extreme quantiles. @@ -97,7 +97,7 @@ def _trim_data(self, data: List) -> List: def fit(self, x: ndarray, y: ndarray): """Fit linear model per column. - Arguments + Arguments: --------- x Training data of shape `(n_obs, n_vars)`. @@ -107,7 +107,7 @@ def fit(self, x: ndarray, y: ndarray): Returns ------- self - Returns an instance of self. + Returns: an instance of self. """ n_obs = x.shape[0] diff --git a/scvelo/core/_metrics.py b/scvelo/core/_metrics.py index 5d2d9fe2..05a1f7cf 100644 --- a/scvelo/core/_metrics.py +++ b/scvelo/core/_metrics.py @@ -9,7 +9,7 @@ def l2_norm(x: Union[ndarray, spmatrix], axis: int = 1) -> Union[float, ndarray]: """Calculate l2 norm along a given axis. - Arguments + Arguments: --------- x Array to calculate l2 norm of. diff --git a/scvelo/core/_models.py b/scvelo/core/_models.py index 8538ddb5..9d9e9372 100644 --- a/scvelo/core/_models.py +++ b/scvelo/core/_models.py @@ -13,7 +13,7 @@ class SplicingDynamics(DynamicsBase): """Splicing dynamics. - Arguments + Arguments: --------- alpha Transcription rate. @@ -80,7 +80,7 @@ def get_solution( ) -> Union[Dict, ndarray]: """Calculate solution of dynamics. - Arguments + Arguments: --------- t Time steps at which to evaluate solution. @@ -122,7 +122,7 @@ def get_steady_states( ) -> Union[Dict[str, ndarray], Tuple[ndarray], ndarray]: """Return steady state of system. - Arguments + Arguments: --------- stacked Whether to stack states or return them individually. Defaults to `True`. diff --git a/scvelo/datasets/_datasets.py b/scvelo/datasets/_datasets.py index 616492cb..94231eff 100644 --- a/scvelo/datasets/_datasets.py +++ b/scvelo/datasets/_datasets.py @@ -60,7 +60,7 @@ 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 + Arguments: --------- file_path Path where to save dataset and read it from. @@ -150,7 +150,7 @@ def forebrain(file_path: Union[str, Path] = "data/ForebrainGlut/hgForebrainGlut. Forebrain tissue of a human week 10 embryo, focusing on glutamatergic neuronal lineage, obtained from elective routine abortions (10 weeks post-conception). - Arguments + Arguments: --------- file_path Path where to save dataset and read it from. @@ -260,7 +260,7 @@ 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 + Arguments: --------- file_path Path where to save dataset and read it from. @@ -308,7 +308,7 @@ def toy_data( ): """Randomly sampled from the Dentate Gyrus dataset. - Arguments + Arguments: --------- file_path Path where to save dataset and read it from. diff --git a/scvelo/inference/_metabolic_labeling.py b/scvelo/inference/_metabolic_labeling.py index 4fd8842d..adf11e93 100644 --- a/scvelo/inference/_metabolic_labeling.py +++ b/scvelo/inference/_metabolic_labeling.py @@ -15,7 +15,7 @@ def _get_bounds(experiment: np.ndarray): """Returns bounds for constraint optimization problem. - Arguments + Arguments: --------- experiment Type of experiment (``"chase"`` or ``"pulse"``) that observation was generated from. @@ -43,7 +43,7 @@ def get_mse( ): """Calculates mean squared error (MSE) between predicted and measurmed, newly synthesized mRNA. - Arguments + Arguments: --------- x Parameter estimate. @@ -87,7 +87,7 @@ def _get_n_neighbors( ) -> pd.DataFrame: """Get number of neighbors required to include ``n_nontrivial_counts`` counts per labeling time. - Arguments + Arguments: --------- X Gene expression. @@ -143,7 +143,9 @@ def _get_n_neighbors( def get_labeling_times(adata, time_key) -> List: """Get labeling times in dataset. - Arguments + See :cite:p:`Weiler2023`. + + Arguments: --------- adata AnnData object. @@ -162,7 +164,9 @@ def get_labeling_time_mask( ) -> Dict[float, np.ndarray]: """Get number of neighbors required to include ``n_nontrivial_counts`` counts per labeling time. - Arguments + See :cite:p:`Weiler2023`. + + Arguments: --------- adata AnnData object. @@ -187,7 +191,9 @@ def get_obs_dist_argsort( ) -> Dict[float, np.ndarray]: """Calculate argsorted pairwise distances per labeling_time_point. - Arguments + See :cite:p:`Weiler2023`. + + Arguments: --------- adata AnnData object. @@ -226,7 +232,9 @@ def get_n_neighbors( ) -> Dict[str, pd.DataFrame]: """Get number of neighbors required to include ``n_nontrivial_counts`` counts per labeling time. - Arguments + See :cite:p:`Weiler2023`. + + Arguments: --------- adata AnnData object. @@ -277,7 +285,7 @@ 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 + Arguments: --------- gex GEX vector of a given gene. @@ -321,7 +329,7 @@ def _get_parameters( ): """Estimates parameters of splicing kinetics from metabolic labeling data. - Arguments + Arguments: --------- measured_labeled Measured labeled RNA. @@ -381,7 +389,9 @@ def get_parameters( ): """Estimates parameters of splicing kinetics from metabolic labeling data. - Arguments + See :cite:p:`Weiler2023`. + + Arguments: --------- adata AnnData object containing data. diff --git a/scvelo/plotting/heatmap.py b/scvelo/plotting/heatmap.py index cc446956..b24a7c10 100644 --- a/scvelo/plotting/heatmap.py +++ b/scvelo/plotting/heatmap.py @@ -36,7 +36,7 @@ def heatmap( ): """Plot time series for genes as heatmap. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. @@ -76,7 +76,7 @@ def heatmap( If `True` or a `str`, save the figure. A string is appended to the default filename. Infer the filetype if ending on {'.pdf', '.png', '.svg'}. kwargs: - Arguments passed to seaborns clustermap, + Arguments: passed to seaborns clustermap, e.g., set `yticklabels=True` to display all gene names in all rows. Returns diff --git a/scvelo/plotting/paga.py b/scvelo/plotting/paga.py index 84111cc6..0cee178a 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). - Parameters - ---------- + Arguments: + --------- adata Annotated data matrix. threshold diff --git a/scvelo/plotting/proportions.py b/scvelo/plotting/proportions.py index ce5bfd4a..ce7f9452 100644 --- a/scvelo/plotting/proportions.py +++ b/scvelo/plotting/proportions.py @@ -22,7 +22,7 @@ def proportions( ): """Plot pie chart of spliced/unspliced proprtions. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/plotting/scatter.py b/scvelo/plotting/scatter.py index 84691312..2a8c2aa3 100644 --- a/scvelo/plotting/scatter.py +++ b/scvelo/plotting/scatter.py @@ -123,7 +123,7 @@ def scatter( ): """Scatter plot along observations or variables axes. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/plotting/utils.py b/scvelo/plotting/utils.py index 2e61531d..0f59918f 100644 --- a/scvelo/plotting/utils.py +++ b/scvelo/plotting/utils.py @@ -1008,7 +1008,7 @@ 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 + Arguments: --------- colors: : `list` or `array` (default `['royalblue', 'white', 'forestgreen']`) List of colors, either as names or rgb values. @@ -1461,7 +1461,7 @@ def hist( ): """Plot a histogram. - Arguments + Arguments: --------- arrays: : `list` or `array` (default `['royalblue', 'white', 'forestgreen']`) List of colors, either as names or rgb values. diff --git a/scvelo/plotting/velocity_embedding.py b/scvelo/plotting/velocity_embedding.py index e90eea8a..e8faaf26 100644 --- a/scvelo/plotting/velocity_embedding.py +++ b/scvelo/plotting/velocity_embedding.py @@ -70,7 +70,7 @@ def velocity_embedding( ): """Scatter plot of velocities on the embedding. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/plotting/velocity_embedding_grid.py b/scvelo/plotting/velocity_embedding_grid.py index 0d36b6da..c0d74131 100644 --- a/scvelo/plotting/velocity_embedding_grid.py +++ b/scvelo/plotting/velocity_embedding_grid.py @@ -152,7 +152,7 @@ def velocity_embedding_grid( ): """Scatter plot of velocities on a grid. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/plotting/velocity_embedding_stream.py b/scvelo/plotting/velocity_embedding_stream.py index d7fd0d7d..7d48c703 100644 --- a/scvelo/plotting/velocity_embedding_stream.py +++ b/scvelo/plotting/velocity_embedding_stream.py @@ -73,7 +73,7 @@ def velocity_embedding_stream( ): """Stream plot of velocities on the embedding. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/plotting/velocity_graph.py b/scvelo/plotting/velocity_graph.py index 90657d23..fe4f7199 100644 --- a/scvelo/plotting/velocity_graph.py +++ b/scvelo/plotting/velocity_graph.py @@ -47,7 +47,9 @@ def velocity_graph( ): """Plot of the velocity graph. - Arguments + Velocity graph with connectivities (dashed) and transitions (solid/arrows). + + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. @@ -56,16 +58,28 @@ def velocity_graph( n_neighbors: `int` (default: 10) Number of neighbors to be included for generating connectivity / velocity graph. arrows: `bool` (default: `None`) - Whether to display arrows instead of edges. - Recommended to be used only on a cluster by setting groups parameter. + Whether to display arrows instead of edges. Recommended to be used only on a + cluster by setting groups parameter. arrowsize: `int` (default: 3) Size of the arrow heads. + threshold: `float` (default: None) + Threshold below which values are set to zero. + edge_width: `float` (default: 0.2) + Line width of edges. + edge_color: `str` (default: "grey") + Edge color. Can be a single color or a sequence of colors with the same length + as edgelist. Color can be string or rgb (or rgba) tuple of floats from 0-1. If + numeric values are specified they will be mapped to colors using the edge_cmap + and edge_vmin,edge_vmax parameters. + edges_on_top: `bool` (default: None) + Whether or not to plot edges on top. {scatter} Returns ------- - `matplotlib.Axis` if `show==False` + If `show==False`, the `matplotlib.Axis` object. + This is a test. """ basis = default_basis(adata, **kwargs) if basis is None else get_basis(adata, basis) kwargs.update( @@ -128,7 +142,7 @@ def velocity_graph( warnings.simplefilter("ignore") X_emb = adata.obsm[f"X_{basis}"][:, get_components(components, basis)] node_size = (kwargs["size"] if "size" in kwargs else default_size(adata)) / 4 - edges = draw_networkx_edges( + edges = _draw_networkx_edges( DiGraph(T) if arrows else Graph(T), X_emb, node_size=node_size, @@ -146,7 +160,7 @@ def velocity_graph( return ax -def draw_networkx_edges( +def _draw_networkx_edges( G, pos, edgelist=None, diff --git a/scvelo/preprocessing/moments.py b/scvelo/preprocessing/moments.py index 590bd12e..a7511e83 100644 --- a/scvelo/preprocessing/moments.py +++ b/scvelo/preprocessing/moments.py @@ -22,7 +22,7 @@ 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 + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -103,7 +103,7 @@ def moments( def second_order_moments(adata, adjusted=False): """Computes second order moments for stochastic velocity estimation. - Arguments + Arguments: --------- adata: `AnnData` Annotated data matrix. @@ -133,7 +133,7 @@ def second_order_moments(adata, adjusted=False): def second_order_moments_u(adata): """Computes second order moments for stochastic velocity estimation. - Arguments + Arguments: --------- adata: `AnnData` Annotated data matrix. @@ -162,7 +162,7 @@ def get_moments( First and second order moments. If centered, that corresponds to means and variances across nearest neighbors. - Arguments + Arguments: --------- adata: `AnnData` Annotated data matrix. diff --git a/scvelo/preprocessing/utils.py b/scvelo/preprocessing/utils.py index cea850c4..c84497df 100644 --- a/scvelo/preprocessing/utils.py +++ b/scvelo/preprocessing/utils.py @@ -631,7 +631,7 @@ def filter_and_normalize( scv.pp.log1p(adata) - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/__init__.py b/scvelo/tools/__init__.py index bca29148..b2e3e126 100644 --- a/scvelo/tools/__init__.py +++ b/scvelo/tools/__init__.py @@ -54,4 +54,5 @@ "SteadyStateModel", "SecondOrderSteadyStateModel", "ExpectationMaximizationModel", + "VELOVI", ] diff --git a/scvelo/tools/_em_model.py b/scvelo/tools/_em_model.py index 0ef5fb39..343e9ce1 100644 --- a/scvelo/tools/_em_model.py +++ b/scvelo/tools/_em_model.py @@ -342,7 +342,7 @@ def _align_dynamics( ): """Align dynamics to a common set of parameters. - Arguments + Arguments: --------- t_max: `float`, `False` or `None` (default: `None`) Total range for time assignments. diff --git a/scvelo/tools/_em_model_core.py b/scvelo/tools/_em_model_core.py index ed4620f0..3a22fa2e 100644 --- a/scvelo/tools/_em_model_core.py +++ b/scvelo/tools/_em_model_core.py @@ -429,7 +429,7 @@ def recover_dynamics( .. image:: https://user-images.githubusercontent.com/31883718/69636459-ef862800-1056-11ea-8803-0a787ede5ce9.png - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -668,7 +668,7 @@ def align_dynamics( ): """Align dynamics to a common set of parameters. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -793,7 +793,7 @@ def latent_time( .. image:: https://user-images.githubusercontent.com/31883718/69636500-03318e80-1057-11ea-9e14-ae9f907711cc.png - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix @@ -972,7 +972,7 @@ def differential_kinetic_test( .. image:: https://user-images.githubusercontent.com/31883718/78930730-dc737200-7aa4-11ea-92f6-269b7609c3a5.png - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -1103,7 +1103,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 + Arguments: ---------- data : :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/_vi_model.py b/scvelo/tools/_vi_model.py index d4d8f1df..856cd8be 100644 --- a/scvelo/tools/_vi_model.py +++ b/scvelo/tools/_vi_model.py @@ -33,6 +33,8 @@ def _softplus_inverse(x: np.ndarray) -> np.ndarray: class VELOVI(VAEMixin, UnsupervisedTrainingMixin, BaseModelClass): """Velocity Variational Inference. + See :cite:p:`Gayoso2023` for details. + Parameters ---------- adata diff --git a/scvelo/tools/rank_velocity_genes.py b/scvelo/tools/rank_velocity_genes.py index dcfd426e..1ab248e8 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 + Arguments: ---------- 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 + Arguments: ---------- data : :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/terminal_states.py b/scvelo/tools/terminal_states.py index 06b80269..4131fdcc 100644 --- a/scvelo/tools/terminal_states.py +++ b/scvelo/tools/terminal_states.py @@ -20,7 +20,7 @@ def cell_fate( ): """Computes individual cell endpoints. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -86,7 +86,7 @@ def cell_origin( ): """Computes individual cell root points. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -239,7 +239,7 @@ def terminal_states( Alternatively, we recommend to use :func:`cellrank.tl.terminal_states` providing an improved/generalized approach of identifying terminal states. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/transition_matrix.py b/scvelo/tools/transition_matrix.py index 15bcfd43..bab7e2a6 100644 --- a/scvelo/tools/transition_matrix.py +++ b/scvelo/tools/transition_matrix.py @@ -39,7 +39,7 @@ def transition_matrix( Alternatively, use :func:`cellrank.tl.transition_matrix` to account for uncertainty in the velocity estimates. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. @@ -171,7 +171,7 @@ def get_cell_transitions( ): """Simulate cell transitions. - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/velocity.py b/scvelo/tools/velocity.py index 9ffffde5..32fbdc9f 100644 --- a/scvelo/tools/velocity.py +++ b/scvelo/tools/velocity.py @@ -267,7 +267,7 @@ def velocity( .. image:: https://user-images.githubusercontent.com/31883718/69636491-ff057100-1056-11ea-90b7-d04098112ce1.png - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -498,7 +498,7 @@ def velocity_genes( ): """Estimates velocities in a gene-specific manner. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/velocity_confidence.py b/scvelo/tools/velocity_confidence.py index f6332c56..f8e795e3 100644 --- a/scvelo/tools/velocity_confidence.py +++ b/scvelo/tools/velocity_confidence.py @@ -19,7 +19,7 @@ def velocity_confidence(data, vkey="velocity", copy=False): :width: 600px - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -28,7 +28,7 @@ def velocity_confidence(data, vkey="velocity", copy=False): copy: `bool` (default: `False`) Return a copy instead of writing to adata. - Returns + Returns: ------- velocity_length: `.obs` Length of the velocity vectors for each individual cell @@ -78,7 +78,7 @@ 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 + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/velocity_embedding.py b/scvelo/tools/velocity_embedding.py index 20bb4e29..b0e4cef0 100644 --- a/scvelo/tools/velocity_embedding.py +++ b/scvelo/tools/velocity_embedding.py @@ -61,7 +61,7 @@ def velocity_embedding( \delta_{ij}. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/velocity_graph.py b/scvelo/tools/velocity_graph.py index ad2bf7f5..0c8482d5 100644 --- a/scvelo/tools/velocity_graph.py +++ b/scvelo/tools/velocity_graph.py @@ -290,7 +290,7 @@ def velocity_graph( = \frac{\delta_{ij}^T \nu_i}{\left\lVert\delta_{ij}\right\rVert \left\lVert \nu_i \right\rVert}. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. diff --git a/scvelo/tools/velocity_pseudotime.py b/scvelo/tools/velocity_pseudotime.py index ad245cd9..9554574c 100644 --- a/scvelo/tools/velocity_pseudotime.py +++ b/scvelo/tools/velocity_pseudotime.py @@ -12,7 +12,7 @@ def principal_curve(data, basis="pca", n_comps=4, clusters_list=None, copy=False): """Computes the principal curve. - Arguments + Arguments: --------- data: :class:`~anndata.AnnData` Annotated data matrix. @@ -167,7 +167,7 @@ def velocity_pseudotime( .. image:: https://user-images.githubusercontent.com/31883718/69545487-33fbc000-0f92-11ea-969b-194dc68400b0.png :width: 600px - Arguments + Arguments: --------- adata: :class:`~anndata.AnnData` Annotated data matrix diff --git a/tests/conftest.py b/tests/conftest.py index ad27a231..ebe0df65 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -272,7 +272,7 @@ def _get_dentategyrus_50obs( preprocessed Boolean identifier whether or not to return preprocessed dataset. - Returns + Returns: ------- Union[AnnData, Tuple[AnnData, AnnData]] Specified version of dataset. @@ -298,7 +298,7 @@ def _get_dentategyrus_100obs( preprocessed Boolean identifier whether or not to return preprocessed dataset. - Returns + Returns: ------- Union[AnnData, Tuple[AnnData, AnnData]] Specified version of dataset. @@ -326,7 +326,7 @@ def _get_dentategyrus_adata( preprocessed Boolean identifier whether or not to return preprocessed dataset. - Returns + Returns: ------- Union[AnnData, Tuple[AnnData, AnnData]] Specified version of dataset. @@ -350,7 +350,7 @@ def _get_pancreas_50obs( preprocessed Boolean identifier whether or not to return preprocessed dataset. - Returns + Returns: ------- Union[AnnData, Tuple[AnnData, AnnData]] Specified version of dataset. @@ -376,7 +376,7 @@ def _get_pancreas_100obs( preprocessed Boolean identifier whether or not to return preprocessed dataset. - Returns + Returns: ------- Union[AnnData, Tuple[AnnData, AnnData]] Specified version of dataset. @@ -404,7 +404,7 @@ def _get_pancreas_adata( preprocessed Boolean identifier whether or not to return preprocessed dataset. - Returns + Returns: ------- Union[AnnData, Tuple[AnnData, AnnData]] Specified version of dataset. diff --git a/tests/core/test_base.py b/tests/core/test_base.py index a145e599..062db52f 100644 --- a/tests/core/test_base.py +++ b/tests/core/test_base.py @@ -44,7 +44,7 @@ def get_adata( The largest possible value of a numerical entry is `1e5`. - Arguments + Arguments: --------- n_obs Number of observations. If set to `None`, a random integer between `1` and @@ -112,7 +112,7 @@ def get_adata( sparse_entries Whether or not to make AnnData entries sparse. - Returns + Returns: ------- AnnData Generated :class:`~anndata.AnnData` object.