We previously tried to implement a python wrapper around the R functions for Seurat v3 and LIGER in
scIB
. However, we found that they didn't always work exactly the same way as when run in a pure R environment. You can however do this yourself using
rpy2
and
anndata2ri
.
from rpy2 import robjects as ro
import anndata2ri
anndata2ri.activate()
adata = sc.datasets.pbmc68k_reduced()
ro.globalenv["data"] = adata
ro.r('library(Seurat)')
ro.r('seurat_obj <- as.Seurat(adata)')
# Do your R integration in Seurat within ro.r('')
ro.r('...')
output = ro.r('as.SingleCellExperiment(seurat_obj)')
By going via SingleCellExperiment objects and anndata2ri.activate()
you should be able to easily transfer the data between R and python from a python framework.
Hi @melancholy12,
We previously tried to implement a python wrapper around the R functions for Seurat v3 and LIGER in scIB. However, we found that they didn't always work exactly the same way as when run in a pure R environment. You can however do this yourself using rpy2
and anndata2ri
.
That would look something like
from rpy2 import robjects as ro
import anndata2ri
anndata2ri.activate()
adata = sc.datasets.pbmc68k_reduced()
ro.globalenv["data"] = adata
ro.r('library(Seurat)')
ro.r('seurat_obj <- as.Seurat(adata)')
# Do your R integration in Seurat within ro.r('')
ro.r('...')
output = ro.r('as.SingleCellExperiment(seurat_obj)')
By going via SingleCellExperiment objects and anndata2ri.activate()
you should be able to easily transfer the data between R and python from a python framework.
Hi LuckMD,
Thanks for your reply. Could we simply run it in python instead of using R language?
Just something like scanpy.external.harmony?
Because we are familiar with scanpy, and not want to change the coding style.
Hi @melancholy12,
No, there is currently no python implementation of these methods specifically. You would have to wrap the R function calls with rpy2
to make this work from python. The syntax would still be quite some R. There are basic implementations of these methods in the scib-pipeline repo here though. Maybe that helps to become familiar with how to call them.
Hi @melancholy12,
No, there is currently no python implementation of these methods specifically. You would have to wrap the R function calls with rpy2
to make this work from python. The syntax would still be quite some R. There are basic implementations of these methods in the scib-pipeline repo here though. Maybe that helps to become familiar with how to call them.
There is a new package called pyliger. Here is the link: https://github.com/welch-lab/pyliger
It should be better if it can integrate into scanpy.