Commit 7a6eac0e authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Add code to test ssingler

parent 23afe24b
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
# load("./genesets/scDWS.50.rda")
# load("./genesets/scDWS.100.rda")
# load("./genesets/scDWS.200.rda")
load("./genesets/scDWS.250.rda")
load("./genesets/scDWS.lin.rda")
load("./genesets/scDWS.epi.rda")
load("./genesets/scDWS.fmst.rda")
load("./genesets/cibersort.rda")
load("./genesets/blueprint_encode.rda")
load("./genesets/hpca.rda")
singler = CreateSinglerObject(GetAssayData(object = sc10x), annot = NULL, "PdPbPc_deep", min.genes = 0,
technology = "10X", species = "Human", citation = "",
ref.list = list(cibersort), normalize.gene.length = F, variable.genes = "de",
fine.tune = T, do.signatures = T, clusters = NULL, do.main.types = T,
reduce.file.size = T, numCores = SingleR.numCores)
singler$seurat <- sc10x
singler$meta.data$ALL.POPS <- sc10x$ALL.POPS
singler$meta.data$xy <- sc10x[["umap"]]@cell.embeddings
save(singler,file='./analysis/singler_object.RData')
p <-SingleR.PlotTsne(singler$singler[[1]]$SingleR.single,singler$meta.data$xy)
table(singler$singler[[1]]$SingleR.single.main$labels,singler$meta.dat$ALL.POPS)
# gene.set1 <- read_delim("./genesets/DEG_Epi_5FC.txt","\t",escape_double=FALSE,trim_ws=TRUE,col_names=FALSE)
# gene.set1 <- as.list(gene.set1)
# names(gene.set1) <- "Epi"
# gene.set <- c(gene.set1)
# gene.set1 <- read_delim("./genesets/DEG_FMSt_5FC.txt","\t",escape_double=FALSE,trim_ws=TRUE,col_names=FALSE)
# gene.set1 <- as.list(gene.set1)
# names(gene.set1) <- "St"
# gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.BE.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "BE"
#gene.set <- c(gene.set,gene.set1)
gene.set <- c(gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.LE.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "LE"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.OE1.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Club"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.OE2.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Hillock"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.NE.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "NE"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.Endo.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Endo"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.SM.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "SM"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.Fib.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Fib"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.Leu.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Leu"
gene.set <- c(gene.set,gene.set1)
# genes.leu <- read_excel("./genesets/40425_2017_215_MOESM1_ESM.xlsx",sheet="S3. Candidate markers")
# leu <- as.list(unique(genes.leu[,2]))$Cell
# leu <- leu[-c(9,17,20,24,26,28)]
# #leu.l <- leu[-c(1,3:4,7:8,13:18,21,20:30)]
# #leu.lin <- c("Myeloid","Lymphoid","Lymphoid","Lymphoid","Myeloid","Myeloid","Lymphoid","Myeloid","Myeloid","Myeloid","Myeloid","Myeloid","Lymphoid","Lymphoid","Lymphoid","Myeloid","Lymphoid","Lymphoid","Lymphoid","Lymphoid","Lymphoid","Lymphoid","Lymphoid","Lymphoid","Lymphoid","Lymphoid","Lymphoid")
# #leu.lin <- c("Lymphoid","Myeloid","Myeloid","Myeloid","Myeloid","Myeloid","Myeloid","Lymphoid")
# genes.leu <- genes.leu[unlist(genes.leu[,2]) %in% unlist(leu),]
# #genes.leu.l <- genes.leu[unlist(genes.leu[,2]) %in% unlist(leu.l),]
# #genes.leu.l[nrow(genes.leu.l)+1,] <- list("MS4A7","Macrophages",0)
# #genes.leu.l[nrow(genes.leu.l)+1,] <- list("CD14","Macrophages",0)
# # genes.leu.l[nrow(genes.leu.l)+1,] <- list("CD86","Macrophages",0)
# # genes.leu.l[nrow(genes.leu.l)+1,] <- list("S100A9","Neutrophils",0)
# # genes.leu.l[nrow(genes.leu.l)+1,] <- list("EREG","Neutrophils",0)
# # genes.leu.l[nrow(genes.leu.l)+1,] <- list("S100A8","Neutrophils",0)
# # genes.leu.l[nrow(genes.leu.l)+1,] <- list("FCN1","Neutrophils",0)
# gene.set1 <- split(genes.leu[,1], genes.leu[,2])
# #gene.set1 <- split(genes.leu.l[,1], genes.leu.l[,2])
# gene.set1 <- lapply(gene.set1,unname)
# gene.set1 <- lapply(gene.set1,unlist)
# #names(gene.set1) <- leu.lin
# names(gene.set1) <- leu
# gene.set <- c(gene.set,gene.set1)
rm(gene.set1)
min <- min(table(sc10x$integrated_snn_res.0.5))
results <- scQuSAGE(sc10x,gs=gene.set,save=TRUE,type="lg",id="integrated_snn_res.0.5",ds=0,nm="all.pops",print="2")
sc10x <- results[[1]]
results.cor.all.pops <- results[[2]]
results.clust.all.pops.id <- results[[3]]
rm(results)
rm(gene.set)
save(sc10x,file=paste0("./analysis/",project.name,".RData"))
save.image(file="./analysis/Data.RData")
library(tidyverse)
library(genefilter)
load("/work/urology/ghenry/RNA-Seq/SingleCell/PIPELINE/RUN/Pd/PUBLISH/Pd/sc-TissueMapper_Pr/analysis/sc10x.Rda")
sc10x <- UpdateSeuratObject(sc10x)
Idents(object=sc10x) <- "Merge_Epi.dws_St.go_NE"
sc10x <- RenameIdents(object=sc10x,"OE1"="Club")
sc10x <- RenameIdents(object=sc10x,"OE2"="Hillock")
name = 'scDWS'
expr = as.matrix(GetAssayData(object = sc10x))
types = as.character(as.character(sc10x@active.ident))
main_types = types
main_types = gsub("BE","Epi",main_types)
main_types = gsub("LE","Epi",main_types)
main_types = gsub("Club","Epi",main_types)
main_types = gsub("Hillock","Epi",main_types)
main_types = gsub("NE","Epi",main_types)
main_types = gsub("Fib","FMSt",main_types)
main_types = gsub("SM","FMSt",main_types)
ref = list(name=name,data = expr, types=types, main_types=main_types)
ref$de.genes = CreateVariableGeneSet(expr,types,200)
ref$de.genes.main = CreateVariableGeneSet(expr,main_types,300)
scDWS.lin <- ref
save(scDWS.lin,file='./genesets/scDWS.lin.rda')
Idents(object=sc10x) <- "Merge_Epi.dws_St.go_NE"
sc10x <- RenameIdents(object=sc10x,"OE1"="Club")
sc10x <- RenameIdents(object=sc10x,"OE2"="Hillock")
name = 'scDWS'
expr = as.matrix(GetAssayData(object = sc10x))
types = as.character(as.character(sc10x@active.ident))
main_types = types
main_types = gsub("BE","Epi",main_types)
main_types = gsub("LE","Epi",main_types)
main_types = gsub("Club","Epi",main_types)
main_types = gsub("Hillock","Epi",main_types)
main_types = gsub("NE","Epi",main_types)
main_types = gsub("Fib","FMSt",main_types)
main_types = gsub("SM","FMSt",main_types)
ref = list(name=name,data = expr, types=types, main_types=main_types)
ref.10 <- ref
ref.50 <- ref
ref.100 <- ref
ref.200 <- ref
ref.250 <- ref
ref.10$de.genes = CreateVariableGeneSet(expr,types,10)
ref.10$de.genes.main = CreateVariableGeneSet(expr,main_types,10)
ref.50$de.genes = CreateVariableGeneSet(expr,types,50)
ref.50$de.genes.main = CreateVariableGeneSet(expr,main_types,50)
ref.100$de.genes = CreateVariableGeneSet(expr,types,100)
ref.100$de.genes.main = CreateVariableGeneSet(expr,main_types,100)
ref.200$de.genes = CreateVariableGeneSet(expr,types,200)
ref.200$de.genes.main = CreateVariableGeneSet(expr,main_types,200)
ref.250$de.genes = CreateVariableGeneSet(expr,types,250)
ref.250$de.genes.main = CreateVariableGeneSet(expr,main_types,250)
scDWS.10 <- ref.10
scDWS.50 <- ref.50
scDWS.100 <- ref.100
scDWS.200 <- ref.200
scDWS.250 <- ref.250
save(scDWS.10,file='./genesets/scDWS.10.rda')
save(scDWS.50,file='./genesets/scDWS.50.rda')
save(scDWS.100,file='./genesets/scDWS.100.rda')
save(scDWS.200,file='./genesets/scDWS.200.rda')
save(scDWS.250,file='./genesets/scDWS.250.rda')
Idents(object=sc10x) <- "Merge_Epi.dws_St.go_NE"
sc10x.epi <- subset(sc10x,idents=c("BE","LE","OE1","OE2","NE"))
sc10x.epi <- RenameIdents(object=sc10x.epi,"OE1"="Club")
sc10x.epi <- RenameIdents(object=sc10x.epi,"OE2"="Hillock")
name = 'scDWS.epi'
expr = as.matrix(GetAssayData(object = sc10x.epi))
types = as.character(as.character(sc10x.epi@active.ident))
main_types = types
main_types = gsub("BE","Epi",main_types)
main_types = gsub("LE","Epi",main_types)
main_types = gsub("Club","Epi",main_types)
main_types = gsub("Hillock","Epi",main_types)
main_types = gsub("NE","Epi",main_types)
ref = list(name=name,data = expr, types=types, main_types=main_types)
ref$de.genes = CreateVariableGeneSet(expr,types,200)
ref$de.genes.main = CreateVariableGeneSet(expr,main_types,300)
scDWS.epi <- ref
save(scDWS.epi,file='./genesets/scDWS.epi.rda')
Idents(object=sc10x) <- "Merge_Epi.dws_St.go_NE"
sc10x.fmst <- subset(sc10x,idents=c("Fib","SM"))
name = 'scDWS.fmst'
expr = as.matrix(GetAssayData(object = sc10x.fmst))
types = as.character(as.character(sc10x.fmst@active.ident))
main_types = types
main_types = gsub("Fib","FMSt",main_types)
main_types = gsub("SM","FMSt",main_types)
ref = list(name=name,data = expr, types=types, main_types=main_types)
ref$de.genes = CreateVariableGeneSet(expr,types,200)
ref$de.genes.main = CreateVariableGeneSet(expr,main_types,300)
scDWS.fmst <- ref
save(scDWS.fmst,file='./genesets/scDWS.fmst.rda')
cibersort <- read_excel("./genesets/nmeth.3337-S2.xls",sheet="SuppTable1_GEP_Matrix",skip=13)
cibersort <- as_data_frame(as.matrix(cibersort))
cibersort <- cibersort[,-c(1,2)]
cibersort <- column_to_rownames(cibersort, var = "Gene symbol")
colnames(cibersort) <- gsub(" ","_",colnames(cibersort))
cibersort.main <- read_excel("./genesets/nmeth.3337-S2.xls",sheet="SuppTable1_GEP_Matrix",range="D12:Y12",col_names=FALSE)
cibersort.main <- as.character(cibersort.main[1,])
for (i in 1:22){
if (cibersort.main[i]=="NA"){
for (j in seq(i,1,-1)){
if (cibersort.main[j]!="NA"){
cibersort.main[i] <- cibersort.main[j]
break
}
}
}
}
cibersort.main <- gsub(" ","_",cibersort.main)
name = 'cibersort'
expr <- mapply(cibersort, FUN=as.numeric)
expr <- matrix(data=expr,ncol=ncol(cibersort),nrow=nrow(cibersort))
rownames(expr) <- rownames(cibersort)
colnames(expr) <- colnames(cibersort)
types = as.character(colnames(cibersort))
main_types = cibersort.main
ref = list(name=name,data = expr, types=types, main_types=main_types)
ref$de.genes = CreateVariableGeneSet(expr,types,200)
ref$de.genes.main = CreateVariableGeneSet(expr,main_types,300)
cibersort <- ref
save(cibersort,file='./genesets/cibersort.rda')
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