Converter between Python’s AnnData and R’s SingleCellExperiment.
Project description
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
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
Release history Release notifications | RSS feed
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.2.tar.gz
(25.9 kB
view details)
Built Distribution
File details
Details for the file anndata2ri-1.0.2.tar.gz
.
File metadata
- Download URL: anndata2ri-1.0.2.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1c647bb4816ac2d11d180fcded274f367cee776a0bfdaaa127b6d23219cf65d |
|
MD5 | efc2cd02caae0756b14c4e31351060f3 |
|
BLAKE2b-256 | d4591785a161d816a61934771196b5f608b47249a66adad28a146822a2580807 |
File details
Details for the file anndata2ri-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: anndata2ri-1.0.2-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38da642c09ab41071f2845db815397b173d1fb5df6fc2bd947f78a3bad25adcc |
|
MD5 | f2b756f7d60ec821dede82a8353a4d1e |
|
BLAKE2b-256 | 0cedc6122175ff99a09d8f4f18fd8ac63cd9608fd912f3c501f14a9a99700af7 |