Skip to content

Commit

Permalink
improve some messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
d-callan committed Apr 30, 2024
1 parent 61e3b92 commit b37e55b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion R/method-differentialAbundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit b37e55b

Please sign in to comment.