Metadata-Version: 2.4
Name: anndata2ri
Version: 2.0
Project-URL: Documentation, https://icb-anndata2ri.readthedocs-hosted.com/
Project-URL: Issue Tracker, https://github.com/theislab/anndata2ri/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
Project-URL: Source Code, https://github.com/theislab/anndata2ri
Author-email: "Philipp A." <flying-sheep@web.de>
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: R
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.11
Requires-Dist: anndata
Requires-Dist: rpy2>=3.5.2
Requires-Dist: tzlocal
Provides-Extra: dev
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: scipy-stubs; extra == 'dev'
Provides-Extra: doc
Requires-Dist: ipython; extra == 'doc'
Requires-Dist: lxml; extra == 'doc'
Requires-Dist: scanpydoc[theme,typehints]; extra == 'doc'
Requires-Dist: sphinx; extra == 'doc'
Provides-Extra: test
Requires-Dist: pygments; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-faulthandler; extra == 'test'
Requires-Dist: scanpy; extra == 'test'
Description-Content-Type: text/x-rst

|pypi| |conda| |rtd| |tests| |doi|

.. |pypi| image:: https://img.shields.io/pypi/v/anndata2ri
   :target: https://pypi.org/project/anndata2ri/
   :alt: PyPI Version

.. |conda| image:: https://img.shields.io/conda/vn/bioconda/anndata2ri
   :target: https://anaconda.org/bioconda/anndata2ri
   :alt: Bioconda Version

.. |rtd| image:: https://readthedocs.com/projects/icb-anndata2ri/badge/?version=latest&token=ee358f7efe36cbbd7d04db1b708fa81cefc44634ae7f3f8e0afcd03a1f0b1158
   :target: docs_
   :alt: Documentation Status

.. |tests| image:: https://github.com/theislab/anndata2ri/actions/workflows/run_tests.yml/badge.svg
   :target: https://github.com/theislab/anndata2ri/actions/workflows/run_tests.yml
   :alt: Unit Tests

.. |doi| image:: https://zenodo.org/badge/171714778.svg
   :target: https://zenodo.org/badge/latestdoi/171714778
   :alt: Publication DOI

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`_

.. _AnnData: https://anndata.readthedocs.io/en/latest/
.. _SingleCellExperiment: http://bioconductor.org/packages/release/bioc/vignettes/SingleCellExperiment/inst/doc/intro.html
.. _docs: https://icb-anndata2ri.readthedocs-hosted.com/en/latest/
.. _Scanpy: https://scanpy.readthedocs.io/en/stable/
.. _Seurat: https://satijalab.org/seurat/
.. _`example notebook`: https://github.com/LuckyMD/Code_snippets/blob/master/Seurat_to_anndata.ipynb

Installation
------------

.. code-block:: bash

   pip install anndata2ri
   # or
   conda install -c bioconda anndata2ri

Troubleshooting
---------------

If you have problems installing or importing anndata2ri,
please make sure you first:

1. 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.
2. Search the issues_.
   At the time of writing 17 of the 29 bugs (60%) are invalid or rpy2 bugs / install problems.
3. Make sure you have a compatible R version: rpy2 requires R ≥ 3.6.

.. _rpy2: https://github.com/rpy2/rpy2#readme
.. _issues: https://github.com/theislab/anndata2ri/issues

Usage from Python
-----------------

Use the converter as a context manager:

.. code-block:: python

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

   with localconverter(anndata2ri.converter):
       adata = r('as(some_data, "SingleCellExperiment")')

Usage from Jupyter
------------------
Override the `R magic option`_:

.. _R magic option: https://rpy2.github.io/doc/latest/html/generated_rst/notebooks.html#options

.. code-block:: python

   import anndata2ri
   %load_ext rpy2.ipython
   anndata2ri.set_ipython_converter()

Now you can move objects from Python to R …

.. code-block:: python

   import scanpy.datasets as scd
   adata_paul = scd.paul15()

.. code-block:: r

   %%R -i adata_paul
   adata_paul  # class: SingleCellExperiment ...

… and back:

.. code-block:: r

   %%R -o adata_allen
   data(allen, package = 'scRNAseq')
   adata_allen <- as(allen, 'SingleCellExperiment')

.. code-block:: python

   print(adata_allen)  # AnnData object with ...
