From 17df081f4c87f6b2be47a8df92f52bbd1d123d92 Mon Sep 17 00:00:00 2001 From: Nathan Skene <33265555+NathanSkene@users.noreply.github.com> Date: Fri, 30 Aug 2019 17:02:29 +0100 Subject: [PATCH] Added a check to ensure that resolution is defined Just had an error occur and this should stop it happening again. I had called: a.pbmc <- quantileAlignSNF(a.pbmc, resolution = res, small.clust.thresh = 20) However, I had forgotten to set 'res'. Because res does not get used until late in the function, it was 20 minutes or so until the function crashed. The lines I've added just check to ensure that res has been properly defined. --- R/liger.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/liger.R b/R/liger.R index d67fec2f..f73c3118 100644 --- a/R/liger.R +++ b/R/liger.R @@ -1615,6 +1615,9 @@ quantileAlignSNF.list <- function( set.seed(seed = NULL) id.number <- sample(x = 1000000:9999999, size = 1) } + is.defined <- function(sym) class(try(sym, TRUE))!='try-error' + if(!is.defined(resolution)){stop("'resolution' is not properly defined")} + if(!is.finite(resolution)){stop("'resolution' is not properly defined")} idents <- snf$idents Hs <- object idents.rest <- SLMCluster( @@ -4467,4 +4470,4 @@ convertOldLiger = function(object, override.raw = F) { # class has slots that this particular object does not print(paste0('New slots not filled: ', setdiff(slots_new[slots_new != "cell.data"], slots))) return(new.liger) -} \ No newline at end of file +}