From 1f8ba5df1ab705284b976c95242a7cc46e450590 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Thu, 5 Oct 2023 18:05:26 +0200 Subject: [PATCH 1/7] moved around the try/catch block --- R/scrublet_doubletDetection.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/R/scrublet_doubletDetection.R b/R/scrublet_doubletDetection.R index e353beefb..efd3a97b2 100644 --- a/R/scrublet_doubletDetection.R +++ b/R/scrublet_doubletDetection.R @@ -242,10 +242,8 @@ runScrublet <- function(inSCE, error=function(cond) { message(paste0(date(), " ... Scrublet did not complete successfully; Returning SCE without changes. Scrublet error:")) message(cond) - } -) - - # if (inherits(error, "try-error")) { + } + # if (inherits(error, "try-error")) { # warning("Scrublet did not complete successfully. Returning SCE without", # " making any changes. Error given by Scrublet: \n\n", error) # } @@ -261,5 +259,8 @@ runScrublet <- function(inSCE, metadata(tempSCE) <- metadata(inSCE) reducedDims(tempSCE) <- reducedDims(inSCE) - return(tempSCE) + return(tempSCE) +) + + } From 89384e377036b3d76fc96c1e78f46d6c660aa7df Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Tue, 10 Oct 2023 10:33:20 -0400 Subject: [PATCH 2/7] fixed scrublet try/catch --- R/scrublet_doubletDetection.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/scrublet_doubletDetection.R b/R/scrublet_doubletDetection.R index efd3a97b2..4bafd7cdb 100644 --- a/R/scrublet_doubletDetection.R +++ b/R/scrublet_doubletDetection.R @@ -242,7 +242,8 @@ runScrublet <- function(inSCE, error=function(cond) { message(paste0(date(), " ... Scrublet did not complete successfully; Returning SCE without changes. Scrublet error:")) message(cond) - } + return(inSCE) + }, # if (inherits(error, "try-error")) { # warning("Scrublet did not complete successfully. Returning SCE without", # " making any changes. Error given by Scrublet: \n\n", error) From aa21153e3e0823c94c36c5141c30986958fc6180 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Tue, 10 Oct 2023 13:26:47 -0400 Subject: [PATCH 3/7] applying another fix to scrublet --- R/scrublet_doubletDetection.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/scrublet_doubletDetection.R b/R/scrublet_doubletDetection.R index 4bafd7cdb..9d038a3f8 100644 --- a/R/scrublet_doubletDetection.R +++ b/R/scrublet_doubletDetection.R @@ -247,6 +247,7 @@ runScrublet <- function(inSCE, # if (inherits(error, "try-error")) { # warning("Scrublet did not complete successfully. Returning SCE without", # " making any changes. Error given by Scrublet: \n\n", error) + # return(inSCE) # } ## convert doublet call from TRUE/FALSE to Singlet/Doublet From 53d1154486e286705a26c8185c452eb3382210b1 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Thu, 12 Oct 2023 09:54:42 -0400 Subject: [PATCH 4/7] final fix to the scrublet try/catch block --- R/scrublet_doubletDetection.R | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/R/scrublet_doubletDetection.R b/R/scrublet_doubletDetection.R index 9d038a3f8..5a57aad3a 100644 --- a/R/scrublet_doubletDetection.R +++ b/R/scrublet_doubletDetection.R @@ -238,31 +238,30 @@ runScrublet <- function(inSCE, colData(inSCE)$scrublet_call <- NULL colData(inSCE) = cbind(colData(inSCE), output) + + ## convert doublet call from TRUE/FALSE to Singlet/Doublet + inSCE$scrublet_call <- as.factor(inSCE$scrublet_call) + + levels(inSCE$scrublet_call) <- list(Singlet = "FALSE", Doublet = "TRUE") + + reducedDim(inSCE,'scrublet_TSNE') <- tsneDims + reducedDim(inSCE,'scrublet_UMAP') <- umapDims + + colData(tempSCE) <- colData(inSCE) + metadata(tempSCE) <- metadata(inSCE) + reducedDims(tempSCE) <- reducedDims(inSCE) + + return(tempSCE) }, error=function(cond) { message(paste0(date(), " ... Scrublet did not complete successfully; Returning SCE without changes. Scrublet error:")) message(cond) return(inSCE) - }, + } # if (inherits(error, "try-error")) { # warning("Scrublet did not complete successfully. Returning SCE without", # " making any changes. Error given by Scrublet: \n\n", error) # return(inSCE) # } - - ## convert doublet call from TRUE/FALSE to Singlet/Doublet - inSCE$scrublet_call <- as.factor(inSCE$scrublet_call) - levels(inSCE$scrublet_call) <- list(Singlet = "FALSE", Doublet = "TRUE") - - reducedDim(inSCE,'scrublet_TSNE') <- tsneDims - reducedDim(inSCE,'scrublet_UMAP') <- umapDims - - colData(tempSCE) <- colData(inSCE) - metadata(tempSCE) <- metadata(inSCE) - reducedDims(tempSCE) <- reducedDims(inSCE) - - return(tempSCE) -) - - + ) } From dc7fdbf9092e352a500f5be7c0cad1883dad7133 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Fri, 13 Oct 2023 09:10:33 -0400 Subject: [PATCH 5/7] added a return statement to scrublet block --- R/scrublet_doubletDetection.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/scrublet_doubletDetection.R b/R/scrublet_doubletDetection.R index 5a57aad3a..b27b7146e 100644 --- a/R/scrublet_doubletDetection.R +++ b/R/scrublet_doubletDetection.R @@ -264,4 +264,5 @@ runScrublet <- function(inSCE, # return(inSCE) # } ) + return(result) } From 7d6bf3ce84d9da1914430a211a3deeeaa10ef932 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Fri, 13 Oct 2023 15:22:09 -0400 Subject: [PATCH 6/7] trying to fix scrublet --- R/scrublet_doubletDetection.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/R/scrublet_doubletDetection.R b/R/scrublet_doubletDetection.R index b27b7146e..5a2e6d9f9 100644 --- a/R/scrublet_doubletDetection.R +++ b/R/scrublet_doubletDetection.R @@ -154,6 +154,10 @@ runScrublet <- function(inSCE, ## Loop through each sample and run scrublet # try/catch block for when Scrublet fails (which can be often) + + # boolean flag variable for if the try/catch works + successful = FALSE + result <- tryCatch( { samples <- unique(sample) @@ -251,12 +255,21 @@ runScrublet <- function(inSCE, metadata(tempSCE) <- metadata(inSCE) reducedDims(tempSCE) <- reducedDims(inSCE) + successful = TRUE return(tempSCE) }, error=function(cond) { message(paste0(date(), " ... Scrublet did not complete successfully; Returning SCE without changes. Scrublet error:")) message(cond) return(inSCE) + }, + finally={ + if (isTRUE(successful)) { + return(tempSCE) + } + else { + return(inSCE) + } } # if (inherits(error, "try-error")) { # warning("Scrublet did not complete successfully. Returning SCE without", From f290489ea4e31d30e95556bbb0b8041d35d380d6 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Tue, 17 Oct 2023 11:00:28 -0400 Subject: [PATCH 7/7] fixed the dockerfile pointing to the wrong repo --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ad8e806d0..ef9b1025a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,7 @@ RUN R -e "BiocManager::install('scRNAseq')" RUN R -e "BiocManager::install('celda')" #RUN R -e "devtools::install_github('wleepang/shiny-directory-input')" RUN R -e "options(timeout=360000)" \ - && R -e "devtools::install_github('mingl1997/singleCellTK', ref = 'devel', force = TRUE, dependencies = TRUE)" + && R -e "devtools::install_github('compbiomed/singleCellTK', ref = 'devel', force = TRUE, dependencies = TRUE)" RUN R -e "install.packages('reticulate')" RUN R -e "Sys.setenv(RETICULATE_PYTHON = '/usr/bin/python3')"