Skip to main content

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

Project description

pypi conda 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.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.1.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

anndata2ri-1.0.1-py3-none-any.whl (59.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for anndata2ri-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e75c7893a4e68fcdd5eaf106dfa7f189c47de9565c9de5d3e4888fcc2fee6d5f
MD5 6a6268a3b498f97ed4bbd37d183439a0
BLAKE2b-256 a7baeb656ea6d2962557754ef862a070efe84121ec927a02caa694e1d57d27e0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for anndata2ri-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f035cef8fba49aba504ba74fcfbb366b1e5ea2499bff5d99c9f13fa096eb130
MD5 3da4d91ffae0fbabbfa14fbbd97dc0f5
BLAKE2b-256 16789c9d7f5d9ce4cca24c3532bd0bd4e9d57660f74599ad42ed8499d290d201

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