Commit 8a31b27b authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Add/update singler scmatch code

parent 7a6eac0e
No preview for this file type
load("./genesets/scDWS.250.rda")
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,
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.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",])
Idents(sc10x,cells=cells.epi) <- "Epi"
Idents(sc10x,cells=cells.fmst) <- "FMSt"
Idents(sc10x,cells=cells.endo) <- "Endo"
Idents(sc10x,cells=cells.leu) <- "Leu"
sc10x$lin <- Idents(sc10x)
sc10x.epi <- subset(sc10x,idents="Epi")
sc10x.fmst <- subset(sc10x,idents="FMSt")
sc10x.st <- subset(sc10x,idents=c("FMSt","Endo"))
sc10x.leu <- subset(sc10x,idents="Leu")
Idents(sc10x.epi,cells=cells.be) <- "BE"
Idents(sc10x.epi,cells=cells.le) <- "LE"
Idents(sc10x.epi,cells=cells.hillock) <- "Hillock"
Idents(sc10x.epi,cells=cells.club) <- "Club"
Idents(sc10x.epi,cells=cells.ne) <- "NE"
sc10x.epi$epi.pops <- Idents(sc10x.epi)
Idents(sc10x.fmst,cells=cells.fib) <- "Fib"
Idents(sc10x.fmst,cells=cells.sm) <- "SM"
sc10x.fmst$fmst.pops <- Idents(sc10x.fmst)
Idents(sc10x.st,cells=cells.fib) <- "Fib"
Idents(sc10x.st,cells=cells.sm) <- "SM"
Idents(sc10x.st,cells=cells.endo) <- "Endo"
sc10x.st$st.pops <- Idents(sc10x.st)
results <- scPC(sc10x.epi,pc=100,hpc=0.9,file="epi",print="2")
sc10x.epi <- results[[1]]
pc.use.epi <- results[[2]]
rm(results)
sc10x.epi <- scCluster(sc10x.epi,res=res,red="pca",dim=pc.use.epi,print="2",folder="epi")
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")
results <- scPC(sc10x.st,pc=100,hpc=0.9,file="st",print="2")
sc10x.st <- results[[1]]
pc.use.st <- results[[2]]
rm(results)
sc10x.st <- scCluster(sc10x.st,res=res,red="pca",dim=pc.use.st,print="2",folder="st")
results <- scPC(sc10x.leu,pc=100,hpc=0.9,file="leu",print="2")
sc10x.leu <- results[[1]]
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")
singler.leu = CreateSinglerObject(GetAssayData(sc10x.leu,assay="RNA"), 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)
save(singler,file='./analysis/singler_object.RData')
\ No newline at end of file
write.csv(GetAssayData(sc10x,assay="RNA"),file=paste0("./analysis/",project.name,".csv"))
......@@ -2,17 +2,17 @@
# 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/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,
singler = CreateSinglerObject(GetAssayData(sc10x,assay="RNA"), 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,
ref.list = list(scDWS.250,cibersort,blueprint_encode), normalize.gene.length = F, variable.genes = "de",
fine.tune = F, do.signatures = T, clusters = NULL, do.main.types = T,
reduce.file.size = T, numCores = SingleR.numCores)
singler$seurat <- sc10x
......@@ -21,7 +21,7 @@ singler$meta.data$ALL.POPS <- sc10x$ALL.POPS
singler$meta.data$xy <- sc10x[["umap"]]@cell.embeddings
save(singler,file='./analysis/singler_object.RData')
save(singler,file='./analysis/singler_testobject.RData')
p <-SingleR.PlotTsne(singler$singler[[1]]$SingleR.single,singler$meta.data$xy)
......@@ -119,3 +119,4 @@ rm(gene.set)
save(sc10x,file=paste0("./analysis/",project.name,".RData"))
save.image(file="./analysis/Data.RData")
library(tidyverse)
library(readxl)
library(genefilter)
library(jsonlite)
library(SingleR)
load("/work/urology/ghenry/RNA-Seq/SingleCell/PIPELINE/RUN/Pd/PUBLISH/Pd/sc-TissueMapper_Pr/analysis/sc10x.Rda")
sc10x <- UpdateSeuratObject(sc10x)
......@@ -148,9 +151,42 @@ 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)
ref$de.genes = CreateVariableGeneSet(expr,types,300)
ref$de.genes.main = CreateVariableGeneSet(expr,main_types,500)
cibersort <- ref
save(cibersort,file='./genesets/cibersort.rda')
#fantom5 <- read.csv("./genesets/9606_symbol.csv")
fantom5 <- read_csv("./genesets/9606_symbol.csv")
fantom5 <- as_data_frame(as.matrix(fantom5))
fantom5 <- column_to_rownames(fantom5, var = "symbol")
colnames(fantom5) <- gsub("\\..","",colnames(fantom5))
fantom5.main.oto <- read_json("./genesets/human_samples_oto.txt",simplifyVector = TRUE)
# fantom5.main.oto <- lapply(fantom5.main.oto,function(y) gsub(":",".",y))
# fantom5.main.oto <- lapply(fantom5.main.oto,function(y) gsub("-",".",y))
# fantom5.main.oto <- lapply(fantom5.main.oto,function(y) gsub(" ",".",y))
fantom5.main.oto <- lapply(fantom5.main.oto,function(x) gsub("\\..","",x))
fantom5 <- fantom5[,!(colnames(fantom5) %in% unlist(unname(unlist((fantom5.main.oto[grep("DOID",names(fantom5.main.oto))])))))]
fantom5 <- fantom5[,!(colnames(fantom5) %in% unlist(unname(unlist((fantom5.main.oto[grep("UBERON",names(fantom5.main.oto))])))))]
fantom5.main <- colnames(fantom5)
name = 'fantom5'
expr <- mapply(fantom5, FUN=as.numeric)
expr <- matrix(data=expr,ncol=ncol(fantom5),nrow=nrow(fantom5))
rownames(expr) <- rownames(fantom5)
colnames(expr) <- colnames(fantom5)
types = as.character(colnames(fantom5))
main_types = fantom5.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)
fantom5 <- ref
save(fantom5,file='./genesets/fantom5.rda')
\ 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