Skip to content
Snippets Groups Projects
Commit e1baf4eb authored by Gervaise Henry's avatar Gervaise Henry :cowboy:
Browse files

Add Lineage UK cells to St for analysis

parent cf73641c
Branches
Tags
No related merge requests found
...@@ -47,25 +47,18 @@ if (!dir.exists(paste0("./analysis/",opt$g,"/global",sub.folder))){ ...@@ -47,25 +47,18 @@ if (!dir.exists(paste0("./analysis/",opt$g,"/global",sub.folder))){
sc10x.Group <- SetAllIdent(object=sc10x.Group,id="Lineage") sc10x.Group <- SetAllIdent(object=sc10x.Group,id="Lineage")
sc10x.Group.Epi <- SubsetData(object=sc10x.Group,ident.use="Epi") sc10x.Group.Epi <- SubsetData(object=sc10x.Group,ident.use="Epi")
sc10x.Group.St <- SubsetData(object=sc10x.Group,ident.use="St") sc10x.Group.St <- SubsetData(object=sc10x.Group,ident.use="St")
UK <- TRUE
tryCatch({ tryCatch({
sc10x.Group.UK <- SubsetData(object=sc10x.Group,ident.use="?") sc10x.Group.St <- SubsetData(object=sc10x.Group,ident.use=c("St","?"))
},error=function(e){UK <<- FALSE}) },error=function(e){cat("ERROR : ",conditionMessage(e),"/\n")})
rm(sc10x.Group) rm(sc10x.Group)
#re-detect variable genes in Epi + St subsets #re-detect variable genes in Epi + St subsets
sc10x.Group.Epi <- FindVariableGenes(object=sc10x.Group.Epi,mean.function=ExpMean,dispersion.function=LogVMR,x.low.cutoff=0.0125,x.high.cutoff=3,y.cutoff=0.5,do.plot=FALSE) sc10x.Group.Epi <- FindVariableGenes(object=sc10x.Group.Epi,mean.function=ExpMean,dispersion.function=LogVMR,x.low.cutoff=0.0125,x.high.cutoff=3,y.cutoff=0.5,do.plot=FALSE)
sc10x.Group.St <- FindVariableGenes(object=sc10x.Group.St,mean.function=ExpMean,dispersion.function=LogVMR,x.low.cutoff=0.0125,x.high.cutoff=3,y.cutoff=0.5,do.plot=FALSE) sc10x.Group.St <- FindVariableGenes(object=sc10x.Group.St,mean.function=ExpMean,dispersion.function=LogVMR,x.low.cutoff=0.0125,x.high.cutoff=3,y.cutoff=0.5,do.plot=FALSE)
if (UK==TRUE){
sc10x.Group.UK <- FindVariableGenes(object=sc10x.Group.UK,mean.function=ExpMean,dispersion.function=LogVMR,x.low.cutoff=0.0125,x.high.cutoff=3,y.cutoff=0.5,do.plot=FALSE)
}
#re-PCA on new variable genes #re-PCA on new variable genes
sc10x.Group.Epi <- RunPCA(object=sc10x.Group.Epi,pc.genes=sc10x.Group.Epi@var.genes,do.print=FALSE,pcs.compute=50) sc10x.Group.Epi <- RunPCA(object=sc10x.Group.Epi,pc.genes=sc10x.Group.Epi@var.genes,do.print=FALSE,pcs.compute=50)
sc10x.Group.St <- RunPCA(object=sc10x.Group.St,pc.genes=sc10x.Group.St@var.genes,do.print=FALSE,pcs.compute=50) sc10x.Group.St <- RunPCA(object=sc10x.Group.St,pc.genes=sc10x.Group.St@var.genes,do.print=FALSE,pcs.compute=50)
if (UK==TRUE){
sc10x.Group.UK <- RunPCA(object=sc10x.Group.UK,pc.genes=sc10x.Group.St@var.genes,do.print=FALSE,pcs.compute=50)
}
#generate QC figures #generate QC figures
postscript(paste0("./analysis/",opt$g,"/qc/Plot_PCElbow.Epi.eps")) postscript(paste0("./analysis/",opt$g,"/qc/Plot_PCElbow.Epi.eps"))
...@@ -80,14 +73,6 @@ plot <- plot+theme(axis.text.x=element_text(size=20),axis.text.y=element_text(si ...@@ -80,14 +73,6 @@ plot <- plot+theme(axis.text.x=element_text(size=20),axis.text.y=element_text(si
plot(plot) plot(plot)
dev.off() dev.off()
if (UK==TRUE){
postscript(paste0("./analysis/",opt$g,"/qc/Plot_PCElbow.UK.eps"))
plot <- PCElbowPlot(object=sc10x.Group.UK,num.pc=50)
plot <- plot+theme(axis.text.x=element_text(size=20),axis.text.y=element_text(size=20),axis.title.x=element_text(size=20),axis.title.y=element_text(size=20))
plot(plot)
dev.off()
}
#re-generate tSNE dimensions and generage sample figures #re-generate tSNE dimensions and generage sample figures
sc10x.Group.Epi <- RunTSNE(object=sc10x.Group.Epi,dims.use=1:PC.Max,do.fast=TRUE) sc10x.Group.Epi <- RunTSNE(object=sc10x.Group.Epi,dims.use=1:PC.Max,do.fast=TRUE)
postscript(paste0("./analysis/",opt$g,"/global/NoStress/tSNE_Sample.Epi.eps")) postscript(paste0("./analysis/",opt$g,"/global/NoStress/tSNE_Sample.Epi.eps"))
...@@ -105,29 +90,13 @@ plot <- plot+guides(colour=guide_legend(override.aes=list(size=10))) ...@@ -105,29 +90,13 @@ plot <- plot+guides(colour=guide_legend(override.aes=list(size=10)))
plot(plot) plot(plot)
dev.off() dev.off()
if (UK==TRUE){
sc10x.Group.UK <- RunTSNE(object=sc10x.Group.UK,dims.use=1:PC.Max,do.fast=TRUE)
postscript(paste0("./analysis/",opt$g,"/global/NoStress/tSNE_Sample.UK.eps"))
plot <- TSNEPlot(object=sc10x.Group.UK,group.by="samples",pt.size=2.5,do.return=TRUE)
plot <- plot+theme(axis.text.x=element_text(size=20),axis.text.y=element_text(size=20),axis.title.x=element_text(size=20),axis.title.y=element_text(size=20),legend.text=element_text(size=20))
plot <- plot+guides(colour=guide_legend(override.aes=list(size=10)))
plot(plot)
dev.off()
}
#re-cluster at different resolutions and generate figures #re-cluster at different resolutions and generate figures
if (UK==TRUE){ pops <- c("Epi","St")
pops <- c("Epi","St","UK")
} else {
pops <- c("Epi","St")
}
for (j in pops){ for (j in pops){
if (j=="Epi"){ if (j=="Epi"){
sc10x.Group <- sc10x.Group.Epi sc10x.Group <- sc10x.Group.Epi
} else if (j=="St") { } else if (j=="St") {
sc10x.Group <- sc10x.Group.St sc10x.Group <- sc10x.Group.St
} else if (j=="UK") {
sc10x.Group <- sc10x.Group.UK
} }
for (i in c(5,2,1,0.5,0.2,0.1)){ for (i in c(5,2,1,0.5,0.2,0.1)){
gc() gc()
...@@ -145,8 +114,6 @@ for (j in pops){ ...@@ -145,8 +114,6 @@ for (j in pops){
sc10x.Group.Epi <- sc10x.Group sc10x.Group.Epi <- sc10x.Group
} else if (j=="St"){ } else if (j=="St"){
sc10x.Group.St <- sc10x.Group sc10x.Group.St <- sc10x.Group
} else {
sc10x.Group.UK <- sc10x.Group
}} }}
rm(pops) rm(pops)
rm(sc10x.Group) rm(sc10x.Group)
...@@ -162,13 +129,8 @@ rm(opt) ...@@ -162,13 +129,8 @@ rm(opt)
#save subcluster .Rda files #save subcluster .Rda files
save(sc10x.Group.Epi,file=paste0("./analysis/sc10x.",Project.Name,".",opt.subclust$g,".EpiSubcluster",sub.file,".Rda")) save(sc10x.Group.Epi,file=paste0("./analysis/sc10x.",Project.Name,".",opt.subclust$g,".EpiSubcluster",sub.file,".Rda"))
save(sc10x.Group.St,file=paste0("./analysis/sc10x.",Project.Name,".",opt.subclust$g,".StSubcluster",sub.file,".Rda")) save(sc10x.Group.St,file=paste0("./analysis/sc10x.",Project.Name,".",opt.subclust$g,".StSubcluster",sub.file,".Rda"))
if (UK==TRUE){
save(sc10x.Group.UK,file=paste0("./analysis/sc10x.",Project.Name,".",opt.subclust$g,".UKSubcluster",sub.file,".Rda"))
}
rm(UK)
rm(sc10x.Group.Epi) rm(sc10x.Group.Epi)
rm(sc10x.Group.St) rm(sc10x.Group.St)
rm(sc10x.Group.UK)
rm(sub.folder) rm(sub.folder)
rm(sub.file) rm(sub.file)
save.image(file=paste0("./analysis/sc10x.",Project.Name,".Cumulative.RData")) save.image(file=paste0("./analysis/sc10x.",Project.Name,".Cumulative.RData"))
...@@ -43,12 +43,10 @@ if (!dir.exists(paste0("./analysis/",opt$g,"/global",sub.folder))){ ...@@ -43,12 +43,10 @@ if (!dir.exists(paste0("./analysis/",opt$g,"/global",sub.folder))){
#merge Epi and St SubClust and generate tSNEs #merge Epi and St SubClust and generate tSNEs
sc10x.Group <- SetAllIdent(object=sc10x.Group,id="Lineage") sc10x.Group <- SetAllIdent(object=sc10x.Group,id="Lineage")
Epi.cell <- names(sc10x.Group@ident[sc10x.Group@ident=="Epi"]) Epi.cell <- names(sc10x.Group@ident[sc10x.Group@ident=="Epi"])
St.cell <- names(sc10x.Group@ident[sc10x.Group@ident=="St"]) St.cell <- c(names(sc10x.Group@ident[sc10x.Group@ident=="St"]),names(sc10x.Group@ident[sc10x.Group@ident=="?"]))
UK.cell <- names(sc10x.Group@ident[sc10x.Group@ident=="?"])
sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=Epi.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$Epi.res",opt$r,"[sc10x.Group@ident=='Epi']")))) sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=Epi.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$Epi.res",opt$r,"[sc10x.Group@ident=='Epi']"))))
sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=St.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$St.res",opt$r,"[sc10x.Group@ident=='St']")))) sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=St.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$St.res",opt$r,"[sc10x.Group@ident=='St']"))))
sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=UK.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$UK.res",opt$r,"[sc10x.Group@ident=='?']"))))
sc10x.Group <- StashIdent(object=sc10x.Group,save.name=paste0("SubClust.res",opt$r)) sc10x.Group <- StashIdent(object=sc10x.Group,save.name=paste0("SubClust.res",opt$r))
postscript(paste0("./analysis/",opt$g,"/global",sub.folder,"/tSNE_Global.Merge.res",opt$r,".eps")) postscript(paste0("./analysis/",opt$g,"/global",sub.folder,"/tSNE_Global.Merge.res",opt$r,".eps"))
plot <- TSNEPlot(object=sc10x.Group,pt.size=5,do.label=TRUE,label.size=10,do.return=TRUE) plot <- TSNEPlot(object=sc10x.Group,pt.size=5,do.label=TRUE,label.size=10,do.return=TRUE)
...@@ -60,7 +58,6 @@ dev.off() ...@@ -60,7 +58,6 @@ dev.off()
sc10x.Group <- SetAllIdent(object=sc10x.Group,id="Lineage") sc10x.Group <- SetAllIdent(object=sc10x.Group,id="Lineage")
sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=Epi.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$Epi.sub.",opt$e,"[sc10x.Group@ident=='Epi']")))) sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=Epi.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$Epi.sub.",opt$e,"[sc10x.Group@ident=='Epi']"))))
sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=St.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$St.sub.",opt$s,"[sc10x.Group@ident=='St']")))) sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=St.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$St.sub.",opt$s,"[sc10x.Group@ident=='St']"))))
sc10x.Group <- SetIdent(object=sc10x.Group,cells.use=UK.cell,ident.use=eval(parse(text=paste0("sc10x.Group@meta.data$UK.sub.",opt$s,"[sc10x.Group@ident=='?']"))))
sc10x.Group@ident <- factor(sc10x.Group@ident,levels=c( sc10x.Group@ident <- factor(sc10x.Group@ident,levels=c(
unique(as.character(sc10x.Group@ident)[grep("^Epi",as.character(sc10x.Group@ident))]), unique(as.character(sc10x.Group@ident)[grep("^Epi",as.character(sc10x.Group@ident))]),
unique(as.character(sc10x.Group@ident)[grep("^BE",as.character(sc10x.Group@ident))]), unique(as.character(sc10x.Group@ident)[grep("^BE",as.character(sc10x.Group@ident))]),
...@@ -90,7 +87,6 @@ dev.off() ...@@ -90,7 +87,6 @@ dev.off()
rm(plot) rm(plot)
rm(Epi.cell) rm(Epi.cell)
rm(St.cell) rm(St.cell)
rm(UK.cell)
#make generic variables of run specific variables #make generic variables of run specific variables
Group.List <- c(Group.List,paste0("SubClust.res",opt$r),"SubClust.ID") Group.List <- c(Group.List,paste0("SubClust.res",opt$r),"SubClust.ID")
......
This diff is collapsed.
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