R调用reticulate处理数据

2022-04-03  本文已影响0人  倪桦
library(reticulate)
######加载python模块######
sc <- import("scanpy")
pd <- import("pandas")

adata = sc$read('./matrix.h5ad') ###载入scanpy输出的h5ad文件

#######导出基因名和样本信息################
meta = adata$obs
gene <- adata$var

#############导出矩阵并转置,scanpy和Seurat的行列是反的#############
adata2 = adata$X
adata2 = adata2$T

adata2@Dimnames[[1]] = rownames(gene)
adata2@Dimnames[[2]] = rownames(meta)

merge <- CreateSeuratObject(adata2)
merge <- AddMetaData(merge, meta)

上一篇下一篇

猜你喜欢

热点阅读