Skip to content

Commit

Permalink
Merge 74391f2 into 5a3df3d
Browse files Browse the repository at this point in the history
  • Loading branch information
mingl1997 authored Oct 17, 2023
2 parents 5a3df3d + 74391f2 commit b505c69
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down
50 changes: 33 additions & 17 deletions R/scrublet_doubletDetection.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,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)
Expand Down Expand Up @@ -239,29 +243,41 @@ 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)

successful = TRUE
return(tempSCE)
},
error=function(cond) {
p <- paste0(date(), " ... Scrublet did not complete successfully; Returning SCE without changes. Scrublet error:")
message(p)
message(cond)
}
)

# if (inherits(error, "try-error")) {
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",
# " 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)
)
return(result)
}

0 comments on commit b505c69

Please sign in to comment.