R/xyCal.R

Defines functions xyCal

Documented in xyCal

#' Specify the column numbers for given conditions
#' This function returns a list of vectors specifing the columns of the conditions
#' @param cl Vector defining per-column conditions; assumes 0 is the "base condition"
#' @author Alexander Kheirallah ([email protected]). Inspired by functions in RankProd package.  
#' @export
xyCal <- function(cl) {
  lev=unique(cl)
  uni.cl=length(lev)
  if (uni.cl < 2 | uni.cl > 2)
    stop("There is something wrong with the classlabels. Provide two class labels only! Thanks!")
  if(uni.cl==2) {
    cat("Analysis for two-classes","\n","\n")
    if(min(lev)!=0 | max(lev)!=1){
      cat("Warning: Expected classlabels are 0 and 1. cl will thus be set to 0 and 1.","\n","\n")
      cl[which(cl==min(lev))]<-0 ##small one is assigned to 0
      cl[which(cl==max(lev))]<-1 ##big one is assigned to 0
    }
    x<-which(cl==0) ##sample 1
    y<-which(cl==1) ##sample 2
  }
  structure(list(x=x,y=y))
}
msxakk89/dat documentation built on April 3, 2020, 5:39 p.m.