Convert R RNA-seq data object to a Python object I have done some work in R and would like to try a Python tool.

What is a good way to import the data (and its annotations etc) as a Python object?

I am particularly interested in converting a Seurat object into an AnnData object. (Either directly or as a Python object which can be converted into an AnnData.)
A simple solution for converting Seurat objects into AnnData, as described in this vignette:

library(reticulate)
seuratobject_ad &lt;- Convert(from=seuratobject, to="anndata", filename="seuratobject.h5ad")




Alternatively, one can use Loom, "a file format designed to store and work with single-cell RNA-seq data".

In R, install LoomR:

devtools::install_github(repo = "mojaveazure/loomR")


Convert from Seurat object to loom:

pfile &lt;- Convert(from = pbmc_small, to = "loom", filename = "pbmc_small.loom")
pfile$close() # close loom objects when finished using them.


Then import loom object in Python using loompy, or directly as AnnData:

scanpy.api.read_loom



Alternatively, see feather.



Or export as some text format (csv, json) then import into Python.