Commit 40b5287d authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Stop caclulating tsne

parent 42ab2961
......@@ -75,11 +75,11 @@ for (i in names(sc10x)){
} else if (ncol(sc10x.temp) <= 100) {
pc.calc <- ncol(sc10x.temp)-1
}
results <- scPC(sc10x.temp,pc=pc.calc,hpc=0.9,file=paste0(i,".pre.stress"),print="2",assay="SCT")
results <- scPC(sc10x.temp,pc=pc.calc,hpc=0.9,file=paste0(i,".pre.stress"),print="umap",assay="SCT")
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="0",folder=paste0(i,".pre.stress"),assay="SCT")
sc10x.temp <- scCluster(sc10x.temp,res=0.5,red="pca",dim=pc.use.prestress.temp,print="umap",folder=paste0(i,".pre.stress"),assay="SCT")
sc10x[i] <- sc10x.temp
pc.use.prestress[i] <- pc.use.prestress.temp
rm(sc10x.temp)
......@@ -142,7 +142,7 @@ if (ncol(sc10x) > 1000) {
} else if (ncol(sc10x) > 100) {
pc.calc <- ncol(sc10x)-1
}
results <- scPC(sc10x,pc=pc.calc,hpc=0.9,file="ALL",print="2")
results <- scPC(sc10x,pc=pc.calc,hpc=0.9,file="ALL",print="umap")
sc10x <- results[[1]]
pc.use.poststress <- results[[2]]
rm(results)
......@@ -150,7 +150,7 @@ rm(pc.calc)
res <- c(seq(0.1,0.5,0.1),0.75,seq(1,5,1))
sc10x <- scCluster(sc10x,res=res,red="pca",dim=pc.use.poststress,print="2",folder="ALL")
sc10x <- scCluster(sc10x,res=res,red="pca",dim=pc.use.poststress,print="umap",folder="ALL")
DefaultAssay(object=sc10x) <- "SCT"
......
......@@ -504,7 +504,7 @@ scCellCycle <- function(sc10x,sub=FALSE,sp="hu"){
}
scPC <- function(sc10x,pc=50,hpc=0.9,file="pre.stress",print="tsne",assay="integrated"){
scPC <- function(sc10x,pc=50,hpc=0.9,file="pre.stress",print="umap",assay="integrated"){
#Scale Seurat object & calculate # of PCs to use
#Inputs:
......@@ -574,7 +574,7 @@ scAlign <- function(sc10x.l){
}
scCluster <- function(sc10x,res=0.1,red="pca",dim,print="tsne",folder=FALSE,assay="integrated"){
scCluster <- function(sc10x,res=0.1,red="pca",dim,print="umap",folder=FALSE,assay="integrated"){
#Cluster Seurat object and produce visualizations
#Inputs:
......@@ -601,7 +601,7 @@ scCluster <- function(sc10x,res=0.1,red="pca",dim,print="tsne",folder=FALSE,assa
DefaultAssay(sc10x) <- assay
#Calculste Vis
sc10x <- RunTSNE(sc10x,dims=1:dim,reduction="pca",assay=assay)
#sc10x <- RunTSNE(sc10x,dims=1:dim,reduction="pca",assay=assay)
sc10x <- RunUMAP(sc10x,dims=1:dim,reduction="pca",assay=assay)
sc10x <- FindNeighbors(sc10x,reduction=red,verbose=FALSE,assay=assay)
......@@ -610,7 +610,7 @@ scCluster <- function(sc10x,res=0.1,red="pca",dim,print="tsne",folder=FALSE,assa
sc10x <- FindClusters(sc10x,resolution=i,verbose=FALSE)
plot1 <- DimPlot(sc10x,reduction="pca",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot2 <- DimPlot(sc10x,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
#plot2 <- DimPlot(sc10x,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot3 <- DimPlot(sc10x,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
if (print=="tsne"){
......@@ -638,7 +638,7 @@ scCluster <- function(sc10x,res=0.1,red="pca",dim,print="tsne",folder=FALSE,assa
for (i in c("samples","HTO_maxID","hash.ID")[c("samples","HTO_maxID","hash.ID") %in% colnames(sc10x@meta.data)]){
plot1 <- DimPlot(sc10x,reduction="pca",group.by=i)
plot2 <- DimPlot(sc10x,reduction="tsne",group.by=i)
#plot2 <- DimPlot(sc10x,reduction="tsne",group.by=i)
plot3 <- DimPlot(sc10x,reduction="umap",group.by=i)
legend <- cowplot::get_legend(plot1)
......@@ -760,9 +760,9 @@ scScore <- function(sc10x.l,score,geneset,cut.pt=0.9,anchor=FALSE){
plot1 <- DimPlot(sc10x,reduction="pca",label=TRUE,repel=TRUE)+theme(legend.position="none")+ggtitle("ALL")
plot2 <- DimPlot(sc10x.negative,reduction="pca",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot3 <- DimPlot(sc10x.positive,reduction="pca",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot4 <- DimPlot(sc10x,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")+ggtitle("Negative")
plot5 <- DimPlot(sc10x.negative,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot6 <- DimPlot(sc10x.positive,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
#plot4 <- DimPlot(sc10x,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")+ggtitle("Negative")
#plot5 <- DimPlot(sc10x.negative,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
#plot6 <- DimPlot(sc10x.positive,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot7 <- DimPlot(sc10x,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")+ggtitle("Positive")
plot8 <- DimPlot(sc10x.negative,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot9 <- DimPlot(sc10x.positive,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
......@@ -790,7 +790,7 @@ scScore <- function(sc10x.l,score,geneset,cut.pt=0.9,anchor=FALSE){
}
scQuSAGE <- function(sc10x,gs,save=FALSE,type,id,ds=0,nm="pops",print="tsne"){
scQuSAGE <- function(sc10x,gs,save=FALSE,type,id,ds=0,nm="pops",print="umap"){
#Runs QuSAGE
#Inputs:
......@@ -958,7 +958,7 @@ scQuSAGE <- function(sc10x,gs,save=FALSE,type,id,ds=0,nm="pops",print="tsne"){
}
plot1 <- DimPlot(sc10x,reduction="pca",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot2 <- DimPlot(sc10x,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
#plot2 <- DimPlot(sc10x,reduction="tsne",label=TRUE,repel=TRUE)+theme(legend.position="none")
plot3 <- DimPlot(sc10x,reduction="umap",label=TRUE,repel=TRUE)+theme(legend.position="none")
if (print=="tsne"){
postscript(paste0("./analysis/vis/",nm,"/tSNE_",id,"_",nm,".eps"))
......@@ -1002,7 +1002,7 @@ scShinyOutput <- function(sc10x,anal="raw"){
exp.extra[5,] <- as.numeric(sc10x$Stress1)
exp <- rbind(exp,exp.extra)
Matrix::writeMM(as(exp,"dgCMatrix"),file=paste0("./analysis/shiny/",anal,"/outs/filtered_feature_bc_matrix/matrix.mtx.gz"))
for (i in c("pca","tsne","umap")){
for (i in c("pca","umap")){
dr <- Embeddings(sc10x,i)
if (i != "pca"){
colnames(dr) <- c(paste0(toupper(i),"-",1:2))
......
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