Skip to main content

Converter between Python’s AnnData and R’s SingleCellExperiment.

Project description

pypi conda travis doi

AnnData ↭ SingleCellExperiment

RPy2 converter from AnnData to SingleCellExperiment and back.

You can for example use it to process your data using both Scanpy and Seurat, as described in this example notebook

Installation

pip install anndata2ri
# or
conda install -c bioconda anndata2ri

Troubleshooting

If you have problems installing or importing anndata2ri, please make sure you first:

  1. Check the stack trace: If the error happens while installing or importing a dependency such as rpy2, report your problem in that project’s bug tracker.

  2. Search the issues. At the time of writing 17 of the 29 bugs (60%) are invalid or rpy2 bugs / install problems.

  3. Make sure you have a compatible R version: rpy2 requires R ≥ 3.6.

Usage from Python

Either use the converter manually …

import anndata2ri
from rpy2.robjects import r
from rpy2.robjects.conversion import localconverter

with localconverter(anndata2ri.converter):
    adata = r('as(some_data, "SingleCellExperiment")')

… or activate it globally:

import anndata2ri
from rpy2.robjects import r
anndata2ri.activate()

adata = r('as(some_data, "SingleCellExperiment")')

Usage from Jupyter

Activate the conversion before you load the extension:

import anndata2ri
anndata2ri.activate()
%load_ext rpy2.ipython

Now you can move objects from Python to R …

import scanpy.datasets as scd
adata_paul = scd.paul15()
%%R -i adata_paul
adata_paul  # class: SingleCellExperiment ...

… and back:

%%R -o adata_allen
data(allen, package = 'scRNAseq')
adata_allen <- as(allen, 'SingleCellExperiment')
print(adata_allen)  # AnnData object with ...

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

anndata2ri-1.0.4.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

anndata2ri-1.0.4-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file anndata2ri-1.0.4.tar.gz.

File metadata

  • Download URL: anndata2ri-1.0.4.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for anndata2ri-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b98b3c9c86d52d88d898aa2d0be1337013d76497b3cc1c9851ec74ed1e11bb09
MD5 94f61db1d0bd099343652728b4cb0114
BLAKE2b-256 a2770e665f09ae5738f444f54fb32840ac2f1f28b1e19561558603353a07b88f

See more details on using hashes here.

File details

Details for the file anndata2ri-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: anndata2ri-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for anndata2ri-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7b10501323ac29be1ee531100d12a3d4384e41551412c7e07e8e973a3ad24f8b
MD5 89c3951bb8434d1a31f340bc7bf543ea
BLAKE2b-256 7a9f77d96cc12345fcab6bcb361d6df3e2583e075bc0414052220124261c9a50

See more details on using hashes here.

Supported by

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