-
Notifications
You must be signed in to change notification settings - Fork 0
/
Integrate_All_HypoData.R
52 lines (41 loc) · 2.42 KB
/
Integrate_All_HypoData.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##HypoCombined- WORKING on X1-16XL
library(Seurat)
KaZhouAll = readRDS("~/KaZhouAll_mt10_integrated.rds") #All Fetal
[email protected]$sample2 = gsub("_.*", "", gsub("22T", "22", [email protected]$sample))
[email protected]$StudySample = paste([email protected]$Study, [email protected]$sample2, sep="_") #17 clusters
DefaultAssay(KaZhouAll) = "RNA"
Hypo.list <- SplitObject(KaZhouAll, split.by = "StudySample")
rm(KaZhouAll)
for(n in names(Hypo.list)){
Hypo.list[[n]] = subset(Hypo.list[[n]])
Hypo.list[[n]] = DietSeurat(Hypo.list[[n]])
MT.genes = grep(pattern="^MT-", x = row.names(Hypo.list[[n]]), value=T)
percent.mt = Matrix::colSums(Hypo.list[[n]]@assays[["RNA"]][MT.genes, ])/Matrix::colSums(Hypo.list[[n]]@assays[["RNA"]])
Hypo.list[[n]] = AddMetaData(Hypo.list[[n]], percent.mt, "percent.mt")
Hypo.list[[n]] <- NormalizeData(Hypo.list[[n]])
Hypo.list[[n]] <- FindVariableFeatures(Hypo.list[[n]], selection.method = "vst", nfeatures = 2000)
}
#saveRDS(Hypo.list, "~/Dropbox/Columbia/Hypo.listNeuro_23MAY23.rds")
EdKaZhouHypoNeurons = readRDS("~/EdKaZhouHypoNeurons_mt10_integrated.rds") #All Neurons (inc adult and fetal)
Idents(EdKaZhouHypoNeurons) = "Donor"
EdKaZhouHypoNeurons2 = subset(EdKaZhouHypoNeurons, idents = c("H18.30.002", "H19.30.001", "H19.30.002"))
DefaultAssay(EdKaZhouHypoNeurons2) = "RNA"
Hypo.list2 <- SplitObject(EdKaZhouHypoNeurons2, split.by = "Donor")
rm(EdKaZhouHypoNeurons2); rm(EdKaZhouHypoNeurons)
for(n in names(Hypo.list2)){
Hypo.list[[n]] = DietSeurat(Hypo.list2[[n]])
MT.genes = grep(pattern="^MT-", x = row.names(Hypo.list[[n]]), value=T)
percent.mt = Matrix::colSums(Hypo.list[[n]]@assays[["RNA"]][MT.genes, ])/Matrix::colSums(Hypo.list[[n]]@assays[["RNA"]])
Hypo.list[[n]] = AddMetaData(Hypo.list[[n]], percent.mt, "percent.mt")
Hypo.list[[n]] <- NormalizeData(Hypo.list[[n]])
Hypo.list[[n]] <- FindVariableFeatures(Hypo.list[[n]], selection.method = "vst", nfeatures = 2000)
}
saveRDS(Hypo.list, "~/Hypo.list_1JUN23.rds")
feat <- SelectIntegrationFeatures(object.list = Hypo.list)
for(n in names(Hypo.list)){
Hypo.list[[n]] = ScaleData(Hypo.list[[n]], features = feat, verbose = FALSE)
Hypo.list[[n]] = RunPCA(Hypo.list[[n]], features = feat, verbose = FALSE)
}
Hypo.anchors <- FindIntegrationAnchors(object.list = Hypo.list, anchor.features = feat, reduction = "rpca")
Hypo.combined <- IntegrateData(anchorset = Hypo.anchors)
saveRDS(Hypo.combined, "~/Hypo.combined_1JUNE23.rds")