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)
网友评论