-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addMapping() to support future multi-model plotting #7
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -402,6 +402,39 @@ checkPlots <- function(plots) { | |
return(NULL) | ||
} | ||
|
||
checkMapping <- function(mapping) { | ||
checkList(mapping) | ||
|
||
# stop if mapping object has less than 2 elements | ||
if (length(mapping) > 0) stopifnot(length(mapping) > 1) | ||
else return(NULL) | ||
|
||
# check if list elements have the same size. If not, fill difference with NA. | ||
listMaxLength <- max(sapply(mapping, length)) | ||
mapping <- lapply(lapply(mapping, unlist), "length<-", listMaxLength) | ||
|
||
mappingdf <- as.data.frame(mapping) | ||
|
||
# NAs are accepted, but not if all values for a model are NA | ||
stopifnot(vapply(mappingdf, is.character, logical(1))) | ||
|
||
# check if any given model has at least one feature aligned with another model | ||
for (i in seq_along(mappingdf)) { | ||
tempModel <- mappingdf[!is.na(mappingdf[[i]]),] | ||
if (nrow(tempModel) > 1) { | ||
featAligned <- any(apply(!sapply(tempModel, is.na), 1, sum) > 1) | ||
} else { | ||
featAligned <- any(sum(!sapply(tempModel, is.na)) > 1) | ||
} | ||
|
||
if (isFALSE(featAligned)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just implemented in most recent commit. Thanks! |
||
stop(sprintf("Model \"%s\" does not present any feature mapping to another model.", colnames(mappingdf)[[i]])) | ||
} | ||
} | ||
|
||
return(NULL) | ||
} | ||
|
||
checkBarcodes <- function(barcodes) { | ||
checkList(barcodes) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out the error that only occurs with R 3.4.4. In R3, strings are always automatically coerced to factors by default (
stringsAsFactors=TRUE
). This default behavior was changed (for the better) in R4. Please update this line to explicitly keep the strings as charactor vectors when converting to a data frame.