Skip to main content

Ouroboros

Ouroboros

Ouroboros is a variational autoencoder that infers cell cycle phase, cell cycle pseudotime and dormancy pseudotime from scRNA-seq datasets. New cells are mapped onto a common pre-trained embedding, enabling comparative quantitative analyses along dormancy pseudotime between samples and experimental conditions.

For more information see the Wiki: wiki

Installation

Ouroboros supports Python 3.9–3.10. Cartopy is an optional dependency required for some plotting functions. It is recommended to install via conda before installing Ouroboros.

Installation:

conda create -n ouroboros_env -c conda-forge python=3.9 pip=24.3.1
conda activate ouroboros_env 
conda install -c conda-forge cartopy -y
pip install ouroboros

Alternatively, you can install directly from conda:

conda install steiflab::ouroboros

Install directly from GitHub (not recommended):

pip install git+https://github.com/steiflab/Ouroboros.git

ScPhere is included as part of Ouroboros and has been updated for compatibility with TensorFlow 2. ScPhere was originally developed by Jiarui Ding and colleagues at the Klarman Cell Observatory.

Running Ouroboros within a scanpy workflow isn't strictly necessary, but if you want to work within a scanpy workflow as outlined in the tutorial, install scanpy into the environment like so:

conda activate ouroboros_env
mamba install -c conda-forge "scanpy>=1.9.3,<1.11"

Running Ouroboros

For a full tutorial see the Wiki: wiki

There are seperate tutorials for python (scanpy) and R (seurat) users, and an additonal tutorial to embed RNA velocity vectors into the sphere.

To run Ouroboros on an h5ad/ Scanpy object

Ouroboros requires raw count data. Before running Ouroboros, make sure your raw counts are stored in adata.layers["raw_counts"], and save your Scanpy object as an .h5ad file.

Gene names must be in HUGO gene symbol format rather than Ensembl IDs.

anndata.write_h5ad('adata.h5ad')

For .csv input, gene names should be provided as column names (in HUGO gene symbol format), and cell IDs should be provided as row names.

Then you can run Ouroboros on the command line like so:

ouroboros \
    --data /path/to/h5ad  \
    --data_type h5ad \
    --species human \
    --outdir /path/to/output/directory \
    --seed 0 \
    --repeat 5 

Arguments:

Argument Description
--data Required. Path to your input data file. Must be a .h5ad or .csv file.
--data_type Required. Format of the input data. Must be h5ad or csv.
--species Species of origin for the dataset. Must be human or mouse. Default is human
--outdir Output directory where results (embeddings, figures, logs) will be saved. Default is '.'
--seed Seed used for Ouroborous for data reproducibility. Default is 0
--repeat* Number of times to retrain model (only if input data is missing any training genes). Default is 1.
--force Ignore input validation checks (raw counts and missing genes) and continue (not recommended)

* If any gene is missing from training feature set from the input data, the model must be retrained. To ensure robust performance, Ouroboros will retrain the VAE {repeat} times and select the model that correlates with the consensus. However, increasing the repeat parameter will significantly extend runtime.

Ouroboros Output

The main output from Ouroboros is ouroboros_embedding_pseudotime.csv, where each row represents a cell embedded in the spherical latent space. The columns are described below:

Column Description
dim1, dim2, dim3 Three-dimensional coordinates of each cell in the spherical latent space. These coordinates are used by the plot_sphere and plot_robinson_plot functions.
KNN_phase Cell-cycle phase assigned using K-nearest neighbors (KNN) based on the training dataset: G1, S, G2M, G1-G0 transition, or G0.
south Indicates whether a cell is located in the southern hemisphere. True indicates a dormant cell with a dormancy_pseudotime; False indicates a cycling cell with a cell_cycle_pseudotime.
cell_cycle_pseudotime Pseudotime for cycling cells, calculated from the angular position in the northern hemisphere. Values range from 0 to 1.
dormancy_pseudotime Pseudotime for dormant cells, calculated from the distance toward the southern pole. Values range from -1 to 0.
pseudotime_phase Phase/state annotation based on pseudotime thresholds: G1 (0–0.4), S (0.4–0.75), G2M (0.75–1), Light dormancy (-0.4–0), Mid dormancy (-0.6–-0.4), and Deep dormancy (-1–-0.6).

If the input matrix is missing one or more genes required by the training dataset, Ouroboros will retrain the model using the available training genes. Retraining may reduce model accuracy. When retraining occurs, retrained_reference_embedding.csv is generated, containing the three-dimensional latent-space coordinates of the retrained reference cells and their ground-truth phase labels. A qc.csv file is also generated containing quality-control metrics for the retrained model, including the number of missing training genes, KL divergence, log-likelihood, and SHAP score loss attributable to missing genes.

Ouroboros also generates three interactive spherical plots: ouroboros_cell_cycle_pseudotime.html, which displays cells coloured by cell-cycle pseudotime, ouroboros_dormancy_pseudotime.html, which displays cells coloured by dormancy pseudotime and ouroboros_KNN_phase.html, which displays cells coloured by discrete KNN_phase. The distribution of pseudotime values is additionally provided as pseudotime_histogram.png.

Plotting Ouroboros output

We have included several python functions to help you explore the Ouroboros output sphere.

See Wiki tutorials for more information

Acknowledgements

This project makes use of scPhere, developed by the Broad Institute and distributed under the BSD 3-Clause License.

We have included a lightly modified version of scPhere (updated for TensorFlow 2.x support) within this repository.

If you use functionality derived from scPhere, please also cite: Ding, J., Regev, A. Deep generative model embedding of single-cell RNA-Seq profiles on hyperspheres and hyperbolic spaces. Nat Commun 12, 2554 (2021). https://doi.org/10.1038/s41467-021-22851-4

License

Ouroboros is distributed under the MIT License (see LICENSE). scPhere is distributed under the BSD 3-Clause License (see scphere/LICENSE).

Metadata

Release files for ouroboros 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ouroboros 1.0.4
File Size Uploaded Provenance
ouroboros-1.0.4.tar.gz 15.3 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ouroboros 1.0.4
File Interpreter ABI Platform
ouroboros-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 32.7 MB

Release files / ouroboros-1.0.4.tar.gz

Download URL ouroboros-1.0.4.tar.gz
Size 15.3 MB
Tags Source
SHA-256 checksum
How to use checksums
215a680f9161fe2c1a420473669d553a974a53b437f5d8288121e5d7686bf0bc
BLAKE2b-256 checksum
How to use checksums
709791a3ea00b55e223723634521fee4c93f643cb2bc27e6a7bda94e90084a35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / ouroboros-1.0.4-py3-none-any.whl

Download URL ouroboros-1.0.4-py3-none-any.whl
Size 17.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4763ed92c1bb2d3054de0be23bf1995ca81787857def69c31328af6f4b3fc5d4
BLAKE2b-256 checksum
How to use checksums
6425b436501b010d16509016a1131dc788c16951277b9397f6e355c4f499e7e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for ouroboros 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page