Check a set of keys and their values

check_values(
  x,
  annotations,
  allowlist_keys = NULL,
  allowlist_values = NULL,
  success_msg = "All annotation values are valid",
  fail_msg = "Some annotation values are invalid",
  return_valid = FALSE,
  annots_link = "https://shinypro.synapse.org/users/nsanati/annotationUI/",
  syn
)

Arguments

x

A data frame of annotation data

annotations

A data frame of annotations to check against

allowlist_keys

A character vector of annotation keys to allowlist. If provided, all values for the given keys will be treated as valid.

allowlist_values

A named list of keys (as the names) and values (as vectors) to allowlist

success_msg

Message indicating the check succeeded.

fail_msg

Message indicating the check failed.

return_valid

Should the function return valid values? Defaults to FALSE (i.e. the function will return invalid values).

annots_link

Link to a definition of the annotations being used in the project

syn

Synapse client object

Value

If return_valid = FALSE: a condition object indicating whether all annotation values are valid. Invalid annotation values are included as data within the object: a named list where each element corresponds to a key that contains invalid values, and the contents of each element is a vector of invalid values. If return_valid = TRUE: a named list of the valid annotation keys and values.

Examples

annots <- data.frame( key = c("fileFormat", "fileFormat"), value = c("txt", "csv"), columnType = c("STRING", "STRING"), stringsAsFactors = FALSE ) dat <- data.frame( fileFormat = c("wrong", "txt", "csv", "wrong again"), stringsAsFactors = FALSE ) check_values(dat, annots)
#> <error/check_fail> #> Some annotation values are invalid
## Comma-separated and json-style strings for keys with enumerated values ## are separated and checked individually dat <- data.frame( fileFormat = c("wrong, txt, csv", "[\"wrong again\",\"csv\"]"), stringsAsFactors = FALSE ) check_values(dat, annots)
#> <error/check_fail> #> Some annotation values are invalid