Commit 21032bfc authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

More refactoring

parent fcfc7fa9
#!/bin/bash
#SBATCH --job-name sc10x.id
#SBATCH -p 128GB,256GB,256GBv1,384GB
#SBATCH -p 256GB,256GBv1,384GB
#SBATCH -N 1
#SBATCH -t 7-0:0:0
#SBATCH -o job_%j.out
......@@ -8,9 +8,10 @@
#SBATCH --mail-type ALL
#SBATCH --mail-user gervaise.henry@utsouthwestern.edu
module load python/3.6.4-anaconda
source activate umap
module load R/3.6.1-gccmkl
module load gdal
module load cairo/1.14.8
module load R/3.6.1-gccmkl
module load hdf5_18/1.8.17
Rscript ../r.scripts/SingleR.R --p "$1" --s "$2" --o "$3"
Rscript ../r.scripts/sc-TissueMapper_ID.R --p "$1" --s "$2" --o "$3"
......@@ -8,9 +8,10 @@
#SBATCH --mail-type ALL
#SBATCH --mail-user gervaise.henry@utsouthwestern.edu
module load python/3.6.4-anaconda
source activate umap
module load R/3.6.1-gccmkl
module load gdal
module load cairo/1.14.8
module load R/3.6.1-gccmkl
module load hdf5_18/1.8.17
Rscript ../r.scripts/sc-TissueMapper_RUN.R --p "$1" --s "$2"
gc()
library(optparse)
library(Seurat)
library(SingleR)
library(RColorBrewer)
library(viridis)
library(gridExtra)
library(SingleR)
library(ggplot2)
options(future.globals.maxSize= 1000000000000)
option_list=list(
make_option("--p",action="store",default="huPr_PdPb",type='character',help="Project Name"),
make_option("--s",action="store",default="hu",type='character',help="Species"),
......@@ -59,13 +61,13 @@ pop.epi <- pop.epi[common,]
pop.st <- pop.st[common,]
rm(common)
singler.lin <- SingleR(sc10x.se,ref=list(imm=imm,pop.epi=pop.epi,pop.st=pop.st),method="cluster",clusters=sc10x.se$integrated_snn_res.0.5,labels=list(imm=imm$label.main,pop.epi=pop.epi$label.fine,pop.st=pop.st$label.fine),de.method="wilcox",BPPARAM=BiocParallel::MulticoreParam(workers=20))
singler.lin <- SingleR(sc10x.se,ref=list(imm=imm,pop.epi=pop.epi,pop.st=pop.st),method="cluster",clusters=sc10x.se$integrated_snn_res.0.5,labels=list(imm=imm$label.main,pop.epi=pop.epi$label.fine,pop.st=pop.st$label.fine),BPPARAM=BiocParallel::MulticoreParam(workers=20))
labs <- singler.lin$labels
labs[labs %in% c("BE","LE","Hillock","Club")] <- "Epi"
labs[labs %in% c("T cells","CD4+ T cells","CD8+ T cells","NK cells","B cells","Monocytes","Dendritic cells","Neutrophils","Basophils","Progenitors")] <- "Leu"
sc10x$lin <- labs[match(sc10x.se$integrated_snn_res.0.5,singler.lin@rownames)]
rm(labs)
#DimPlot(sc10x,group.by="lin",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
DimPlot(sc10x,group.by="lin",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
Idents(sc10x) <- "lin"
sc10x.epi <- subset(sc10x, idents="Epi")
......@@ -136,6 +138,10 @@ sc10x$pop[names(sc10x.epi$pop)] <- sc10x.epi$pop
sc10x$pop[names(sc10x.leu$pop)] <- sc10x.leu$pop
#DimPlot(sc10x,group.by="pop",reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
if (!dir.exists("./analysis/vis/singler/")){
dir.create("./analysis/vis/singler/")
}
plot <- DimPlot(sc10x,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
postscript(paste0("./analysis/vis/singler/UMAP_all.eps"))
print(plot)
......@@ -181,7 +187,7 @@ saveRDS(sc10x.fib,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",
saveRDS(sc10x.sm,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_sm.rds"))
saveRDS(sc10x.leu,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",opt$p,"_id_leu.rds"))
rm(list=ls(pattern="^sc10x"))
save(list=ls(pattern="^singler"),file='./analysis/singler_objects.RData')
rm(list=ls(pattern="^sc10x"))
rm(list=ls(pattern="^singler"))
save.image(file="./analysis/sc10x.id.RData")
\ No newline at end of file
save.image(file="./analysis/sc10x.id.RData")
gc()
# library(methods)
library(optparse)
library(Seurat)
library(readr)
# library(readxl)
# library(fBasics)
# library(pastecs)
# library(qusage)
# library(RColorBrewer)
# library(monocle)
library(dplyr)
library(autothresholdr)
library(RColorBrewer)
library(viridis)
library(gridExtra)
# library(SingleR)
# library(sctransform)
library(autothresholdr)
library(ggplot2)
#options(bitmapType="cairo")
options(future.globals.maxSize= 1000000000000)
option_list=list(
......@@ -77,11 +68,13 @@ for (i in names(sc10x)){
sc10x.temp <- results[[1]]
pc.use.prestress.temp <- results[[2]]
rm(results)
sc10x.temp <- scCluster(sc10x.temp,res=0.5,red="pca",dim=pc.use.prestress.temp,print="2",folder=paste0(i,".pre.stress"),assay="SCT")
sc10x.temp <- scCluster(sc10x.temp,res=0.5,red="pca",dim=pc.use.prestress.temp,print="0",folder=paste0(i,".pre.stress"),assay="SCT")
sc10x[i] <- sc10x.temp
pc.use.prestress[i] <- pc.use.prestress.temp
rm(sc10x.temp)
rm(pc.use.prestress.temp)
}
rm(sc10x.temp)
rm(i)
if (opt$s == "hu"){
genes.stress <- read_delim("/work/urology/ghenry/RNA-Seq/SingleCell/ANALYSIS/REF/stress/genes.deg.Stress.csv",",",escape_double=FALSE,trim_ws=TRUE,col_names=TRUE)
......@@ -145,10 +138,11 @@ sc10x@meta.data <- sc10x@meta.data[,c("samples","integrated_snn_res.0.1","integr
saveRDS(sc10x,paste0("./analysis/",project.name,"_raw.rds"))
save.image(file="./analysis/sc10x.raw.RData")
library(sceasy)
library(reticulate)
use_condaenv('sceasy')
convertFormat(sc10x,from="seurat",to="anndata",outFile=paste0("/project/urology/Strand_lab/shared/cellxgene/anndata/",project.name,"_raw.h5ad"),assay="SCT",main_layer="scale.data")
saveRDS(sc10x,paste0("/project/urology/Strand_lab/shared/cellxgene/seurat/",project.name,"_raw.rds"))
rm(list=ls(pattern="sc10x"))
save.image(file="./analysis/sc10x.raw.RData")
......@@ -580,12 +580,11 @@ scCluster <- function(sc10x,res=0.1,red="pca",dim,print="tsne",folder=FALSE,assa
#Create subfolder if necessary
if (folder==FALSE){
sub <- ""
} else {
} else if (print != "0") {
if (!dir.exists(paste0("./analysis/vis/",folder))){
dir.create(paste0("./analysis/vis/",folder))
}
sub <- paste0(folder,"/")
}
DefaultAssay(sc10x) <- assay
......
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