Commit 5dfeff3d authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Return lin id to cluster and add by-cell id after

parent a645e818
......@@ -47,6 +47,10 @@ if (opt$s == "hu"){
lin.P3 <- as.SingleCellExperiment(lin.P3,assay="RNA")
rm(ntiss10x.P3.anno)
leu.P1 <- lin.P1[,lin.P1$label.fine %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","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","Basophil/Mast 1","Basophil/Mast 2","Basophil","Neutrophil")]
leu.P2 <- lin.P2[,lin.P2$label.fine %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","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","Basophil/Mast 1","Basophil/Mast 2","Basophil","Neutrophil")]
leu.P3 <- lin.P3[,lin.P3$label.fine %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","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","Basophil/Mast 1","Basophil/Mast 2","Basophil","Neutrophil")]
pop <- readRDS("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/huPr_Pd_all.rds")
try(
if (as.numeric(substring(pop@version,1,1))<3){
......@@ -75,6 +79,8 @@ if (opt$s == "hu"){
lin@meta.data <- lin@meta.data[,c("label.main","label.fine")]
lin <- as.SingleCellExperiment(lin,assay="RNA")
rm(tiss10x.mouse.anno)
leu <- lin[,lin$label.fine %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","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","Basophil/Mast 1","Basophil/Mast 2","Basophil","Neutrophil")]
}
sc10x <- readRDS(paste0("./analysis/",opt$p,"_raw.rds"))
......@@ -104,10 +110,10 @@ if (opt$s == "hu"){
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)]
#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
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"
......@@ -198,7 +204,35 @@ 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="umap",folder="leu")
#DimPlot(sc10x.leu,group.by="integrated_snn_res.0.1",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
sc10x.se.leu <- as.SingleCellExperiment(sc10x.leu,assay="RNA")
if (opt$s == "hu"){
common <- Reduce(intersect, list(rownames(sc10x.se.leu),rownames(leu.P1),rownames(leu.P2),rownames(leu.P3)))
leu.P1 <- leu.P1[common,]
leu.P2 <- leu.P1[common,]
leu.P3 <- leu.P3[common,]
} else if (opt$s == "mu"){
common <- Reduce(intersect, list(rownames(sc10x.se.leu),rownames(leu)))
leu <- leu[common,]
}
sc10x.se.leu <- sc10x.se.leu[common,]
rm(common)
if (opt$s == "hu"){
ref.leu <- list(lung.P1=leu.P1,lung.P2=leu.P2,lung.P3=leu.P3)
labels.leu <- list(lung.P1=leu.P1$label.fine,lung.P2=leu.P2$label.fine,lung.P3=leu.P3$label.fine)
rm(leu.P1)
rm(leu.P2)
rm(leu.P3)
} else if (opt$s == "mu"){
ref.leu <- leu
labels.leu <- leu$label.fine
rm(leu)
}
singler.leu <- SingleR(sc10x.se.leu,ref=ref.leu,method="single",labels=labels.leu,de.method="wilcox",BPPARAM=BiocParallel::MulticoreParam(workers=20))
sc10x.leu$pop <- singler.leu$labels
Idents(sc10x.leu) <- "pop"
#sc10x[["pop"]][row.names(sc10x.leu[["pop"]]),] <- sc10x.leu[["pop"]][,"pop"]
#DimPlot(sc10x.leu,group.by="pop",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
if (opt$o == "pr" && opt$s == "hu") {
sc10x.se.epi <- as.SingleCellExperiment(sc10x.epi,assay="RNA")
......@@ -209,7 +243,7 @@ if (opt$o == "pr" && opt$s == "hu") {
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"
sc10x[["pop"]][row.names(sc10x.epi[["pop"]]),] <- sc10x.epi[["pop"]][,"pop"]
#sc10x[["pop"]][row.names(sc10x.epi[["pop"]]),] <- sc10x.epi[["pop"]][,"pop"]
#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
......
......@@ -858,7 +858,11 @@ scQuSAGE <- function(sc10x,gs,save=FALSE,type,id,ds=0,nm="pops",print="umap"){
groups <- paste0("Cluster_",levels(sc10x@active.ident))
#col <- hcl(h=(seq(15,375-375/length(groups),length=length(groups))),c=100,l=65)
col <- brewer.pal(n=length(groups),name="Dark2")
if (length(groups) == 2) {
col <- c("#1B9E77","#7570B3")
} else {
col <- brewer.pal(n=length(groups),name="Dark2")
}
#Make labels for QuSAGE
clust <- list()
......
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