Warm tip: This article is reproduced from serverfault.com, please click

Loading in an RS4 object in Python

发布于 2021-07-19 13:47:25

I have an rds file that contains a Seurat RS4 object. I try to run

result = pyreadr.read_r('P1.seur.rds')

And get that the file contains an unrecognized object. I realize that I can't just load in the object like this and know that there are other tutorials on working with RS4 objects, but I'm not sure how to load in the file in the first place so I can use rpy2's functions to turn it into a Python dataframe. How can I load in the object so I can work with it? Thanks!

Questioner
sjgandhi2312
Viewed
0
lgautier 2021-07-25 00:49:00

What about reading the rds file with rpy2? Unlike pyreadr it will use R's own reader.

from rpy2.robjects.packages import importr
base = importr('base')

obj = base.readRDS('./foo.rds')