Skip to content

ivirshup/anndata2ri

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

travis

AnnData ↭ SingleCellExperiment

RPy2 converter from AnnData to SCE and back.

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 85.5%
  • Jupyter Notebook 14.5%