使用satijalab开发的loomR读取loom文件,具体详见https://satijalab.org/loomr/loomr_tutorial
library(loomR) #
lfile <- connect(filename = "osmFISH_SScortex_mouse_all_cells.loom", mode = "r+")
lfile
lfile$matrix
full.matrix <- lfile$matrix[, ]
dim(x = full.matrix)
A <-lfile$col.attrs$CellID[]
B <-lfile$col.attrs$ClusterName[]
C <-lfile$col.attrs$ClusterID[]
D <-lfile$row.attrs$Gene[]
#############转成Seurat对象的方式##############
full.matrix <- lfile$matrix[,]
dim(full.matrix)
full.matrix <- t(full.matrix)
gene_name <- lfile$row.attrs$Gene[] #基因名
barcode <- lfile$col.attrs$CellID[] #细胞ID
colnames(full.matrix) <- barcode
rownames(full.matrix) <-gene_name
S =CreateSeuratObject(counts = full.matrix,project = 'SP',min.cells = 0, min.features = 0)
S$ClusterID <- lfile$col.attrs$ClusterID[]
S$ClusterName <- lfile$col.attrs$ClusterName[]
S$Regin <- lfile$col.attrs$Region[]
S$Total_molecules <- lfile$col.attrs$Total_molecules[]
S$Valid <- lfile$col.attrs$Valid[]
S$X <- lfile$col.attrs$X[]
S$Y <-lfile$col.attrs$Y[]
S$size_pix <- lfile$col.attrs$size_pix[]
S$size_um2 <- lfile$col.attrs$size_um2[]
S@assays$RNA@meta.features$Fluorophore <- lfile$row.attrs$Fluorophore[]
S@assays$RNA@meta.features$Hybridization <- lfile$row.attrs$Hybridization[]