Converter between Python’s AnnData and R’s SingleCellExperiment.
Project description
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:
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.
Search the issues. At the time of writing 17 of the 29 bugs (60%) are invalid or rpy2 bugs / install problems.
Make sure you have a compatible R version: rpy2 requires R ≥ 3.6.
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 Jupyter
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
Built Distribution
File details
Details for the file anndata2ri-1.0.5.tar.gz
.
File metadata
- Download URL: anndata2ri-1.0.5.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fda05066dc46148cd0050d41327313b9999d5c461aa274afd3429c31d79a98b3 |
|
MD5 | 0f81e81a0e4ad095b1fe6ebb21794123 |
|
BLAKE2b-256 | 65320178565535aa36e9360ba87083b49017a3b474c98395f5b6609b83433315 |
File details
Details for the file anndata2ri-1.0.5-py3-none-any.whl
.
File metadata
- Download URL: anndata2ri-1.0.5-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c17e7cf227a7d4ef06eb262d88202267b205044baa98948b566910460fb5ab4 |
|
MD5 | 1eb47b6e72a0dc3cc5487bccf4ecb212 |
|
BLAKE2b-256 | f865899659011b0bfeddedef86dc92eda4936da34977de620f8f281c378addab |