diff --git a/r.scripts/sc-TissueMapper.R b/r.scripts/sc-TissueMapper.R index 37ad9f9655fe9d440bc8cb3ea3718be8e3c98f4b..38adbeced40df00083db4cf7401eeddc1aaec1dc 100644 --- a/r.scripts/sc-TissueMapper.R +++ b/r.scripts/sc-TissueMapper.R @@ -492,14 +492,6 @@ scQuSAGE <- function(sc10x,gs,res.use=0.1,ds=25000,nm="Lin",folder="lin"){ labels <- paste0("Cluster_",as.vector(factor(sc10x@ident))) - #if ((ncol(sc10x@data)>ds & ds!=0)){ - # rnd <- sample(1:ncol(sc10x@data),ds) - # data <- sc10x@data[,rnd] - # labels <- labels[rnd] - #} else { - # data <- sc10x@data - #} - cell.sample <- NULL for (i in 1:number.clusters){ cell <- names(sc10x@ident[sc10x@ident==i]) @@ -651,16 +643,7 @@ scQuSAGEsm <- function(sc10x,gs,ds=25000,nm="Lin",folder="lin"){ clusters <- unique(sc10x@ident) labels <- as.vector(factor(sc10x@ident)) - - #if ((ncol(sc10x@data)>ds & ds!=0)){ - # rnd <- sample(1:ncol(sc10x@data),ds) - # data <- sc10x@data[,rnd] - # labels <- labels[rnd] - #} else { - # data <- sc10x@data - #} - #data <- as.data.frame(as.matrix(data)) - + cell.sample <- NULL for (i in clusters){ cell <- names(sc10x@ident[sc10x@ident==i]) @@ -773,15 +756,6 @@ scQuSAGElg <- function(sc10x,gs,ds=25000,nm="Lin",folder="lin"){ labels <- as.vector(factor(sc10x@ident)) - #if ((ncol(sc10x@data)>ds & ds!=0)){ - # rnd <- sample(1:ncol(sc10x@data),ds) - # data <- sc10x@data[,rnd] - # labels <- labels[rnd] - #} else { - # data <- sc10x@data - #} - #data <- as.data.frame(as.matrix(data)) - cell.sample <- NULL for (i in clusters){ cell <- names(sc10x@ident[sc10x@ident==i]) diff --git a/r.scripts/sc-TissueMapper_RUN.Pd.R b/r.scripts/sc-TissueMapper_RUN.Pd.R index 285435076c104a486dafec8c09290f7831bfef99..b954f3624a695f8ffe1cceedaff14311a9d79417 100644 --- a/r.scripts/sc-TissueMapper_RUN.Pd.R +++ b/r.scripts/sc-TissueMapper_RUN.Pd.R @@ -3,7 +3,6 @@ library(methods) library(optparse) library(Seurat) library(readr) -#library(readxl) library(fBasics) library(pastecs) library(qusage) @@ -104,18 +103,11 @@ option_list=list( make_option("--cca",action="store",default=50,type='integer',help="Number of CCAs to cacluate"), make_option("--acca",action="store",default=30,type='integer',help="Number of CCAs to align"), make_option("--pc",action="store",default=50,type='integer',help="Number of PCs to cacluate"), - #make_option("--hpc",action="store",default=0.9,type='numeric',help="Max variance cutoff for PCs to use, pre-stress"), make_option("--res.prestress",action="store",default=1,type='numeric',help="Resolution to cluster, pre-stress"), make_option("--st",action="store",default=TRUE,type='logical',help="Remove stressed cells?"), make_option("--stg",action="store",default="go",type='character',help="Geneset to use for stress ID"), make_option("--cut.stress",action="store",default=0.9,type='numeric',help="Cutoff for stress score"), - #make_option("--hpc.poststress",action="store",default=0.85,type='numeric',help="Max variance cutoff for PCs to use, post-stress"), make_option("--res.poststress",action="store",default=0.2,type='numeric',help="Resolution to cluster, post-stress"), - #make_option("--ds",action="store",default=250,type='integer',help="Number of cells to downsample"), - #make_option("--hpc.epi",action="store",default=0.85,type='numeric',help="Max variance cutoff for PCs to use, Epi"), - #make_option("--res.epi",action="store",default=0.2,type='numeric',help="Resolution to cluster, Epi"), - #make_option("--hpc.st",action="store",default=0.85,type='numeric',help="Max variance cutoff for PCs to use, St"), - #make_option("--res.st",action="store",default=0.15,type='numeric',help="Resolution to cluster, St"), make_option("--cut.ne",action="store",default=0.999,type='numeric',help="Cutoff for NE score") ) opt=parse_args(OptionParser(option_list=option_list)) @@ -164,14 +156,7 @@ rm(sc10x.D17) rm(sc10x.D27) rm(sc10x.D35) -#results <- scPC(sc10x,lx=opt$lx,hx=opt$hx,ly=opt$ly,cc=opt$cc,pc=opt$pc,hpc=opt$hpc,file="pre.stress",cca=TRUE) -#sc10x <- results[[1]] -#genes.hvg.prestress <- results[[2]] -#pc.use.prestress <- results[[3]] -#rm(results) - sc10x <- scCluster(sc10x,pc.use=opt$acca,res.use=opt$res.prestress,folder="pre.stress",red="cca.aligned") -#sc10x <- scCluster(sc10x,pc.use=pc.use.prestress,res.use=opt$res.prestress,folder="pre.stress",red="pca") if (opt$st==TRUE){ results <- scStress(sc10x,stg=opt$stg,res.use=opt$res.prestress,cut=opt$cut.stress) @@ -180,17 +165,7 @@ if (opt$st==TRUE){ sc10x.Stress <- results[[3]] rm(results) - #results <- scPC(sc10x,lx=opt$lx,hx=opt$hx,ly=opt$ly,cc=opt$cc,pc=opt$pc,hpc=opt$hpc,file="post.stress",cca=FALSE) - #sc10x <- results[[1]] - #genes.hvg.poststress <- results[[2]] - #pc.use.poststress <- results[[3]] - #rm(results) - - #sc10x <- scCluster(sc10x,pc.use=pc.use.poststress,res.use=opt$res.poststress,folder="post.stress",red="pca") sc10x <- scCluster(sc10x,pc.use=opt$acca,res.use=opt$res.poststress,folder="post.stress",red="cca.aligned") - #sc10x <- scCluster(sc10x,pc.use=opt$acca,res.use=0.15,folder="post.stress",red="cca.aligned") - #sc10x <- scCluster(sc10x,pc.use=opt$acca,res.use=0.25,folder="post.stress",red="cca.aligned") - #sc10x <- scCluster(sc10x,pc.use=opt$acca,res.use=0.5,folder="post.stress",red="cca.aligned") } gene.set1 <- read_delim("./genesets/DEG_Epi_5FC.txt","\t",escape_double=FALSE,trim_ws=TRUE,col_names=FALSE) @@ -303,12 +278,6 @@ gc() results.cor.Epi.lgea <- scQuSAGEsm(sc10x.Epi,gs=gene.set,ds=min.epi,nm="Epi.dws.sub",folder="lgea") rm(gene.set) -#sc10x.St <- scCluster(sc10x.St,pc.use=opt$acca,res.use=opt$res.st,folder="st",red="cca.aligned") -#sc10x.St <- scCluster(sc10x.St,pc.use=opt$acca,res.use=0.2,folder="st",red="cca.aligned") -#sc10x.St <- scCluster(sc10x.St,pc.use=opt$acca,res.use=0.25,folder="st",red="cca.aligned") -#sc10x.St <- scCluster(sc10x.St,pc.use=opt$acca,res.use=0.5,folder="st",red="cca.aligned") -#sc10x.St <- scCluster(sc10x.St,pc.use=opt$acca,res.use=0.1,folder="st",red="cca.aligned") - sc10x.St <- RunTSNE(object=sc10x.St,reduction.use="cca.aligned",dims.use=1:opt$acca,do.fast=TRUE) postscript(paste0("./analysis/tSNE/st/tSNE_Sample.eps")) plot <- TSNEPlot(object=sc10x.St,group.by="samples",pt.size=2.5,do.return=TRUE,vector.friendly=FALSE) @@ -363,7 +332,6 @@ sc10x <- scMerge(sc10x,sc10x,sc10x.Epi.NE,i.1="Merge_Epi.dws_St.go",i.2="NE",nm= sc10x.Epi <- scMerge(sc10x.Epi,sc10x.Epi,sc10x.Epi.NE,i.1="Epi.dws.sub",i.2="NE",nm="Epi.dws.sub_NE") gene.orthog <- read.delim("./genesets/Ensemble.mus-hum.txt") -#gene.set1 <- read_excel("./genesets/SupTab3_Consensus_Sigs.xlsx",skip=5) gene.set1 <- read_csv("./genesets/SupTab3_Consensus_Sigs.csv",skip=6) gene.set2 <- as.data.frame(gene.set1$Basal[!is.na(gene.set1$Basal)]) colnames(gene.set2) <- "genes" @@ -402,7 +370,6 @@ gene.set2 <- as.list(gene.set2) names(gene.set2) <- "Ionocyte" gene.set <- c(gene.set,gene.set2) rm(gene.set2) -#gene.set1 <- read_excel("./genesets/SupTab6_Krt13_Hillock.xlsx",skip=5) gene.set1 <- read_csv("./genesets/SupTab6_Krt13_Hillock.csv",skip=6) gene.set1 <- gene.set1[gene.set1$FDR<=0.05 & gene.set1$'log2 fold-change (MAST)'>=1.5,1] colnames(gene.set1) <- "genes"