anndata2ri 2.0


pip install anndata2ri

  Latest version

Released: Aug 11, 2025


Meta
Author: Philipp A.
Requires Python: >=3.11

Classifiers

Development Status
  • 4 - Beta

Intended Audience
  • Developers
  • Science/Research

License
  • OSI Approved :: GNU General Public License v3 or later (GPLv3+)

Programming Language
  • Python :: 3 :: Only
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • R

Topic
  • Scientific/Engineering :: Bio-Informatics

PyPI Version Bioconda Version Documentation Status Unit Tests Publication DOI

AnnData ↭ SingleCellExperiment

RPy2 converter from AnnData to SingleCellExperiment and back. (For details about conversion see the docs)

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

Use the converter as a context manager:

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

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

Usage from Jupyter

Override the R magic option:

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

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 ...

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
anndata
rpy2 (>=3.5.2)
tzlocal