diff --git a/R/AllClasses.R b/R/AllClasses.R index 1b88351..b448310 100644 --- a/R/AllClasses.R +++ b/R/AllClasses.R @@ -365,6 +365,16 @@ setGeneric("gatingTemplate", function(x, ...) standardGeneric("gatingTemplate")) #' @rdname gatingTemplate-class setMethod("gatingTemplate", signature(x = "character"), function(x, name = "default", strict = TRUE, strip_extra_quotes=FALSE,...) { dt <- fread(x, ...) + # empty gatingTemplate error + if(nrow(dt) == 0) { + stop( + paste0( + "Cannot create gatingTemplate from ", + x, + " as it contains no gating entries." + ) + ) + } dt <- .preprocess_csv(dt, strict = strict) #append the isMultiPops column based on pop name @@ -387,6 +397,14 @@ setMethod( strict = TRUE, strip_extra_quotes = FALSE, ...) { + if(nrow(x) == 0) { + stop( + paste0( + "Cannot create gatingTemplate from this data.table as it ", + "contains no gating entries." + ) + ) + } dt <- .preprocess_csv(x, strict = strict) #append the isMultiPops column based on pop name dt[, isMultiPops := FALSE]