-
Notifications
You must be signed in to change notification settings - Fork 3
/
05_seurat_integrate_tips.R
35 lines (28 loc) · 1.33 KB
/
05_seurat_integrate_tips.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library(Seurat)
library(loomR)
library(SeuratDisk)
inFile = paste0('~/BioFiles/immuneCellAtlas/',
'cc95ff89-2e68-4a08-a234-480eca21ce79.homo_sapiens.loom')
bm280k.loom <- connect(filename = inFile, mode = "r+")
bm280k.loom
bm280k = as.Seurat(bm280k.loom)
bm280k.loom$close_all()
# bm280k.data <- Read10X_h5("../data/ica_bone_marrow_h5.h5")
# bm280k <- CreateSeuratObject(counts = bm280k.data, min.cells = 100, min.features = 500)
bm280k.list <- SplitObject(bm280k, split.by = "orig.ident")
bm280k.list <- lapply(X = bm280k.list, FUN = function(x) {
x <- NormalizeData(x, verbose = FALSE)
x <- FindVariableFeatures(x, verbose = FALSE)
})
features <- SelectIntegrationFeatures(object.list = bm280k.list)
bm280k.list <- lapply(X = bm280k.list, FUN = function(x) {
x <- ScaleData(x, features = features, verbose = FALSE)
x <- RunPCA(x, features = features, verbose = FALSE)
})
anchors <- FindIntegrationAnchors(object.list = bm280k.list, reference = c(1, 2), reduction = "rpca",
dims = 1:50)
bm280k.integrated <- IntegrateData(anchorset = anchors, dims = 1:50)
bm280k.integrated <- ScaleData(bm280k.integrated, verbose = FALSE)
bm280k.integrated <- RunPCA(bm280k.integrated, verbose = FALSE)
bm280k.integrated <- RunUMAP(bm280k.integrated, dims = 1:50)
DimPlot(bm280k.integrated, group.by = "orig.ident")