Seurat转h5ad
library(SeuratDisk)
SaveH5Seurat(SeuratObj, filename = '../data/h5ad/RNA.h5Seurat',overwrite = T)
Convert('../data/h5ad/RNA.h5Seurat', dest = "h5ad",overwrite = T)
h5ad转Seurat
library(SeuratDisk)
Convert('./GSE153643_RAW/raw_counts.h5ad', dest = "h5seurat",overwrite = TRUE,assay = "RNA")
scRNA <- LoadH5Seurat("./GSE153643_RAW/raw_counts.h5seurat")
scRNA
h5ad转Seurat的另一种策略:用reticulate在R中调用python读h5ad
read_h5ad_as_Seurat <- function(h5ad_file_name){
# h5ad_file_name <- "/mdshare/node8/txmdata/scREGION/Cortex_plot/raw_data/atac_cortex.h5ad"
library(reticulate)
library(Seurat)
# python_path <- system("which python",intern = TRUE)
python_path = '/home/timo/anaconda3/bin/python3'
use_python(python_path)
numpy <- import("numpy")
pandas <- import("pandas")
scanpy <- import("scanpy")
adata <- scanpy$read(h5ad_file_name)
count_mtx <- Matrix::t(adata$X)
dimnames(count_mtx) <- list(rownames(adata$var),rownames(adata$obs))
SeuratObj <- CreateSeuratObject(count_mtx,meta.data = adata$obs)
return(SeuratObj)
}
loom转Seurat
loom_in <- Connect(filename = "/mdshare/node8/txmdata/scREGION/Cortex_plot/raw_data/atac_cortex.loom", mode = 'r')
mat <- t(loom_in[["matrix"]][,])
sel_cells = loom_in[["col_attrs"]][['obs_names']][]
sel_genes <- loom_in[["row_attrs"]][['var_names']][]
dimnames(mat) <- list(sel_genes,sel_cells)
seurat_atac <- CreateSeuratObject(counts = mat, assay = 'ATAC')
seurat_atac@meta.data$celltype <- loom_in[["col_attrs"]][['celltype']][]
网友评论