Commit 11e5bd18 authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Update human references (to lung) and increase scAlign setting

parent a0defb2a
......@@ -25,13 +25,28 @@ source("./r.scripts/sc-TissueMapper_functions.R")
source("./r.scripts/sc-TissueMapper_process.R")
if (opt$s == "hu"){
imm <- MonacoImmuneData()
} else if (opt$s == "mu"){
imm <- ImmGenData()
imm <- imm[,imm$label.main %in% c("Macrophages","Monocytes","B cells","DC","Eosinophils","Neutrophils","T cells","ILC","NK cells","Basophils","Mast cells","Stem cells","Tgd","NKT","B cells, pro")]
}
if (opt$o == "pr" && opt$s == "hu") {
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)
pop <- readRDS("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/huPr_Pd_all.rds")
try(
if (as.numeric(substring(pop@version,1,1))<3){
......@@ -51,63 +66,39 @@ if (opt$o == "pr" && opt$s == "hu") {
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")
} else if (opt$o == "pr" && opt$s == "mu") {
# pop <- readRDS("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/muPrUr_all.rds")
# try(
# if (as.numeric(substring(pop@version,1,1))<3){
# pop <- UpdateSeuratObject(pop)
# }
# )
# Idents(pop) <- "Lineage"
# pop.epi <- subset(pop,idents="Epi")
# 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")
pop <- ImmGenData()
pop.epi <- pop[,pop$label.main %in% c("Epithelial cells")]
pop.st <- pop[,pop$label.main %in% c("Stromal cells","Fibroblasts","Endothelial cells")]
rm(pop)
} else if (opt$s == "mu"){
}
rm(pop)
sc10x <- readRDS(paste0("./analysis/",opt$p,"_raw.rds"))
sc10x.se <- as.SingleCellExperiment(sc10x)
common <- Reduce(intersect, list(rownames(sc10x.se),rownames(imm),rownames(pop.epi),rownames(pop.st)))
common <- Reduce(intersect, list(rownames(sc10x.se),rownames(lin.P1),rownames(lin.P2),rownames(lin.P3)))
sc10x.se <- sc10x.se[common,]
imm <- imm[common,]
pop.epi <- pop.epi[common,]
pop.st <- pop.st[common,]
lin.P1 <- lin.P1[common,]
lin.P2 <- lin.P1[common,]
lin.P3 <- lin.P3[common,]
rm(common)
singler.lin <- SingleR(sc10x.se,ref=list(imm=imm,pop.epi=pop.epi,pop.st=pop.st),method="cluster",clusters=sc10x.se$integrated_snn_res.2,labels=list(imm=imm$label.main,pop.epi=pop.epi$label.fine,pop.st=pop.st$label.fine),BPPARAM=BiocParallel::MulticoreParam(workers=20))
labs <- singler.lin$labels
if (opt$s == "hu") {
labs[labs %in% c("BE","LE","Hillock","Club")] <- "Epi"
labs[labs %in% c("T cells","CD4+ T cells","CD8+ T cells","NK cells","B cells","Monocytes","Dendritic cells","Neutrophils","Basophils","Progenitors")] <- "Leu"
} else if (opt$s == "mu") {
# labs[labs %in% c("BE","LE","Ur")] <- "Epi"
labs[labs %in% c("Epithelial cells (Ep.5wk.MEC.Sca1+)","Epithelial cells (Ep.5wk.MEChi)","Epithelial cells (Ep.5wk.MEClo)","Epithelial cells (Ep.8wk.CEC.Sca1+)","Epithelial cells (Ep.8wk.CEChi)","Epithelial cells (Ep.8wk.MEChi)","Epithelial cells (Ep.8wk.MEClo)","Epithelial cells (MECHI.GFP+.ADULT)","Epithelial cells (MECHI.GFP+.ADULT.KO)","Epithelial cells (MECHI.GFP-.ADULT)","Epithelial cells (EP.MECHI)")] <- "Epi"
labs[labs %in% c("Fibroblasts (FRC.CAD11.WT)","Fibroblasts (FRC.CFA)","Fibroblasts (FRC)","Fibroblasts (FI.MTS15+)","Fibroblasts (FI)")] <- "Fib"
labs[labs %in% c("Stromal cells (DN.CFA)","Stromal cells (DN)","Stromal cells (ST.31-38-44-)")] <- "SM"
labs[labs %in% c("Endothelial cells (LEC.CFA)","Endothelial cells (LEC)","Endothelial cells (BEC)")] <- "Endo"
labs[labs %in% c("Macrophages","Monocytes","B cells","DC","Eosinophils","Neutrophils","T cells","ILC","NK cells","Basophils","Mast cells","Stem cells","Tgd","NKT","B cells, pro")] <- "Leu"
}
sc10x$lin <- labs[match(sc10x.se$integrated_snn_res.2,singler.lin@rownames)]
rm(labs)
DimPlot(sc10x,group.by="lin",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
singler <- SingleR(sc10x.se,ref=list(lung.P1=lin.P1,lung.P2=lin.P2,lung.P3=lin.P3),method="single",labels=list(lung.P1=lin.P1$label.fine,lung.P2=lin.P2$label.fine,lung.P3=lin.P3$label.fine),de.method="wilcox",BPPARAM=BiocParallel::MulticoreParam(workers=20))
sc10x$pop <- singler$labels
labs <- singler$labels
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"
labs[labs %in% c("Capillary Aerocyte","Capillary","Bronchial Vessel 2","Vein","Artery","Lymphatic","Bronchial Vessel 1")] <- "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")] <- "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")] <- "Myeloid"
labs[labs %in% c("Basophil/Mast 1","Basophil/Mast 2")] <- "Granulocyte"
sc10x$lin <- labs
#DimPlot(sc10x,group.by="lin",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
Idents(sc10x) <- "lin"
sc10x.epi <- subset(sc10x, idents="Epi")
sc10x.fmst <- subset(sc10x, idents=c("Fib","SM"))
sc10x.fib <- subset(sc10x, idents="Fib")
sc10x.sm <- subset(sc10x, idents="SM")
sc10x.leu <- subset(sc10x, idents="Leu")
sc10x.epi <- subset(sc10x, idents="Epithelia")
sc10x.fmst <- subset(sc10x, idents=c("Fibroblast","Smooth Muscle"))
sc10x.fib <- subset(sc10x, idents="Fibroblast")
sc10x.sm <- subset(sc10x, idents="Smooth Muscle")
sc10x.leu <- subset(sc10x, idents=c("Lymphoid", "Myeloid", "Granulocyte"))
res <- c(seq(0.1,0.5,0.1),0.75,seq(1,5,1))
......@@ -195,16 +186,6 @@ if (opt$o == "pr" && opt$s == "hu") {
sc10x.epi$pop <- sc10x.epi$lin
}
sc10x.se.leu <- as.SingleCellExperiment(sc10x.leu,assay="RNA")
common <- intersect(rownames(sc10x.se.leu),rownames(imm))
sc10x.se.leu <- sc10x.se.leu[common,]
imm <- imm[common,]
rm(common)
singler.leu <- SingleR(sc10x.se.leu,ref=imm,method="single",labels=imm$label.main,BPPARAM=BiocParallel::MulticoreParam(workers=20))
sc10x.leu$pop <- singler.leu$labels
Idents(sc10x.leu) <- "pop"
#DimPlot(sc10x.leu,group.by="pop",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
sc10x$pop <- sc10x$lin
sc10x$pop[names(sc10x.epi$pop)] <- sc10x.epi$pop
......
......@@ -546,7 +546,7 @@ scAlign <- function(sc10x.l){
#sc10x.l[[i]] <- NormalizeData(sc10x.l[[i]],verbose=FALSE)
gc()
#sc10x.l[[i]] <- ScaleData(sc10x.l[[i]],vars.to.regress=c("nFeature_RNA","percent.mito"),verbose = FALSE)
sc10x.l[[i]] <- SCTransform(sc10x.l[[i]],vars.to.regress=c("nFeature_RNA","percent.mito","Stress1"),verbose=FALSE,assay="RNA")
sc10x.l[[i]] <- SCTransform(sc10x.l[[i]],variable.features.n=5000,vars.to.regress=c("nFeature_RNA","percent.mito","Stress1"),verbose=FALSE,assay="RNA")
gc()
#sc10x.l[[i]] <- FindVariableFeatures(sc10x.l[[i]],selection.method="vst",nfeatures=2000,verbose=FALSE)
}
......@@ -554,9 +554,9 @@ scAlign <- function(sc10x.l){
sc10x.features <- SelectIntegrationFeatures(object.list=sc10x.l,nfeatures=5000)
sc10x.l <- PrepSCTIntegration(object.list=sc10x.l,anchor.features=sc10x.features,verbose=FALSE)
sc10x.l <- lapply(sc10x.l,FUN=function(x) { RunPCA(x,features=sc10x.features,verbose=FALSE) })
sc10x.l <- lapply(sc10x.l,FUN=function(x) { RunPCA(x,features=sc10x.features,npcs=500 ,verbose=FALSE) })
sc10x.anchors <- FindIntegrationAnchors(object.list=sc10x.l,normalization.method="SCT",anchor.features=sc10x.features,verbose=FALSE,reduction="rpca",dims=1:30)
sc10x.anchors <- FindIntegrationAnchors(object.list=sc10x.l,normalization.method="SCT",anchor.features=sc10x.features,verbose=FALSE,reduction="rpca",dims=1:500)
sc10x <- IntegrateData(anchorset=sc10x.anchors,normalization.method="SCT",verbose=FALSE)
#sc10x <- FindIntegrationAnchors(object.list=sc10x.l,dims=1:30,scale=FALSE)
......
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