Commit 407e9306 authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Only use samples which were sequenced deep, merge samples less than 750 cells b4 CCA

parent 0be5f735
......@@ -3,7 +3,7 @@
mkdir ../analysis/DATA/10x
for i in `cat ../analysis/DATA/${1}-demultiplex.csv`; do
if [[ ${i} = *Sample* ]]
if [[ ${i} = *Samples* ]]
then
continue
else
......
......@@ -19,7 +19,7 @@ library(autothresholdr)
options(bitmapType="cairo")
option_list=list(
make_option("--p",action="store",default="huBl",type='character',help="Project Name"),
make_option("--p",action="store",default="Biopsy",type='character',help="Project Name"),
make_option("--s",action="store",default="hu",type='character',help="Species")
)
opt=parse_args(OptionParser(option_list=option_list))
......@@ -36,11 +36,26 @@ load("./analysis/sc10x.raw.RData")
load("./genesets/scDWS.250.rda")
load("./genesets/cibersort.rda")
singler = CreateBigSingleRObject(GetAssayData(sc10x,assay="SCT"), annot = NULL, opt$p, min.genes = 0,
technology = "10X", species = "Human", citation = "",
ref.list = list(scDWS.250), normalize.gene.length = F, variable.genes = "de",
fine.tune = T, do.signatures = T, clusters = NULL, do.main.types = F,
reduce.file.size = T, numCores = 15)
if (opt$s == "hu"){
species <- "Human"
} else if (opt$s == "mu") {
species <- "Mouse"
}
if (ncol(sc10x) > 10000){
singler <- CreateBigSingleRObject(GetAssayData(sc10x,assay="SCT"),annot=NULL,opt$p,min.genes=0,
technology="10X",species=species,citation="",
ref.list=list(scDWS.250),normalize.gene.length=F,variable.genes="de",
fine.tune=T,do.signatures=T,clusters=NULL,do.main.types=F,
reduce.file.size=T,numCores=25)
} else {
singler <- CreateSinglerObject(GetAssayData(sc10x,assay="SCT"),annot=NULL,opt$p,min.genes=0,
technology="10X",species=species,citation="",
ref.list=list(scDWS.250),normalize.gene.length=F,variable.genes="de",
fine.tune=T,do.signatures=T,clusters=NULL,do.main.types=F,
reduce.file.size=T, numCores=25)
}
# cells.epi <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="Epi",])
# cells.fmst <-names(singler$singler[[1]]$SingleR.single.main$labels[singler$singler[[1]]$SingleR.single.main$labels[,1]=="FMSt",])
......
......@@ -20,7 +20,7 @@ options(bitmapType="cairo")
options(future.globals.maxSize= 10000000000)
option_list=list(
make_option("--p",action="store",default="PdPbPc",type='character',help="Project Name"),
make_option("--p",action="store",default="Biopsy",type='character',help="Project Name"),
make_option("--s",action="store",default="hu",type='character',help="Species")
)
opt=parse_args(OptionParser(option_list=option_list))
......@@ -55,9 +55,11 @@ rm(results)
# genes.g2m <- results[[3]]
# rm(results)
sc10x <- sc10x[as.character(unlist(sc10x.groups[sc10x.groups$Deep==1,1]))]
merges <- NULL
for (i in names(counts.cell.filtered)){
if (counts.cell.filtered[[i]]<500){
for (i in names(counts.cell.filtered[as.character(unlist(sc10x.groups[sc10x.groups$Deep==1,1]))])){
if (counts.cell.filtered[[i]]<750){
merges <- c(merges,i)
}
}
......@@ -101,5 +103,7 @@ sc10x <- scCluster(sc10x,res=res,red="pca",dim=pc.use.poststress,print="2",folde
DefaultAssay(object=sc10x) <- "SCT"
scShinyOutput()
save(sc10x,file=paste0("./analysis/sc10x.raw.rda"))
save.image(file="./analysis/sc10x.raw.RData")
......@@ -26,6 +26,45 @@ scFolders <- function(){
if (!dir.exists("./analysis/cor")){
dir.create("./analysis/cor")
}
if (!dir.exists("./analysis/shiny")){
dir.create("./analysis/shiny")
}
if (!dir.exists("./analysis/shiny")){
dir.create("./analysis/shiny")
}
if (!dir.exists("./analysis/shiny/raw")){
dir.create("./analysis/shiny/raw")
}
if (!dir.exists("./analysis/shiny/raw/outs")){
dir.create("./analysis/shiny/raw/outs")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis")){
dir.create("./analysis/shiny/raw/outs/analysis")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/clustering")){
dir.create("./analysis/shiny/raw/outs/analysis/clustering")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/diffexp")){
dir.create("./analysis/shiny/raw/outs/analysis/diffexp")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/pca")){
dir.create("./analysis/shiny/raw/outs/analysis/pca")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/pca/10_components")){
dir.create("./analysis/shiny/raw/outs/analysis/pca/10_components")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/tsne")){
dir.create("./analysis/shiny/raw/outs/analysis/tsne")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/tsne/2_components")){
dir.create("./analysis/shiny/raw/outs/analysis/tsne/2_components")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/umap")){
dir.create("./analysis/shiny/raw/outs/analysis/umap")
}
if (!dir.exists("./analysis/shiny/raw/outs/analysis/umap/2_components")){
dir.create("./analysis/shiny/raw/outs/analysis/umap/2_components")
}
}
......@@ -859,3 +898,37 @@ scQuSAGE <- function(sc10x,gs,save=FALSE,type,id,ds=0,nm="pops",print="tsne"){
names(results)=c("sc10x",paste0("results.cor.",nm),paste0("results.clust.",nm,".id"))
return(results)
}
scShinyOutput <- function(){
for (i in c("pca","tsne","umap")){
dr <- Embeddings(sc10x,i)
if (i != "pca"){
colnames(dr) <- c(paste0(toupper(i),"-",1:2))
} else {
dr <- dr[,1:10]
colnames(dr) <- c(paste0(toupper(i),"-",1:10))
}
dr <- cbind(dr,Barcode=rownames(dr))
dr <- dr[,c(3,1,2)]
dr <- as.data.frame(dr,row.names=FALSE)
if (i != "pca"){
write_csv(dr,paste0("./analysis/shiny/raw/outs/analysis/",i,"/2_components/projection.csv"),col_names=TRUE)
} else {
write_csv(dr,paste0("./analysis/shiny/raw/outs/analysis/",i,"/10_components/projection.csv"),col_names=TRUE)
}
}
for (i in c("samples",paste0("integrated_snn_res.",res))){
if (!dir.exists(paste0("./analysis/shiny/raw/outs/analysis/clustering/",gsub("integrated_snn_res.","res_",i)))){
dir.create(paste0("./analysis/shiny/raw/outs/analysis/clustering/",gsub("integrated_snn_res.","res_",i)))
}
clust <- as.matrix(sc10x[[i]])
colnames(clust) <- "Cluster"
clust <- cbind(clust,Barcode=rownames(clust))
clust <- clust[,c(2,1)]
clust <- as.data.frame(clust,row.names=FALSE)
write_csv(clust,paste0("./analysis/shiny/raw/outs/analysis/clustering/",gsub("integrated_snn_res.","res_",i),"/clusters.csv"),col_names=TRUE)
}
#Idents(sc10x) <- "integrated_snn_res.0.1"
#deg <- FindAllMarkers(sc10x,assay="SCT",slot="scale.data",logfc.threshold=0,test.use="MAST")
}
\ No newline at end of file
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