From 9ce4a426f96bb7f926a84b6ecb771f6dff5e5946 Mon Sep 17 00:00:00 2001 From: Louise Huuki Date: Tue, 11 Apr 2023 11:59:08 -0400 Subject: [PATCH] Add a more detailed error message for bad colData category (cat) --- R/plot_gene_express.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/plot_gene_express.R b/R/plot_gene_express.R index 193dc5f..ec6a62f 100644 --- a/R/plot_gene_express.R +++ b/R/plot_gene_express.R @@ -41,8 +41,13 @@ plot_gene_express <- function(sce, plot_points = FALSE, ncol = 2) { stopifnot(any(genes %in% rownames(sce))) - stopifnot(cat %in% colnames(colData(sce))) - stopifnot(assay_name %in% SummarizedExperiment::assayNames(sce)) + + if(!cat %in% colnames(colData(sce))){ + message("ERROR '", cat, "' is not a column name in colData(sce), check that `cat` matches this sce") + stop() + } + + stopifnot(assay_name %in% SummarizedExperiment::assayNames(sce)) value <- NULL