# UniTVelo for RNA Velocity Analysis
Temporally unified RNA velocity for single cell trajectory inference (UniTVelo) is implementated on Python 3 and TensorFlow 2. The model estimates velocity of each gene and updates cell time based on phase portraits concurrently.
![human bone marrow velocity stream](figures/HumanBoneMarrow.png)
The major features of UniTVelo are,
* Using spliced RNA oriented design to model RNA velocity and transcription rates
* Introducing a unified latent time (`Unified-time mode`) across whole transcriptome to incorporate stably and monotonically changed genes
* Retaining gene-spcific time matrics (`Independent mode`) for complex datasets
UniTVelo has proved its robustness in 10 different datasets. Details can be found via our manuscript in bioRxiv which is currently under review ([UniTVelo](https://www.biorxiv.org/content/10.1101/2022.04.27.489808v1)).
## Installation
### GPU Acceleration
UniTVelo is designed based on TensorFlow's automatic differentiation architecture. Please make sure [TensorFlow 2](https://www.tensorflow.org/install) and relative [CUDA](https://developer.nvidia.com/cuda-downloads) dependencies are correctly installed.
Use the following scripts to confirm TensorFlow is using the GPU.
```python3
import tensorflow as tf
print ("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
```
If GPU is not available, UniTVelo will automatically switch to CPU for model fitting or it can be spcified in `config.py` (see `Getting Started` below).
### Main Module
(Optional) Create a separate conda environment for version control and to avoid potential conflicts.
```python3
conda create -n unitvelo python=3.7
conda activate unitvelo
```
UniTVelo package can be conveniently installed via PyPI or directly from GitHub repository.
```python3
pip install unitvelo
```
or
```python3
pip install git+https://github.com/StatBiomed/UniTVelo
```
## Getting Started
### Public Datasets
Examples of UniTVelo and steps for reproducible results are provided in Jupyter Notebook under `notebooks` folder. Specifically, please refer to records analyzing [Mouse Erythroid](notebooks/Figure2_ErythroidMouse.ipynb) and [Human Bone Marrow](notebooks/Figure3_BoneMarrow.ipynb) datasets.
UniTVelo has proved its performance through 10 different datasets and 4 of them have been incorporated within scVelo package, see [datasets](notebooks/README.md). Others can be obtained via [link](https://connecthkuhk-my.sharepoint.com/:f:/g/personal/gmz1229_connect_hku_hk/EkC47RWWUrtOqcWzJ0neDGEBKLZTHWZW7PPe3vhUo9sn6g?e=QyoLFJ).
### RNA Velocity on New Dataset
UniTVelo provides an integrated function for velocity analysis by default whilst specific configurations might need to be adjusted accordingly.
1. Import package
```python3
import unitvelo as utv
```
2. Sub-class and override base configuration file (here lists a few frequently used), please refer `config.py` for detailed arguments.
```python3
velo = utv.config.Configuration()
velo.R2_ADJUST = True
velo.IROOT = None
velo.FIT_OPTION = '1'
velo.GPU = 0
```
* Arguments:
* -- `velo.R2_ADJUST` (bool), linear regression R-squared on extreme quantile (default) or full data (adjusted)
* -- `velo.IROOT` (str), specify root cell cluster would enable diffusion map based time initialization, default None
* -- `velo.FIT_OPTION` (str), '1' Unified-time mode (default), '2' Independent mode
* -- `velo.GPU` (int), specify the GPU card used for fitting, -1 will switch to CPU mode, default 0.
3. Run model (label refers to column name in adata.obs specifying celltypes)
```python3
adata = utv.run_model(path_to_adata, label, config_file=velo)
scv.pl.velocity_embedding_stream(adata, color=label, dpi=100, title='')
```
4. Evaluation metrics (Optional)
```python3
# Cross Boundary Direction Correctness
# Ground truth should be given via `cluster_edges`
metrics = {}
metrics = utv.evaluate(adata, cluster_edges, label, 'velocity')
# Latent time estimation
scv.pl.scatter(adata, color='latent_time', color_map='gnuplot', size=20)
# Phase portraits for individual genes (experimental)
utv.pl.plot_range(gene_name, adata, velo, show_ax=True, time_metric='latent_time')
```
Raw data
{
"_id": null,
"home_page": "https://github.com/StatBiomed/UniTVelo",
"name": "unitvelo",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.0",
"maintainer_email": "",
"keywords": "RNA velocity,Unified time,Transcriptomics,Kinetic,Trajectory inference",
"author": "Mingze Gao",
"author_email": "gmz1229@connect.hku.hk",
"download_url": "https://files.pythonhosted.org/packages/05/c3/73151ce261fd8a41c8fe7b51f41181c01c6af3e40f8068c04148f1aa6a4e/unitvelo-0.2.5.2.tar.gz",
"platform": null,
"description": "\n# UniTVelo for RNA Velocity Analysis\n\nTemporally unified RNA velocity for single cell trajectory inference (UniTVelo) is implementated on Python 3 and TensorFlow 2. The model estimates velocity of each gene and updates cell time based on phase portraits concurrently.\n![human bone marrow velocity stream](figures/HumanBoneMarrow.png)\n\nThe major features of UniTVelo are,\n\n* Using spliced RNA oriented design to model RNA velocity and transcription rates\n* Introducing a unified latent time (`Unified-time mode`) across whole transcriptome to incorporate stably and monotonically changed genes\n* Retaining gene-spcific time matrics (`Independent mode`) for complex datasets\n\nUniTVelo has proved its robustness in 10 different datasets. Details can be found via our manuscript in bioRxiv which is currently under review ([UniTVelo](https://www.biorxiv.org/content/10.1101/2022.04.27.489808v1)).\n\n## Installation\n\n### GPU Acceleration\n\nUniTVelo is designed based on TensorFlow's automatic differentiation architecture. Please make sure [TensorFlow 2](https://www.tensorflow.org/install) and relative [CUDA](https://developer.nvidia.com/cuda-downloads) dependencies are correctly installed.\n\nUse the following scripts to confirm TensorFlow is using the GPU.\n\n```python3\nimport tensorflow as tf\nprint (\"Num GPUs Available: \", len(tf.config.list_physical_devices('GPU')))\n```\n\nIf GPU is not available, UniTVelo will automatically switch to CPU for model fitting or it can be spcified in `config.py` (see `Getting Started` below).\n\n### Main Module\n\n(Optional) Create a separate conda environment for version control and to avoid potential conflicts.\n\n```python3\nconda create -n unitvelo python=3.7\nconda activate unitvelo\n```\n\nUniTVelo package can be conveniently installed via PyPI or directly from GitHub repository.\n\n```python3\npip install unitvelo\n```\n\nor\n\n```python3\npip install git+https://github.com/StatBiomed/UniTVelo\n```\n\n## Getting Started\n\n### Public Datasets\n\nExamples of UniTVelo and steps for reproducible results are provided in Jupyter Notebook under `notebooks` folder. Specifically, please refer to records analyzing [Mouse Erythroid](notebooks/Figure2_ErythroidMouse.ipynb) and [Human Bone Marrow](notebooks/Figure3_BoneMarrow.ipynb) datasets.\n\nUniTVelo has proved its performance through 10 different datasets and 4 of them have been incorporated within scVelo package, see [datasets](notebooks/README.md). Others can be obtained via [link](https://connecthkuhk-my.sharepoint.com/:f:/g/personal/gmz1229_connect_hku_hk/EkC47RWWUrtOqcWzJ0neDGEBKLZTHWZW7PPe3vhUo9sn6g?e=QyoLFJ).\n\n### RNA Velocity on New Dataset\n\nUniTVelo provides an integrated function for velocity analysis by default whilst specific configurations might need to be adjusted accordingly.\n\n1. Import package\n\n```python3\nimport unitvelo as utv\n```\n\n2. Sub-class and override base configuration file (here lists a few frequently used), please refer `config.py` for detailed arguments.\n\n```python3\nvelo = utv.config.Configuration()\nvelo.R2_ADJUST = True \nvelo.IROOT = None\nvelo.FIT_OPTION = '1'\nvelo.GPU = 0\n```\n\n* Arguments:\n * -- `velo.R2_ADJUST` (bool), linear regression R-squared on extreme quantile (default) or full data (adjusted)\n * -- `velo.IROOT` (str), specify root cell cluster would enable diffusion map based time initialization, default None\n * -- `velo.FIT_OPTION` (str), '1' Unified-time mode (default), '2' Independent mode\n * -- `velo.GPU` (int), specify the GPU card used for fitting, -1 will switch to CPU mode, default 0.\n\n3. Run model (label refers to column name in adata.obs specifying celltypes)\n\n```python3\nadata = utv.run_model(path_to_adata, label, config_file=velo)\nscv.pl.velocity_embedding_stream(adata, color=label, dpi=100, title='')\n```\n\n4. Evaluation metrics (Optional)\n\n```python3\n# Cross Boundary Direction Correctness\n# Ground truth should be given via `cluster_edges`\nmetrics = {}\nmetrics = utv.evaluate(adata, cluster_edges, label, 'velocity')\n\n# Latent time estimation\nscv.pl.scatter(adata, color='latent_time', color_map='gnuplot', size=20)\n\n# Phase portraits for individual genes (experimental)\nutv.pl.plot_range(gene_name, adata, velo, show_ax=True, time_metric='latent_time')\n```\n\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Temporally unified RNA velocity inference",
"version": "0.2.5.2",
"split_keywords": [
"rna velocity",
"unified time",
"transcriptomics",
"kinetic",
"trajectory inference"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5e5d0a9cdd47e480c9311fa1bb3c670a43762fd367f23d9bd45f6f0eab8311c7",
"md5": "1dd4188641fa60e1dd822bb1627aebd8",
"sha256": "44e74ee6501eaca98f8236d05e8ab6cfa6718d3e9d82d0f0598c22e5b48101f8"
},
"downloads": -1,
"filename": "unitvelo-0.2.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1dd4188641fa60e1dd822bb1627aebd8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.0",
"size": 38710,
"upload_time": "2023-01-12T07:13:31",
"upload_time_iso_8601": "2023-01-12T07:13:31.444787Z",
"url": "https://files.pythonhosted.org/packages/5e/5d/0a9cdd47e480c9311fa1bb3c670a43762fd367f23d9bd45f6f0eab8311c7/unitvelo-0.2.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "05c373151ce261fd8a41c8fe7b51f41181c01c6af3e40f8068c04148f1aa6a4e",
"md5": "119aa8286d5651ff43769662733d1d4a",
"sha256": "30e09218c5de9452e5f0c74287fe3a3775b2739c1a162f25be6e4a1c36770ddb"
},
"downloads": -1,
"filename": "unitvelo-0.2.5.2.tar.gz",
"has_sig": false,
"md5_digest": "119aa8286d5651ff43769662733d1d4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.0",
"size": 35517,
"upload_time": "2023-01-12T07:13:34",
"upload_time_iso_8601": "2023-01-12T07:13:34.074692Z",
"url": "https://files.pythonhosted.org/packages/05/c3/73151ce261fd8a41c8fe7b51f41181c01c6af3e40f8068c04148f1aa6a4e/unitvelo-0.2.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-12 07:13:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "StatBiomed",
"github_project": "UniTVelo",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "unitvelo"
}