sc-TissueMapper_ID.R 15.7 KB
Newer Older
1
2
3
gc()
library(optparse)
library(Seurat)
Gervaise Henry's avatar
Gervaise Henry committed
4
library(SingleR)
5
library(scRNAseq)
6
7
8
library(RColorBrewer)
library(viridis)
library(gridExtra)
Gervaise Henry's avatar
Gervaise Henry committed
9
library(ggplot2)
10

Gervaise Henry's avatar
Gervaise Henry committed
11
12
options(future.globals.maxSize= 1000000000000)

13
option_list=list(
Gervaise Henry's avatar
Gervaise Henry committed
14
  make_option("--p",action="store",default="huPr_PdPb",type='character',help="Project Name"),
15
16
  make_option("--s",action="store",default="hu",type='character',help="Species"),
  make_option("--o",action="store",default="pr",type='character',help="Organ")
17
18
19
20
21
22
23
24
25
26
)
opt=parse_args(OptionParser(option_list=option_list))
rm(option_list)


setwd("../")

source("./r.scripts/sc-TissueMapper_functions.R")
source("./r.scripts/sc-TissueMapper_process.R")

27
if (opt$s == "hu"){
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  load("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/Travaglini_Nature2020/assets/Analysis/r objects/droplet_normal_lung_blood_seurat_ntiss10x.P1.anno.20191002.RC4.Robj")
  lin.P1 <- UpdateSeuratObject(ntiss10x.P1.anno)
  lin.P1$label.main <- lin.P1$magnetic.selection
  lin.P1$label.fine <- lin.P1$free_annotation
  lin.P1@meta.data <- lin.P1@meta.data[,c("label.main","label.fine")]
  lin.P1 <- as.SingleCellExperiment(lin.P1,assay="RNA")
  rm(ntiss10x.P1.anno)
  load("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/Travaglini_Nature2020/assets/Analysis/r objects/droplet_normal_lung_seurat_ntiss10x.P2.anno.20191002.RC4.Robj")
  lin.P2 <- UpdateSeuratObject(ntiss10x.P2.anno)
  lin.P2$label.main <- lin.P2$magnetic.selection
  lin.P2$label.fine <- lin.P2$free_annotation
  lin.P2@meta.data <- lin.P2@meta.data[,c("label.main","label.fine")]
  lin.P2 <- as.SingleCellExperiment(lin.P2,assay="RNA")
  rm(ntiss10x.P2.anno)
  load("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/Travaglini_Nature2020/assets/Analysis/r objects/droplet_normal_lung_blood_seurat_ntiss10x.P3.anno.20191002.RC4.Robj")
  lin.P3 <- UpdateSeuratObject(ntiss10x.P3.anno)
  lin.P3$label.main <- lin.P3$magnetic.selection
  lin.P3$label.fine <- lin.P3$free_annotation
  lin.P3@meta.data <- lin.P3@meta.data[,c("label.main","label.fine")]
  lin.P3 <- as.SingleCellExperiment(lin.P3,assay="RNA")
  rm(ntiss10x.P3.anno)
  
Gervaise Henry's avatar
Gervaise Henry committed
50
  pop <- readRDS("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/huPr_Pd_all.rds")
51
  try(
Gervaise Henry's avatar
Gervaise Henry committed
52
53
    if (as.numeric(substring(pop@version,1,1))<3){
      pop <- UpdateSeuratObject(pop)
54
55
    }
  )
Gervaise Henry's avatar
Gervaise Henry committed
56
57
58
59
60
61
62
63
64
65
66
67
68
  Idents(pop) <- "Lineage"
  pop.epi <- subset(pop,idents="Epi")
  Idents(pop.epi) <- "Population"
  pop.epi <- subset(pop.epi,idents=c("BE","LE","Hillock","Club"))
  pop.st <- subset(pop,idents=c("FMSt","Endo"))
  pop.epi$label.main <- pop.epi$Lineage
  pop.st$label.main <- pop.st$Lineage
  pop.epi$label.fine <- pop.epi$Population
  pop.st$label.fine <- pop.st$Population
  pop.epi@meta.data <- pop.epi@meta.data[,c("label.main","label.fine")]
  pop.st@meta.data <- pop.st@meta.data[,c("label.main","label.fine")]
  pop.epi <- as.SingleCellExperiment(pop.epi,assay="RNA")
  pop.st <- as.SingleCellExperiment(pop.st,assay="RNA")
69
70
  rm(pop)
} else if (opt$s == "mu"){
71
72
73
74
75
76
77
  load("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/Travaglini_Nature2020/assets/Analysis/r objects/mouse_droplet_TMS_tiss10x.mouse.anno.ncbi.20200222.RC4.Robj")
  lin <- UpdateSeuratObject(tiss10x.mouse.anno)
  lin$label.main <- lin$free_annotation
  lin$label.fine <- lin$free_annotation
  lin@meta.data <- lin@meta.data[,c("label.main","label.fine")]
  lin <- as.SingleCellExperiment(lin,assay="RNA")
  rm(tiss10x.mouse.anno)
78
}
Gervaise Henry's avatar
Gervaise Henry committed
79

Gervaise Henry's avatar
Gervaise Henry committed
80
sc10x <- readRDS(paste0("./analysis/",opt$p,"_raw.rds"))
Gervaise Henry's avatar
Gervaise Henry committed
81
82

sc10x.se <- as.SingleCellExperiment(sc10x)
83
84
85
86
87
88
89
90
91
if (opt$s == "hu"){
  common <- Reduce(intersect, list(rownames(sc10x.se),rownames(lin.P1),rownames(lin.P2),rownames(lin.P3)))
  lin.P1 <- lin.P1[common,]
  lin.P2 <- lin.P1[common,]
  lin.P3 <- lin.P3[common,]
} else if (opt$s == "mu"){
  common <- Reduce(intersect, list(rownames(sc10x.se),rownames(lin)))
  lin <- lin[common,]
}
Gervaise Henry's avatar
Gervaise Henry committed
92
93
94
sc10x.se <- sc10x.se[common,]
rm(common)

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
if (opt$s == "hu"){
  ref <- list(lung.P1=lin.P1,lung.P2=lin.P2,lung.P3=lin.P3)
  labels <- list(lung.P1=lin.P1$label.fine,lung.P2=lin.P2$label.fine,lung.P3=lin.P3$label.fine)
  rm(lin.P1)
  rm(lin.P2)
  rm(lin.P3)
} else if (opt$s == "mu"){
  ref <- lin
  labels <- lin$label.fine
  rm(lin)
}
  
#singler <- SingleR(sc10x.se,ref=ref,method="single",labels=labels,de.method="wilcox",BPPARAM=BiocParallel::MulticoreParam(workers=20))
#labs <- singler$labels
singler <- SingleR(sc10x.se,ref=ref,clusters=sc10x.se$integrated_snn_res.1,labels=labels,de.method="wilcox",BPPARAM=BiocParallel::MulticoreParam(workers=20))
labs <- singler$labels[match(sc10x.se$integrated_snn_res.1,singler@rownames)]
sc10x$pop <- labs
labs.raw <- labs
113
114
115
labs[labs %in% c("Differentiating Basal","Proliferating Basal","Basal","Mesothelial","Alveolar Epithelial Type 2","Club","Alveolar Epithelial Type 1","Ciliated","Signaling Alveolar Epithelial Type 2","Proximal Basal","Neuroendocrine","Mucous","Ionocyte","Serous","Proximal Ciliated","Goblet")] <- "Epithelia"
labs[labs %in% c("Adventitial Fibroblast","Alveolar Fibroblast","Lipofibroblast")] <- "Fibroblast"
labs[labs %in% c("Airway Smooth Muscle","Pericyte","Myofibroblast","Fibromyocyte","Vascular Smooth Muscle")] <- "Smooth Muscle"
116
117
118
119
labs[labs %in% c("Capillary Aerocyte","Capillary","Bronchial Vessel 2","Vein","Artery","Lymphatic","Bronchial Vessel 1","Lympatic")] <- "Endothelia"
labs[labs %in% c("CD4+ Memory/Effector T","CD4+ Naive T","CD8+ Memory/Effector T","CD8+ Naive T","Natural Killer","B","Plasmacytoid Dendritic","Plasma","Proliferating NK/T","Natural Killer T","CD4+ T","CD8+ T","Proliferating T","Regulatory T","Ly6g5b+ T","Proliferating NK","Alox5+ Lymphocytes","Zbtb32+ B")] <- "Lymphoid"
labs[labs %in% c("Classical Monocyte","Nonclassical Monocyte","Myeloid Dendritic Type 2","IGSF21+ Dendritic","EREG+ Dendritic","Myeloid Dendritic Type 1","TREM2+ Dendritic","Macrophage","Proliferating Macrophage","Proliferating Classical Monocyte","Intermediate Monocyte","Ccr7+ Dendritic","Proliferating Dendritic","Alveolar Macrophage","Interstitial Macrophage","Proliferating Alveolar Macrophage")] <- "Myeloid"
labs[labs %in% c("Basophil/Mast 1","Basophil/Mast 2","Basophil","Neutrophil")] <- "Granulocyte"
120
sc10x$lin <- labs
Gervaise Henry's avatar
Gervaise Henry committed
121
sc10x$lung <- labs.raw
122
#DimPlot(sc10x,group.by="lin",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
Gervaise Henry's avatar
Gervaise Henry committed
123
124

Idents(sc10x) <- "lin"
125
sc10x.epi <- subset(sc10x, idents="Epithelia")
Gervaise Henry's avatar
Gervaise Henry committed
126
sc10x.fmst <- subset(sc10x, idents=unique(Idents(sc10x))[unique(Idents(sc10x)) %in% c("Fibroblast","Smooth Muscle")])
127
128
sc10x.fib <- subset(sc10x, idents="Fibroblast")
sc10x.sm <- subset(sc10x, idents="Smooth Muscle")
Gervaise Henry's avatar
Gervaise Henry committed
129
sc10x.leu <- subset(sc10x, idents=unique(Idents(sc10x))[unique(Idents(sc10x)) %in% c("Lymphoid", "Myeloid", "Granulocyte")])
130

Gervaise Henry's avatar
Gervaise Henry committed
131
132
res <- c(seq(0.1,0.5,0.1),0.75,seq(1,5,1))

133
134
if (ncol(sc10x.epi) > 1000) {
  pc.calc.epi <- 1000
Gervaise Henry's avatar
Gervaise Henry committed
135
} else if (ncol(sc10x.epi) > 500) {
136
  pc.calc.epi <- 500
Gervaise Henry's avatar
Gervaise Henry committed
137
} else if (ncol(sc10x.epi) > 100) {
138
139
  pc.calc.epi <- ncol(sc10x.epi)-1
}
Gervaise Henry's avatar
Gervaise Henry committed
140
results <- scPC(sc10x.epi,pc=pc.calc.epi,hpc=0.9,file="epi",print="umap")
Gervaise Henry's avatar
Gervaise Henry committed
141
142
143
sc10x.epi <- results[[1]]
pc.use.epi <- results[[2]]
rm(results)
Gervaise Henry's avatar
Gervaise Henry committed
144
sc10x.epi <- scCluster(sc10x.epi,res=res,red="pca",dim=pc.use.epi,print="umap",folder="epi")
Gervaise Henry's avatar
Gervaise Henry committed
145
146
#DimPlot(sc10x.epi,group.by="integrated_snn_res.0.1",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")

147
148
if (ncol(sc10x.fmst) > 1000) {
  pc.calc.fmst <- 1000
Gervaise Henry's avatar
Gervaise Henry committed
149
} else if (ncol(sc10x.fmst) > 500) {
150
  pc.calc.fmst <- 500
Gervaise Henry's avatar
Gervaise Henry committed
151
} else if (ncol(sc10x.fmst) > 100) {
152
153
  pc.calc.fmst <- ncol(sc10x.fmst)-1
}
Gervaise Henry's avatar
Gervaise Henry committed
154
results <- scPC(sc10x.fmst,pc=pc.calc.fmst,hpc=0.9,file="fmst",print="umap")
Gervaise Henry's avatar
Gervaise Henry committed
155
156
157
sc10x.fmst <- results[[1]]
pc.use.fmst <- results[[2]]
rm(results)
Gervaise Henry's avatar
Gervaise Henry committed
158
sc10x.fmst <- scCluster(sc10x.fmst,res=res,red="pca",dim=pc.use.fmst,print="umap",folder="fmst")
Gervaise Henry's avatar
Gervaise Henry committed
159
160
#DimPlot(sc10x.fmst,group.by="integrated_snn_res.0.1",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")

161
162
if (ncol(sc10x.fib) > 1000) {
  pc.calc.fib <- 1000
Gervaise Henry's avatar
Gervaise Henry committed
163
} else if (ncol(sc10x.fib) > 500) {
164
  pc.calc.fib <- 500
Gervaise Henry's avatar
Gervaise Henry committed
165
} else if (ncol(sc10x.fib) > 100) {
166
167
  pc.calc.fib <- ncol(sc10x.fib)-1
}
Gervaise Henry's avatar
Gervaise Henry committed
168
results <- scPC(sc10x.fib,pc=pc.calc.fib,hpc=0.9,file="all",print="umap")
Gervaise Henry's avatar
Gervaise Henry committed
169
170
171
sc10x.fib <- results[[1]]
pc.use.fib <- results[[2]]
rm(results)
Gervaise Henry's avatar
Gervaise Henry committed
172
sc10x.fib <- scCluster(sc10x.fib,res=res,red="pca",dim=pc.use.fib,print="umap",folder="fib")
Gervaise Henry's avatar
Gervaise Henry committed
173
174
#DimPlot(sc10x.fib,group.by="integrated_snn_res.0.1",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")

175
176
if (ncol(sc10x.sm) > 1000) {
  pc.calc.sm <- 1000
Gervaise Henry's avatar
Gervaise Henry committed
177
} else if (ncol(sc10x.sm) > 500) {
178
  pc.calc.sm <- 500
Gervaise Henry's avatar
Gervaise Henry committed
179
} else if (ncol(sc10x.sm) > 100) {
180
181
  pc.calc.sm <- ncol(sc10x.sm)-1
}
Gervaise Henry's avatar
Gervaise Henry committed
182
results <- scPC(sc10x.sm,pc=pc.calc.sm,hpc=0.9,file="sm",print="umap")
Gervaise Henry's avatar
Gervaise Henry committed
183
184
185
sc10x.sm <- results[[1]]
pc.use.sm <- results[[2]]
rm(results)
Gervaise Henry's avatar
Gervaise Henry committed
186
sc10x.sm <- scCluster(sc10x.sm,res=res,red="pca",dim=pc.use.sm,print="umap",folder="sm")
Gervaise Henry's avatar
Gervaise Henry committed
187
188
#DimPlot(sc10x.sm,group.by="integrated_snn_res.0.1",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")

189
190
if (ncol(sc10x.leu) > 1000) {
  pc.calc.leu <- 1000
Gervaise Henry's avatar
Gervaise Henry committed
191
} else if (ncol(sc10x.leu) > 500) {
192
  pc.calc.leu <- 500
Gervaise Henry's avatar
Gervaise Henry committed
193
} else if (ncol(sc10x.leu) > 100) {
194
195
  pc.calc.leu <- ncol(sc10x.leu)-1
}
Gervaise Henry's avatar
Gervaise Henry committed
196
results <- scPC(sc10x.leu,pc=pc.calc.leu,hpc=0.9,file="leu",print="umap")
Gervaise Henry's avatar
Gervaise Henry committed
197
198
199
sc10x.leu <- results[[1]]
pc.use.leu <- results[[2]]
rm(results)
Gervaise Henry's avatar
Gervaise Henry committed
200
sc10x.leu <- scCluster(sc10x.leu,res=res,red="pca",dim=pc.use.leu,print="umap",folder="leu")
Gervaise Henry's avatar
Gervaise Henry committed
201
202
#DimPlot(sc10x.leu,group.by="integrated_snn_res.0.1",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")

203
204
205
206
207
208
209
210
211
if (opt$o == "pr" && opt$s == "hu") {
  sc10x.se.epi <- as.SingleCellExperiment(sc10x.epi,assay="RNA")
  common <- intersect(rownames(sc10x.se.epi),rownames(pop.epi))
  sc10x.se.epi <- sc10x.se.epi[common,]
  pop.epi <- pop.epi[common,]
  rm(common)
  singler.epi <- SingleR(sc10x.se.epi,ref=pop.epi,method="single",labels=pop.epi$label.fine,de.method="wilcox",BPPARAM=BiocParallel::MulticoreParam(workers=20))
  sc10x.epi$pop <- singler.epi$labels
  Idents(sc10x.epi) <- "pop"
212
  sc10x[["pop"]][row.names(sc10x.epi[["pop"]])] <- sc10x.epi[["pop"]][,"pop"]
213
214
215
  #DimPlot(sc10x.epi,group.by="pop",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
} else if (opt$o == "pr" && opt$s == "mu") {
  sc10x.epi$pop <- sc10x.epi$lin
Gervaise Henry's avatar
Gervaise Henry committed
216
217
} else {
  sc10x.epi$pop <- sc10x.epi$lin
218
}
Gervaise Henry's avatar
Gervaise Henry committed
219

Gervaise Henry's avatar
Gervaise Henry committed
220
sc10x$pop <- sc10x$lin
221

Gervaise Henry's avatar
Gervaise Henry committed
222
223
224
sc10x$pop[names(sc10x.epi$pop)] <- sc10x.epi$pop
sc10x$pop[names(sc10x.leu$pop)] <- sc10x.leu$pop
#DimPlot(sc10x,group.by="pop",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
Gervaise Henry's avatar
Gervaise Henry committed
225

226
227
228
229
230
231
232
Idents(sc10x) <- "pop"
Idents(sc10x.epi) <- "pop"
Idents(sc10x.fmst) <- "lin"
Idents(sc10x.fib) <- "lin"
Idents(sc10x.sm) <- "lin"
Idents(sc10x.leu) <- "pop"

Gervaise Henry's avatar
Gervaise Henry committed
233
234
235
236
if (!dir.exists("./analysis/vis/singler/")){
  dir.create("./analysis/vis/singler/")
}

Gervaise Henry's avatar
Gervaise Henry committed
237
238
239
240
plot <- DimPlot(sc10x,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
postscript(paste0("./analysis/vis/singler/UMAP_all.eps"))
print(plot)
dev.off()
Gervaise Henry's avatar
Gervaise Henry committed
241
for (i in c("epi","fmst","fib","sm","leu")){
Gervaise Henry's avatar
Gervaise Henry committed
242
243
244
245
246
  plot <- DimPlot(get(paste0("sc10x.",i)),reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
  postscript(paste0("./analysis/vis/singler/UMAP_",i,".eps"))
  print(plot)
  dev.off()
}
247

Gervaise Henry's avatar
Gervaise Henry committed
248
249
250
251
252
253
DefaultAssay(object=sc10x) <- "SCT"
DefaultAssay(object=sc10x.epi) <- "SCT"
DefaultAssay(object=sc10x.fmst) <- "SCT"
DefaultAssay(object=sc10x.fib) <- "SCT"
DefaultAssay(object=sc10x.sm) <- "SCT"
DefaultAssay(object=sc10x.leu) <- "SCT"
254
255
256
257
258
259
260
261
262
263
264
265
266
267
for (i in res){
  sc10x[[paste0("resolution_",i)]] <- sc10x[[paste0("integrated_snn_res.",i)]]
  sc10x.epi[[paste0("resolution_",i)]] <- sc10x.epi[[paste0("integrated_snn_res.",i)]]
  sc10x.fmst[[paste0("resolution_",i)]] <- sc10x.fmst[[paste0("integrated_snn_res.",i)]]
  sc10x.fib[[paste0("resolution_",i)]] <- sc10x.fib[[paste0("integrated_snn_res.",i)]]
  sc10x.sm[[paste0("resolution_",i)]] <- sc10x.sm[[paste0("integrated_snn_res.",i)]]
  sc10x.leu[[paste0("resolution_",i)]] <- sc10x.leu[[paste0("integrated_snn_res.",i)]]
}
sc10x@meta.data <- sc10x@meta.data[,c("lin","pop","lung","samples","resolution_0.1","resolution_0.2","resolution_0.3","resolution_0.4","resolution_0.5","resolution_0.75","resolution_1","resolution_2","resolution_3","resolution_4","resolution_5","nCount_RNA","nFeature_RNA","percent.mito","percent.ribo","Stress1")]
sc10x.epi@meta.data <- sc10x.epi@meta.data[,c("lin","pop","lung","samples","resolution_0.1","resolution_0.2","resolution_0.3","resolution_0.4","resolution_0.5","resolution_0.75","resolution_1","resolution_2","resolution_3","resolution_4","resolution_5","nCount_RNA","nFeature_RNA","percent.mito","percent.ribo","Stress1")]
sc10x.fmst@meta.data <- sc10x.fmst@meta.data[,c("lin","lung","samples","resolution_0.1","resolution_0.2","resolution_0.3","resolution_0.4","resolution_0.5","resolution_0.75","resolution_1","resolution_2","resolution_3","resolution_4","resolution_5","nCount_RNA","nFeature_RNA","percent.mito","percent.ribo","Stress1")]
sc10x.fib@meta.data <- sc10x.fib@meta.data[,c("lin","lung","samples","resolution_0.1","resolution_0.2","resolution_0.3","resolution_0.4","resolution_0.5","resolution_0.75","resolution_1","resolution_2","resolution_3","resolution_4","resolution_5","nCount_RNA","nFeature_RNA","percent.mito","percent.ribo","Stress1")]
sc10x.sm@meta.data <- sc10x.sm@meta.data[,c("lin","lung","samples","resolution_0.1","resolution_0.2","resolution_0.3","resolution_0.4","resolution_0.5","resolution_0.75","resolution_1","resolution_2","resolution_3","resolution_4","resolution_5","nCount_RNA","nFeature_RNA","percent.mito","percent.ribo","Stress1")]
sc10x.leu@meta.data <- sc10x.leu@meta.data[,c("lin","lung","pop","samples","resolution_0.1","resolution_0.2","resolution_0.3","resolution_0.4","resolution_0.5","resolution_0.75","resolution_1","resolution_2","resolution_3","resolution_4","resolution_5","nCount_RNA","nFeature_RNA","percent.mito","percent.ribo","Stress1")]
Gervaise Henry's avatar
Gervaise Henry committed
268
269
270
271
272
273
saveRDS(sc10x,paste0("./analysis/",opt$p,"_id_all.rds"))
saveRDS(sc10x.epi,paste0("./analysis/",opt$p,"_id_epi.rds"))
saveRDS(sc10x.fmst,paste0("./analysis/",opt$p,"_id_fmst.rds"))
saveRDS(sc10x.fib,paste0("./analysis/",opt$p,"_id_fib.rds"))
saveRDS(sc10x.sm,paste0("./analysis/",opt$p,"_id_sm.rds"))
saveRDS(sc10x.leu,paste0("./analysis/",opt$p,"_id_leu.rds"))
Gervaise Henry's avatar
Gervaise Henry committed
274
275
276
277
278
279
library(sceasy)
library(reticulate)
use_condaenv('sceasy')
convertFormat(sc10x,from="seurat",to="anndata",outFile=paste0("/project/urology/Strand_lab/shared/cellxgene/anndata/",opt$p,"_id_all.h5ad"),assay="SCT",main_layer="scale.data")
convertFormat(sc10x.epi,from="seurat",to="anndata",outFile=paste0("/project/urology/Strand_lab/shared/cellxgene/anndata/",opt$p,"_id_epi.h5ad"),assay="SCT",main_layer="scale.data")
convertFormat(sc10x.fmst,from="seurat",to="anndata",outFile=paste0("/project/urology/Strand_lab/shared/cellxgene/anndata/",opt$p,"_id_fmst.h5ad"),assay="SCT",main_layer="scale.data")
Gervaise Henry's avatar
Gervaise Henry committed
280
281
convertFormat(sc10x.fib,from="seurat",to="anndata",outFile=paste0("/project/urology/Strand_lab/shared/cellxgene/anndata/",opt$p,"_id_fib.h5ad"),assay="SCT",main_layer="scale.data")
convertFormat(sc10x.sm,from="seurat",to="anndata",outFile=paste0("/project/urology/Strand_lab/shared/cellxgene/anndata/",opt$p,"_id_sm.h5ad"),assay="SCT",main_layer="scale.data")
Gervaise Henry's avatar
Gervaise Henry committed
282
283
284
285
convertFormat(sc10x.leu,from="seurat",to="anndata",outFile=paste0("/project/urology/Strand_lab/shared/cellxgene/anndata/",opt$p,"_id_leu.h5ad"),assay="SCT",main_layer="scale.data")
saveRDS(sc10x,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_all.rds"))
saveRDS(sc10x.epi,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_epi.rds"))
saveRDS(sc10x.fmst,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_fmst.rds"))
Gervaise Henry's avatar
Gervaise Henry committed
286
287
saveRDS(sc10x.fib,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_fib.rds"))
saveRDS(sc10x.sm,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_sm.rds"))
Gervaise Henry's avatar
Gervaise Henry committed
288
saveRDS(sc10x.leu,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_leu.rds"))
Gervaise Henry's avatar
Gervaise Henry committed
289
290

save(list=ls(pattern="^singler"),file='./analysis/singler_objects.RData')
Gervaise Henry's avatar
Gervaise Henry committed
291
rm(list=ls(pattern="^sc10x"))
Gervaise Henry's avatar
Gervaise Henry committed
292
rm(list=ls(pattern="^singler"))
Gervaise Henry's avatar
Gervaise Henry committed
293
save.image(file="./analysis/sc10x.id.RData")