#' @title Test ExpressionSet Standard
#' @description This function tests whether a given ExpressionSet follows the pre-defined PhyloExpressionSet or DivergenceExpressionSet standard.
#' @param ExpressionSet a standard PhyloExpressionSet or DivergenceExpressionSet that shall be tested for format validity.
#' @author Hajk-Georg Drost
#' @examples
#'
#' # read example PhyloExpressionSet
#' data(PhyloExpressionSetExample)
#'
#' is.ExpressionSet(PhyloExpressionSetExample)
#'
#' @export
is.ExpressionSet <- function(ExpressionSet){
ExpressionSet <- as.data.frame(ExpressionSet)
ncols <- dim(ExpressionSet)[2]
d.f_bool <- is.data.frame(ExpressionSet)
if (!d.f_bool)
stop("ExpressionSet is not a data.frame.")
age.vector_bool <- is.numeric(ExpressionSet[ , 1])
if (!age.vector_bool)
stop("The first column of the ExpressionSet needs to store numeric values.")
gene.vector_bool <- ifelse(is.factor(ExpressionSet[ , 2]),is.character(levels(ExpressionSet[ , 2])),is.character(ExpressionSet[ , 2]))
if (!gene.vector_bool)
stop("The second column of the ExpressionSet needs to store character values (e.g. gene ids).")
expression.matrix_bool <- all(sapply(as.matrix(ExpressionSet[ , 3:ncols]), is.numeric))
if (!expression.matrix_bool)
stop("Columns 3 - ",ncol(ExpressionSet), " need to store numeric values (e.g. expression levels).")
any.NA.values_bool <- !any(is.na(ExpressionSet))
if (!any.NA.values_bool)
stop("The ExpressionSet cannot contain 'NA' values. Please use na.omit() to remove 'NA' values from the input ExpressionSet.")
if(all(c(d.f_bool,age.vector_bool,gene.vector_bool,expression.matrix_bool,any.NA.values_bool))){
return(TRUE)
}
else{
stop("The present input object does not fulfill the ExpressionSet standard.")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.