Commit 4682f616 authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Make figs of SingleR outputs

parent 8a31b27b
......@@ -4,22 +4,27 @@ load("./genesets/cibersort.rda")
singler = CreateSinglerObject(GetAssayData(sc10x,assay="RNA"), annot = NULL, "PdPbPc_deep", min.genes = 0,
technology = "10X", species = "Human", citation = "",
ref.list = list(scDWS.250), normalize.gene.length = F, variable.genes = "de",
fine.tune = T, do.signatures = T, clusters = NULL, do.main.types = T,
fine.tune = T, do.signatures = T, clusters = NULL, do.main.types = F,
reduce.file.size = T, numCores = SingleR.numCores)
cells.epi <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="Epi",])
cells.fmst <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="FMSt",])
cells.endo <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="Endo",])
cells.st <- c(cells.fmst,cells.endo)
cells.leu <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="Leu",])
# cells.epi <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="Epi",])
# cells.fmst <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="FMSt",])
# cells.endo <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="Endo",])
# cells.st <- c(cells.fmst,cells.endo)
# cells.leu <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="Leu",])
cells.be <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="BE",])
cells.le <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="LE",])
cells.hillock <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="Hillock",])
cells.club <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="Club",])
cells.ne <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="NE",])
cells.fib <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="Fib",])
cells.sm <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="SM",])
cells.be <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="BE",])
cells.le <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="LE",])
cells.hillock <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="Hillock",])
cells.club <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="Club",])
cells.ne <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="NE",])
cells.fib <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="Fib",])
cells.sm <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="SM",])
cells.epi <- c(cells.be,cells.le,cells.hillock,cells.club,cells.ne)
cells.fmst <- c(cells.fib,cells.sm)
cells.st <- c(cells.fmst,cells.endo)
cells.leu <- cells.leu <-names(singler$singler[[1]]$SingleR.single$labels[singler$singler[[1]]$SingleR.single$labels[,1]=="Leu",])
Idents(sc10x,cells=cells.epi) <- "Epi"
Idents(sc10x,cells=cells.fmst) <- "FMSt"
......@@ -56,7 +61,7 @@ results <- scPC(sc10x.fmst,pc=100,hpc=0.9,file="fmst",print="2")
sc10x.fmst <- results[[1]]
pc.use.fmst <- results[[2]]
rm(results)
sc10x.fmst <- scCluster(sc10x.fmst,res=res,red="pca",dim=pc.use.st,print="2",folder="fmst")
sc10x.fmst <- scCluster(sc10x.fmst,res=res,red="pca",dim=pc.use.fmst,print="2",folder="fmst")
results <- scPC(sc10x.st,pc=100,hpc=0.9,file="st",print="2")
sc10x.st <- results[[1]]
......@@ -70,6 +75,23 @@ pc.use.leu <- results[[2]]
rm(results)
sc10x.leu <- scCluster(sc10x.leu,res=res,red="pca",dim=pc.use.leu,print="2",folder="leu.lin")
if (!dir.exists(paste0("./analysis/vis/singler"))){
dir.create(paste0("./analysis/vis/singler"))
}
plot <- DimPlot(sc10x,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
postscript(paste0("./analysis/vis/singler/UMAP_all.lin.eps"))
print(plot)
dev.off()
Idents(sc10x.epi) <- "epi.pops"
Idents(sc10x.fmst) <- "fmst.pops"
Idents(sc10x.st) <- "st.pops"
Idents(sc10x.leu) <- "leu.pops"
for (i in c("epi","fmst","st","leu")){
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()
}
singler.leu = CreateSinglerObject(GetAssayData(sc10x.leu,assay="RNA"), annot = NULL, "PdPbPc_deep", min.genes = 0,
technology = "10X", species = "Human", citation = "",
......@@ -77,4 +99,34 @@ singler.leu = CreateSinglerObject(GetAssayData(sc10x.leu,assay="RNA"), annot = N
fine.tune = T, do.signatures = T, clusters = NULL, do.main.types = T,
reduce.file.size = T, numCores = SingleR.numCores)
save(singler,file='./analysis/singler_object.RData')
\ No newline at end of file
sc10x.leu$leu.lin <- unlist(singler.leu$singler[[1]]$SingleR.single.main$labels[,])
sc10x.leu$leu <- unlist(singler.leu$singler[[1]]$SingleR.single$labels[,])
plot <- DimPlot(sc10x.leu,group.by="leu.lin",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
postscript(paste0("./analysis/vis/singler/UMAP_leu.lin.eps"))
print(plot)
dev.off()
plot <- DimPlot(sc10x.leu,group.by="leu",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
postscript(paste0("./analysis/vis/singler/UMAP_leu.eps"))
print(plot)
dev.off()
Idents(sc10x,cells=cells.be) <- "BE"
Idents(sc10x,cells=cells.le) <- "LE"
Idents(sc10x,cells=cells.hillock) <- "Hillock"
Idents(sc10x,cells=cells.club) <- "Club"
Idents(sc10x,cells=cells.ne) <- "NE"
Idents(sc10x,cells=cells.fib) <- "Fib"
Idents(sc10x,cells=cells.sm) <- "SM"
Idents(sc10x,cells=cells.endo) <- "Endo"
Idents(sc10x,cells=names(singler.leu$singler[[1]]$SingleR.single.main$labels[,])) <- unlist(singler.leu$singler[[1]]$SingleR.single.main$labels[,])
sc10x$all.pops <- Idents(sc10x)
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()
save(list=ls(pattern="^singler"),file='./analysis/singler_objects.RData')
save(list=ls(pattern="^sc10x"),file='./analysis/sc10x.id.rda')
save.image(file="./analysis/sc10x.id.RData")
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment