Skip to main content

Python wrapper for Azimuth (Seurat-based single-cell mapping) using rpy2

Project description

azimuthpy

Python License


azimuthpy is a lightweight Python package that enables seamless integration with the Azimuth reference mapping framework from the Satija Lab, using rpy2.
It allows you to map single-cell RNA-seq datasets (in Python AnnData format) to Azimuth references without leaving Python.

  • Supports direct AnnDataSeurat conversion
  • Maps queries using Azimuth::MapQuery()
  • Pulls predictions and annotations back into AnnData.obs
  • Fully in-memory, no saving intermediate files

Installation

You need to have R installed on your machine with the following R packages:

Install:

pip install azimuthpy

Or using Conda:

# takes 15+ min...
conda env create -f environment.yml
conda activate azimuthpy_conda

If r-azimuth is not available through Conda, install it manually inside R:

install.packages("remotes")
remotes::install_github("satijalab/azimuth")

How to Use

import scanpy as sc
from azimuthpy import annotate_adata_azimuth

Load example dataset

adata = sc.datasets.pbmc3k()
adata

Preprocess

sc.pp.highly_variable_genes(adata, n_top_genes=2000, subset=True, flavor="seurat_v3") # Optional

# Store raw counts in adata.layers["raw_counts"]
adata.layers["raw_counts"] = adata.X

Map to Azimuth reference

You can download references from https://azimuth.hubmapconsortium.org/


# e.g., from https://azimuth.hubmapconsortium.org/references/#Human%20-%20Lung%20v2%20%28HLCA%29
# -> Zenodo: https://zenodo.org/records/6342228
# wget -c https://zenodo.org/api/records/6342228/files-archive
# unzip ...

adata = annotate_adata_azimuth(adata, reference_path="path/to/folder/",
                                        use_layer="raw_counts",
                                        umap_name="ref.umap")

View predicted labels

adata.obs[['predicted.celltype.l1', 'prediction.score.celltype.l1']]

For a full tutorial, see tutorial/gettingStarted.ipynb.

For more info, take a look at the original azimuth R page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azimuthpy-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azimuthpy-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file azimuthpy-0.1.0.tar.gz.

File metadata

  • Download URL: azimuthpy-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for azimuthpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8fe94260166440503c635bcd8dea8283bfc602fdc2e46b62bb22ac5c4130ffa6
MD5 24ccfebeb8d0b3ad6f0c43894fca4dd7
BLAKE2b-256 6e8f64f601890b70b19440858bb07edbda51c7a9eb5baf981b9ba6c729c8374b

See more details on using hashes here.

File details

Details for the file azimuthpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: azimuthpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for azimuthpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4bd203447d196194df70a5422818a22f6249da8b40a4b5e291fc4a9b4eb3fe64
MD5 e1ec9501204a63bad4df1e0bf6ad0a3b
BLAKE2b-256 6a29a5312e0b392429494e75476b0c00329aa0c620915cefb3a2c3e4c2379bc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page