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

Remove develop scripts

parent 95cafb6f
No related merge requests found
#!/bin/bash
#SBATCH --job-name R_FullAnalysis
#SBATCH -p 256GB,256GBv1,384GB
#SBATCH -N 1
#SBATCH -t 7-0:0:0
#SBATCH -o job_%j.out
#SBATCH -e job_%j.out
#SBATCH --mail-type ALL
#SBATCH --mail-user gervaise.henry@utsouthwestern.edu
module load R/3.4.1-gccmkl
Rscript ../r.scripts/sc-TissueMapper_RUN.D27.R
\ No newline at end of file
#!/bin/bash
#SBATCH --job-name R_FullAnalysis
#SBATCH -p 256GB,256GBv1,384GB
#SBATCH -N 1
#SBATCH -t 7-0:0:0
#SBATCH -o job_%j.out
#SBATCH -e job_%j.out
#SBATCH --mail-type ALL
#SBATCH --mail-user gervaise.henry@utsouthwestern.edu
module load R/3.4.1-gccmkl
Rscript ../r.scripts/sc-TissueMapper_RUN.D3.R
#Rscript ../r.scripts/sc-TissueMapper_RUN.D.diy.R
#Rscript ../r.scripts/sc-TissueMapper_RUN.D.pseudotime.R
\ No newline at end of file
gc()
library(methods)
library(optparse)
library(Seurat)
library(readr)
library(fBasics)
library(pastecs)
library(qusage)
source("../r.scripts/sc-TissueMapper.R")
#Create folder structure
setwd("../")
if (!dir.exists("./analysis")){
dir.create("./analysis")
}
if (!dir.exists("./analysis/qc")){
dir.create("./analysis/qc")
}
if (!dir.exists("./analysis/qc/cc")){
dir.create("./analysis/qc/cc")
}
if (!dir.exists("./analysis/tSNE")){
dir.create("./analysis/tSNE")
}
if (!dir.exists("./analysis/tSNE/pre.stress")){
dir.create("./analysis/tSNE/pre.stress")
}
if (!dir.exists("./analysis/pca")){
dir.create("./analysis/pca")
}
if (!dir.exists("./analysis/pca/stress")){
dir.create("./analysis/pca/stress")
}
if (!dir.exists("./analysis/violin")){
dir.create("./analysis/violin")
}
if (!dir.exists("./analysis/violin/stress")){
dir.create("./analysis/violin/stress")
}
if (!dir.exists("./analysis/table")){
dir.create("./analysis/table")
}
if (!dir.exists("./analysis/tSNE/post.stress")){
dir.create("./analysis/tSNE/post.stress")
}
if (!dir.exists("./analysis/cor")){
dir.create("./analysis/cor")
}
if (!dir.exists("./analysis/tSNE/lin")){
dir.create("./analysis/tSNE/lin")
}
if (!dir.exists("./analysis/tSNE/epi")){
dir.create("./analysis/tSNE/epi")
}
if (!dir.exists("./analysis/tSNE/st")){
dir.create("./analysis/tSNE/st")
}
if (!dir.exists("./analysis/tSNE/merge")){
dir.create("./analysis/tSNE/merge")
}
if (!dir.exists("./analysis/pca/ne")){
dir.create("./analysis/pca/ne")
}
if (!dir.exists("./analysis/tSNE/ne")){
dir.create("./analysis/tSNE/ne")
}
if (!dir.exists("./analysis/violin/ne")){
dir.create("./analysis/violin/ne")
}
if (!dir.exists("./analysis/tSNE/FINAL")){
dir.create("./analysis/tSNE/FINAL")
}
if (!dir.exists("./analysis/deg")){
dir.create("./analysis/deg")
}
#Retrieve command-line options
option_list=list(
make_option("--p",action="store",default="D27PrF",type='character',help="Project Name"),
make_option("--g",action="store",default="ALL",type='character',help="Group To analyze"),
make_option("--lg",action="store",default=500,type='integer',help="Threshold for cells with minimum genes"),
make_option("--hg",action="store",default=2500,type='integer',help="Threshold for cells with maximum genes"),
make_option("--lm",action="store",default=0,type='numeric',help="Threshold for cells with minimum %mito genes"),
make_option("--hm",action="store",default=0.1,type='numeric',help="Threshold for cells with maximum %mito genes"),
make_option("--lx",action="store",default=0.0125,type='numeric',help="x low threshold for hvg selection"),
make_option("--hx",action="store",default=3.5,type='numeric',help="x high threshold for hvg selection"),
make_option("--ly",action="store",default=0.5,type='numeric',help="y low threshold for hvg selection"),
make_option("--cc",action="store",default=TRUE,type='logical',help="Scale cell cycle?"),
make_option("--pc",action="store",default=25,type='integer',help="Number of PCs to cacluate"),
make_option("--hpc",action="store",default=0.8,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="dws",type='character',help="Geneset to use for stress ID"),
make_option("--hpc.poststress",action="store",default=0.80,type='numeric',help="Max variance cutoff for PCs to use, post-stress"),
make_option("--res.poststress",action="store",default=0.5,type='numeric',help="Resolution to cluster, post-stress"),
make_option("--ds",action="store",default=0,type='integer',help="Number of cells to downsample"),
make_option("--hpc.epi",action="store",default=0.75,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.75,type='numeric',help="Max variance cutoff for PCs to use, St"),
make_option("--res.st",action="store",default=0.2,type='numeric',help="Resolution to cluster, St")
)
opt=parse_args(OptionParser(option_list=option_list))
rm(option_list)
if (opt$lm==0){opt$lm=-Inf}
sc10x <- scLoad(opt$p)
sc10x <- scSubset(sc10x,"ALL",opt$g)
if (opt$cc==TRUE){
results <- scCellCycle(sc10x)
sc10x <- results[[1]]
genes.s <- results[[2]]
genes.g2m <- results[[3]]
rm(results)
} else {
genes.s=""
genes.g2m=""
}
results <- scQC(sc10x,lg=opt$lg,hg=opt$hg,lm=opt$lm,hm=opt$hm)
sc10x <- results[[1]]
counts.cell.raw <- results[[2]]
counts.gene.raw <- results[[3]]
counts.cell.filtered <- results[[4]]
counts.gene.filtered <- results[[5]]
rm(results)
results <- scPC(sc10x,lx=opt$lx,hx=opt$hx,ly=opt$ly,cc=opt$cc,pc=opt$pc,hpc=opt$hpc,file="pre.stress")
sc10x <- results[[1]]
genes.hvg <- results[[2]]
pc.use <- results[[3]]
rm(results)
sc10x <- scCluster(sc10x,pc.use=pc.use,res.use=opt$res.prestress,folder="pre.stress")
if (opt$st==TRUE){
results <- scStress(sc10x,stg=opt$stg,res.use=opt$res.prestress,pc.use=pc.use)
sc10x <- results[[1]]
counts.cell.filtered.stress <- results[[2]]
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.poststress,file="post.stress")
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")
}
gene.set1 <- read_delim("./genesets/genes.deg.St.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "St"
gene.set <- c(gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.Epi.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Epi"
gene.set <- c(gene.set,gene.set1)
rm(gene.set1)
results <- scQuSAGE(sc10x,gs=gene.set,res.use=opt$res.poststress,ds=opt$ds,nm="Lin",folder="lin")
sc10x <- results[[1]]
results.cor.Lin <- results[[2]]
results.clust.Lin.id <- results[[3]]
rm(results)
rm(gene.set)
sc10x.Epi <- scSubset(sc10x,i="Lin",g="Epi")
if (any(levels(sc10x@ident)=="Unknown")){
sc10x.St <- scSubset(sc10x,i="Lin",g=c("St","Unknown"))
} else {
sc10x.St <- scSubset(sc10x,i="Lin",g="St")
}
#results <- scPC(sc10x.Epi,lx=opt$lx,hx=opt$hx,ly=opt$ly,cc=opt$cc,pc=opt$pc,hpc=opt$hpc.epi,file="Epi")
#sc10x.Epi <- results[[1]]
#genes.hvg.epi <- results[[2]]
#pc.use.epi <- results[[3]]
#rm(results)
sc10x.Epi <- scCluster(sc10x.Epi,pc.use=pc.use.poststress,res.use=0.1,folder="epi")
sc10x.Epi <- scCluster(sc10x.Epi,pc.use=pc.use.poststress,res.use=0.5,folder="epi")
sc10x.Epi <- scCluster(sc10x.Epi,pc.use=pc.use.poststress,res.use=opt$res.epi,folder="epi")
gene.set1 <- read_delim("./genesets/genes.deg.BE.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "BE"
gene.set <- c(gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.LE.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "LE"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.OE1.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "OE_SCGB"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.OE2.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "OE_KRT13"
gene.set <- c(gene.set,gene.set1)
rm(gene.set1)
results <- scQuSAGE(sc10x.Epi,gs=gene.set,res.use=opt$res.epi,ds=opt$ds,nm="Epi.dws.sc",folder="epi")
sc10x.Epi <- results[[1]]
results.cor.Epi.dws.sc <- results[[2]]
results.clust.Epi.dws.id <- results[[3]]
rm(results)
rm(gene.set)
#results <- scPC(sc10x.St,lx=opt$lx,hx=opt$hx,ly=opt$ly,cc=opt$cc,pc=opt$pc,hpc=opt$hpc.st,file="St")
#sc10x.St <- results[[1]]
#genes.hvg.st <- results[[2]]
#pc.use.st <- results[[3]]
#rm(results)
sc10x.St <- scCluster(sc10x.St,pc.use=pc.use.poststress,res.use=0.1,folder="st")
sc10x.St <- scCluster(sc10x.St,pc.use=pc.use.poststress,res.use=0.5,folder="st")
sc10x.St <- scCluster(sc10x.St,pc.use=pc.use.poststress,res.use=opt$res.st,folder="st")
gene.set1 <- read_delim("./genesets/genes.deg.Fib.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Fib"
gene.set <- c(gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.SM.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "SM"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.Endo.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Endo"
gene.set <- c(gene.set,gene.set1)
gene.set1 <- read_delim("./genesets/genes.deg.Leu.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
gene.set1 <- gene.set1[1]
gene.set1 <- as.list(gene.set1)
names(gene.set1) <- "Leu"
gene.set <- c(gene.set,gene.set1)
rm(gene.set1)
results <- scQuSAGE(sc10x.St,gs=gene.set,res.use=opt$res.st,ds=opt$ds,nm="St.dws.sc",folder="st")
sc10x.St <- results[[1]]
results.cor.St.go <- results[[2]]
results.clust.St.go.id <- results[[3]]
rm(results)
rm(gene.set)
sc10x.Epi.NE <- scNE(sc10x.Epi,neg="dws")
sc10x.Epi <- scMergeSubClust(sc10x.Epi,i="Epi.dws.sc",g=c("BE","LE","OE_SCGB","OE_KRT13"),nm="Merge")
sc10x.St <- scMergeSubClust(sc10x.St,i="St.dws.sc",g=c("Endo","SM","Fib","Leu"),nm="Merge")
sc10x <- scMerge(sc10x,sc10x.Epi,sc10x.St,i.1="Merge",i.2="Merge",nm="Merge_Epi.dws.sc_St.dws.sc")
sc10x <- scMerge(sc10x,sc10x,sc10x.Epi.NE,i.1="Merge_Epi.dws.sc_St.dws.sc",i.2="NE",nm="Merge_Epi.dws.sc_St.dws.sc_NE")
sc10x <- SetAllIdent(object=sc10x,id="Merge_Epi.dws.sc_St.dws.sc")
sc10x@ident <- factor(sc10x@ident,levels=c("BE","LE","OE_SCGB","OE_KRT13","Fib","SM","Endo","Leu"))
postscript("./analysis/tSNE/FINAL/tSNE_FINAL.eps")
plot <- TSNEPlot(object=sc10x,pt.size=2.5,do.return=TRUE,vector.friendly=FALSE)
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()
scTables(sc10x,i.1="samples",i.2="Merge_Epi.dws.sc_St.dws.sc")
scTables(sc10x,i.1="samples",i.2="Merge_Epi.dws.sc_St.dws.sc_NE")
scTables(sc10x,i.1="Merge_Epi.dws.sc_St.dws.sc_NE",i.2="Merge_Epi.dws.sc_St.dws.sc")
save(list=ls(pattern="sc10x.Stress"),file="./analysis/sc10x.Stress.Rda")
rm(list=ls(pattern="sc10x.Stress"))
save(list=ls(pattern="^genes.deg"),file="./analysis/DEG.Rda")
rm(list=ls(pattern="^genes.deg"))
save(list=ls(pattern="sc10x.Epi"),file="./analysis/sc10x.Epi.Rda")
rm(list=ls(pattern="^sc10x.Epi"))
save(list=ls(pattern="sc10x.St"),file="./analysis/sc10x.St.Rda")
rm(list=ls(pattern="sc10x.St"))
save(list=ls(pattern="^sc10x"),file="./analysis/sc10x.Rda")
rm(list=ls(pattern="^sc10x"))
save.image(file="./analysis/Data.RData")
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