R/AnnotatedGWAS-class.r

# Define ------------------------------------------------------------------

#' AnnotatedGWAS-class
#' 
#' @aliases AnnotatedGWAS
#' @include GWAS-class.r

setClass("AnnotatedGWAS",  
         representation = representation("GWAS", featureIndex = "SimpleList"))


# Validate ----------------------------------------------------------------

.validAnnotatedGWAS <- function(object) {
  
  # GWAS object is valid
  stopifnot(.validGWAS(object))
  
  # All indexed features are present
  index.features <- unlist(object@featureIndex)
  if (!all(index.features %in% names(mcols(object)))) {
    stop("GWAS object is missing features present in the featureIndex.\n",
         call. = FALSE)
  }
  
  # Features are logical
  class.features <- sapply(mcols(object)[, index.features], class)
  if (!all(class.features == "logical")) {
    stop("Annotated features must be logical.\n", call. = FALSE)
  }
  
  return(TRUE)
}

setValidity("AnnotatedGWAS", .validAnnotatedGWAS)
aaronwolen/bingd documentation built on May 10, 2019, 4:04 a.m.