Skip to main content

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

Project description

travis

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

Install it directly from GitHub via pip (version 19.0 or higher).

pip install git+https://github.com/flying-sheep/anndata2ri.git

You can install a locally checked out version with pip or flit:

cd anndata2ri
pip install .
# or
flit install

Usage from Python

Either use the converter manually …

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

with localconverter(anndata2ri.create_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 IPython

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.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

anndata2ri-1.0-py3-none-any.whl (59.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for anndata2ri-1.0.tar.gz
Algorithm Hash digest
SHA256 e2f8d3aed1fcf78e86688f3ceedf109b7e432c47f2508c168d69e3b8bf6e4f39
MD5 252a6d8edcfdcf9d46785df0235f412b
BLAKE2b-256 d91d410ca5fc36b1f49e8500d9ec34b043b2256ecf971a915f21273a8429f6bd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for anndata2ri-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c392036ec92ad82bac1bb7edf4e871f093b4faa6708121463c2af954410343fc
MD5 1cc34a716f430e7e0b4d0a2fa137bc8b
BLAKE2b-256 b70934c48ce5b4e99d022dcde7e1643f4a9c1523fc91bb916b1c97891bdbdadd

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