R/dataFrame2object.R

Defines functions dataFrame2object .buildWarn

Documented in dataFrame2object

.buildWarn <- function(field) {
    msg <- paste("Data frame does not have column \"", field, "\".", sep = "")
    return(msg)
}

dataFrame2object <- function(dataFrame){
    N <- names(dataFrame)
    requiredFields <- c("Chr", "Pos", "Test", "Norm")
    for (i in 1:length(requiredFields)){ 
        if(! requiredFields[i] %in% N){
            thisM <- .buildWarn(requiredFields)
            stop(thisM)
        }
    }
    if ("GC" %in% N){
        InD <- new("InData", Chr = as.character(dataFrame$Chr), Pos = dataFrame$Pos, 
            Test = dataFrame$Test, Norm = dataFrame$Norm, GC = dataFrame$GC)
        
    } else {
        InD <- new("InData", Chr = as.character(dataFrame$Chr), Pos = dataFrame$Pos, 
            Test = dataFrame$Test, Norm = dataFrame$Norm)
    }

    CN <- new("CNAnorm", InData = InD)
    return(CN)
}

Try the CNAnorm package in your browser

Any scripts or data that you put into this service are public.

CNAnorm documentation built on Nov. 8, 2020, 5:29 p.m.