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 using rpy2.
It lets you map single-cell RNA-seq datasets (in Python AnnData format) to Azimuth references in Python.

  • Supports direct AnnDataSeurat conversion
  • 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.1.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.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: azimuthpy-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 fdd1ae08a0c21a51150c63ba35bad6508464329d906614c4bc3b9592a6056255
MD5 77da6a750d95636061f79f1c8e418a5a
BLAKE2b-256 f754f595270ef74f5982e899e3aaede0f0d36d37fddccb594c84456b2e72621d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: azimuthpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ea6554265f42b11bf70e787f095d938473f95a5314497745b0c9567eb3483be
MD5 434c97a025118651558a08b22386e658
BLAKE2b-256 5eb6668f573080e3de021dd5771fb41bec02123c976b489d52607f0d6c1a07b2

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