From b37e55baae87b006e0a12a01806c9afdbe1b85e5 Mon Sep 17 00:00:00 2001 From: Danielle Callan Date: Tue, 30 Apr 2024 15:44:23 -0400 Subject: [PATCH] improve some messaging --- R/method-differentialAbundance.R | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/R/method-differentialAbundance.R b/R/method-differentialAbundance.R index e942811..6dab4d9 100644 --- a/R/method-differentialAbundance.R +++ b/R/method-differentialAbundance.R @@ -178,7 +178,12 @@ function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verb covariateDataType <- class(data@sampleMetadata@data[[covariate]]) if (!covariateDataType %in% c("factor", "character")) { - stop("Argument 'groupA' must be a function when 'covariate' is not a factor or character") + stop("Argument 'groupA' must be a function when the variable specified by 'covariate' is not a factor or character") + } + covariateUniqueValues <- unique(data@sampleMetadata@data[[covariate]]) + if (!any(groupA %in% covariateUniqueValues)) { + # should warn the specified values arent in the covariate + warning("Specified values in 'groupA' are not in the variable specified by 'covariate'") } groupAFxn <- function(x) {x %in% groupA} @@ -215,6 +220,15 @@ function(data, covariate, groupA, groupB, method = c("Maaslin2", "DESeq2"), verb if (!covariateDataType %in% c("factor", "character")) { stop("Arguments 'groupA' and 'groupB' must be functions when 'covariate' is not a factor or character") } + covariateUniqueValues <- unique(data@sampleMetadata@data[[covariate]]) + if (!any(groupA %in% covariateUniqueValues)) { + # should warn the specified values arent in the covariate + warning("Specified values in 'groupA' are not in the variable specified by 'covariate'") + } + if (!any(groupB %in% covariateUniqueValues)) { + # should warn the specified values arent in the covariate + warning("Specified values in 'groupB' are not in the variable specified by 'covariate'") + } groupAFxn <- function(x) {x %in% groupA} groupBFxn <- function(x) {x %in% groupB}