From e1efc6980b7e5f1f813480417c556064ac26125d Mon Sep 17 00:00:00 2001 From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu> Date: Tue, 25 Sep 2018 15:13:07 -0500 Subject: [PATCH] Fix QuSAGE x-axis and some diy cust cols --- r.scripts/sc-TissueMapper.R | 23 +++++++++++++++-------- r.scripts/sc-TissueMapper_RUN.Pd.R | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/r.scripts/sc-TissueMapper.R b/r.scripts/sc-TissueMapper.R index 38adbec..1f69cc1 100644 --- a/r.scripts/sc-TissueMapper.R +++ b/r.scripts/sc-TissueMapper.R @@ -559,9 +559,10 @@ scQuSAGE <- function(sc10x,gs,res.use=0.1,ds=25000,nm="Lin",folder="lin"){ qs <- get(paste0("results.",i)) if (max(qs$path.mean)>max.x.rg){ max.x.rg <- max(qs$path.mean) - if (min(qs$path.mean)<min.x.rg){ - min.x.rg <- min(qs$path.mean) - }} + } + if (min(qs$path.mean)<min.x.rg){ + min.x.rg <- min(qs$path.mean) + } if (max(qs$path.PDF)>max.y.rg){ max.y.rg <- max(qs$path.PDF) }} @@ -694,9 +695,10 @@ scQuSAGEsm <- function(sc10x,gs,ds=25000,nm="Lin",folder="lin"){ qs <- get(paste0("results.",i)) if (max(qs$path.mean)>max.x.rg){ max.x.rg <- max(qs$path.mean) - if (min(qs$path.mean)<min.x.rg){ - min.x.rg <- min(qs$path.mean) - }} + } + if (min(qs$path.mean)<min.x.rg){ + min.x.rg <- min(qs$path.mean) + } if (max(qs$path.PDF)>max.y.rg){ max.y.rg <- max(qs$path.PDF) }} @@ -1153,10 +1155,14 @@ sc3CCA <- function(sc10x.1,sc10x.2,sc10x.3,nm.1="D17",nm.2="D27",nm.3="D35",cc= sctSNECustCol <- function(sc10x,i,bl,rd,file){ sc10x <- SetAllIdent(object=sc10x,id=i) - sc10x@ident <- factor(sc10x@ident,levels=c(bl,rd)) + sc10x@ident <- factor(sc10x@ident,levels=c(bl,rd,"Unknown")) postscript(paste0("./analysis/diy/tSNE_",file,".",i,".CustCol.eps")) if (length(bl)==1 & length(rd)==1){ - plot <- TSNEPlot(object=sc10x,pt.size=2.5,do.label=FALSE,label.size=10,do.return=TRUE,vector.friendly=FALSE,colors.use=c(brewer.pal(5,"Blues")[5],brewer.pal(5,"Reds")[5])) + if (length(sc10x@ident[sc10x@ident=="Unknown"])>0){ + plot <- TSNEPlot(object=sc10x,pt.size=2.5,do.label=FALSE,label.size=10,do.return=TRUE,vector.friendly=FALSE,colors.use=c(brewer.pal(5,"Blues")[5],brewer.pal(5,"Reds")[5],"grey50")) + } else { + plot <- TSNEPlot(object=sc10x,pt.size=2.5,do.label=FALSE,label.size=10,do.return=TRUE,vector.friendly=FALSE,colors.use=c(brewer.pal(5,"Blues")[5],brewer.pal(5,"Reds")[5])) + } 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) @@ -1175,6 +1181,7 @@ sctSNECustCol <- function(sc10x,i,bl,rd,file){ sctSNEbwCol <- function(sc10x,i,file,files){ sc10x <- SetAllIdent(object=sc10x,id=i) + sc10x@ident <- factor(sc10x@ident,levels=c("Epi","BE","LE","OE1","OE_SCGB","OE2","OE_KRT13","St","Fib","SM","Endo","Leu","Unknown",1:10)) postscript(paste0("./analysis/diy/tSNE_",files,".",file,"_",i,".bwCol.eps")) plot <- TSNEPlot(object=sc10x,pt.size=2.5,do.label=FALSE,label.size=10,do.return=TRUE,vector.friendly=FALSE,colors.use=colorRampPalette(c("white","black"))(length(unique(sc10x@ident))+2)[3:(length(unique(sc10x@ident))+2)]) 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)) diff --git a/r.scripts/sc-TissueMapper_RUN.Pd.R b/r.scripts/sc-TissueMapper_RUN.Pd.R index b954f36..b6c3272 100644 --- a/r.scripts/sc-TissueMapper_RUN.Pd.R +++ b/r.scripts/sc-TissueMapper_RUN.Pd.R @@ -489,7 +489,7 @@ sctSNEbwCol(sc10x,i="Merge_Epi.dws_St.go",file="ALL",files="D") sctSNEbwCol(sc10x.Epi,i="Epi.dws.sub",file="Epi",files="D") sctSNEbwCol(sc10x.St,i="St.go",file="St",files="D") -for (g in c("Epi","St")){ +for (g in c("Epi","St","Unknown")){ sctSNEHighlight(sc10x,i="Lin",g=g,file="D") } for (g in c("BE","LE","OE1","OE2")){ -- GitLab