Commit 305c7585 authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Add dehashing for muPr

parent f2fcee3e
......@@ -42,6 +42,8 @@ sc10x <- results[[1]]
sc10x.groups <- results[[2]]
rm(results)
sc10x <- sc10x[as.character(unlist(sc10x.groups[sc10x.groups$ALL==1,1]))]
#results <- scQC(sc10x,sp=opt$s,feature=c("nFeature_RNA","percent.mito","nCount_RNA"))
results <- scQC(sc10x,sp=opt$s,feature=c("nFeature_RNA"))
sc10x <- results[[1]]
......@@ -134,6 +136,34 @@ rm(results)
counts.cell.destress <- as.list(table(sc10x$samples))
rm(anchor)
if (opt$p=="muPr"){
hto <- as.character(unlist(sc10x.groups[sc10x.groups$HTO==1,1]))
sc10x.hto.data <- Read10X(data.dir=paste0("./analysis/DATA/10x/",hto,"/filtered_feature_bc_matrix/"))
sc10x.hto <- CreateSeuratObject(counts=sc10x.hto.data$`Gene Expression`,project=hto)
sc10x.hto[["HTO"]] <- CreateAssayObject(counts=sc10x.hto.data$`Antibody Capture`)
rm(sc10x.hto.data)
sc10x.hto <- NormalizeData(object=sc10x.hto,assay="HTO",normalization.method="CLR")
sc10x.hto <- HTODemux(sc10x.hto,assay="HTO",positive.quantile=.99)
sc10x.hto <- subset(sc10x.hto,cells=substr(names(sc10x$samples)[sc10x$samples == paste0(hto,"_GEX")],start=1,stop=16))
# HTOHeatmap(sc10x.hto)
# plot1 <- FeatureScatter(sc10x.hto,feature1 = "hto_Anterior-Prostate",feature2 = "hto_Ventral-Prostate",group.by = "HTO_maxID")
# plot2 <- FeatureScatter(sc10x.hto,feature1 = "hto_Anterior-Prostate",feature2 = "hto_Dorsolateral-Prostate",group.by = "HTO_maxID")
# plot3 <- FeatureScatter(sc10x.hto,feature1 = "hto_Dorsolateral-Prostate",feature2 = "hto_Ventral-Prostate",group.by = "HTO_maxID")
# grid.arrange(plot1,plot2,plot3,ncol=1)
Idents(sc10x) <- "samples"
Idents(sc10x,cells=paste0(names(sc10x.hto$HTO_maxID)[sc10x.hto$HTO_maxID=="Anterior-Prostate"],"_4")) <- paste0(hto,"_AP")
Idents(sc10x,cells=paste0(names(sc10x.hto$HTO_maxID)[sc10x.hto$HTO_maxID=="Dorsolateral-Prostate"],"_4")) <- paste0(hto,"_DLP")
Idents(sc10x,cells=paste0(names(sc10x.hto$HTO_maxID)[sc10x.hto$HTO_maxID=="Ventral-Prostate"],"_4")) <- paste0(hto,"_VP")
sc10x$HTO_maxID <- Idents(sc10x)
sc10x$samples_HTO <- Idents(sc10x)
Idents(sc10x,cells=paste0(names(sc10x.hto$hash.ID)[sc10x.hto$hash.ID=="Anterior-Prostate"],"_4")) <- paste0(hto,"_AP")
Idents(sc10x,cells=paste0(names(sc10x.hto$hash.ID)[sc10x.hto$hash.ID=="Dorsolateral-Prostate"],"_4")) <- paste0(hto,"_DLP")
Idents(sc10x,cells=paste0(names(sc10x.hto$hash.ID)[sc10x.hto$hash.ID=="Ventral-Prostate"],"_4")) <- paste0(hto,"_VP")
Idents(sc10x,cells=paste0(names(sc10x.hto$hash.ID)[sc10x.hto$hash.ID=="Negative"],"_4")) <- paste0(hto,"_negative")
Idents(sc10x,cells=paste0(names(sc10x.hto$hash.ID)[sc10x.hto$hash.ID=="Doublet"],"_4")) <- paste0(hto,"_doublet")
sc10x$hash.ID <- Idents(sc10x)
}
results <- scPC(sc10x,pc=100,hpc=0.9,file="post.stress",print="2")
sc10x <- results[[1]]
pc.use.poststress <- results[[2]]
......@@ -142,6 +172,19 @@ rm(results)
res <- c(seq(0.1,0.5,0.1),0.75,seq(1,5,1))
sc10x <- scCluster(sc10x,res=res,red="pca",dim=pc.use.poststress,print="2",folder="ALL")
if (opt$p == "muPr"){
rm(sc10x.hto.data)
rm(sc10x.hto)
Idents(sc10x) <- "samples"
sc10x.tmp <- subset(sc10x,ident=paste0(hto,"_GEX"))
postscript(paste0("./analysis/vis/ALL/HTO_HTO_maxID.eps"))
DimPlot(sc10x.tmp,reduction="umap",group.by="HTO_maxID")
dev.off()
postscript(paste0("./analysis/vis/ALL/HTO_hash.ID.eps"))
DimPlot(sc10x.tmp,reduction="umap",group.by="hash.ID")
dev.off()
}
DefaultAssay(object=sc10x) <- "SCT"
scShinyOutput(sc10x,anal="raw")
......
......@@ -664,34 +664,36 @@ scCluster <- function(sc10x,res=0.1,red="pca",dim,print="tsne",folder=FALSE){
dev.off()
}}
plot1 <- DimPlot(sc10x,reduction="pca",group.by="samples")
plot2 <- DimPlot(sc10x,reduction="tsne",group.by="samples")
plot3 <- DimPlot(sc10x,reduction="umap",group.by="samples")
legend <- cowplot::get_legend(plot1)
if (print=="tsne"){
postscript(paste0("./analysis/vis/",sub,"tSNE_samples.eps"))
grid.arrange(plot2,legend,ncol=1)
dev.off()
} else if (print=="umap"){
postscript(paste0("./analysis/vis/",sub,"UMAP_samples.eps"))
grid.arrange(plot3,legend,ncol=1)
dev.off()
} else if (print=="2"){
plot2 <- plot2+theme(legend.position="none")
plot3 <- plot3+theme(legend.position="none")
postscript(paste0("./analysis/vis/",sub,"2Vis_samples.eps"))
grid.arrange(plot2,plot3,legend,ncol=1)
dev.off()
} else if (print=="3"){
plot1 <- plot1+theme(legend.position="none")
plot2 <- plot2+theme(legend.position="none")
plot3 <- plot3+theme(legend.position="none")
postscript(paste0("./analysis/vis/",sub,"3Vis_samples.eps"))
grid.arrange(plot1,plot2,plot3,legend,ncol=1)
dev.off()
for (i in c("samples","HTO_maxID","hashID")[c("samples","HTO_maxID","hash.ID") %in% colnames(sc10x@meta.data)]){
plot1 <- DimPlot(sc10x,reduction="pca",group.by=i)
plot2 <- DimPlot(sc10x,reduction="tsne",group.by=i)
plot3 <- DimPlot(sc10x,reduction="umap",group.by=i)
legend <- cowplot::get_legend(plot1)
if (print=="tsne"){
postscript(paste0("./analysis/vis/",sub,"tSNE_",i,".eps"))
grid.arrange(plot2,legend,ncol=1)
dev.off()
} else if (print=="umap"){
postscript(paste0("./analysis/vis/",sub,"UMAP_",i,".eps"))
grid.arrange(plot3,legend,ncol=1)
dev.off()
} else if (print=="2"){
plot2 <- plot2+theme(legend.position="none")
plot3 <- plot3+theme(legend.position="none")
postscript(paste0("./analysis/vis/",sub,"2Vis_",i,".eps"))
grid.arrange(plot2,plot3,legend,ncol=1)
dev.off()
} else if (print=="3"){
plot1 <- plot1+theme(legend.position="none")
plot2 <- plot2+theme(legend.position="none")
plot3 <- plot3+theme(legend.position="none")
postscript(paste0("./analysis/vis/",sub,"3Vis_",i,".eps"))
grid.arrange(plot1,plot2,plot3,legend,ncol=1)
dev.off()
}
}
DefaultAssay(sc10x) <- "SCT"
return(sc10x)
......@@ -1017,7 +1019,7 @@ scShinyOutput <- function(sc10x,anal="raw"){
}
}
sc10x <- NormalizeData(sc10x,assay="RNA")
clusters <- c("samples",paste0("integrated_snn_res.",res),"lin","pops","leu","scDWSpr")
clusters <- c("samples","samples_HTO",paste0("integrated_snn_res.",res),"lin","pops","leu","scDWSpr","HTO_maxID","hash.ID")
clusters <- intersect(clusters,names(sc10x@meta.data))
for (i in clusters){
if (nrow(unique(sc10x[[i]]))>1){
......
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