R/compact.data.frame.R

compact.data.frame <-
function (full.frame) 
{
    full.frame <- full.frame[order(full.frame$cn), ]
    full.frame.mod <- do.call(
        rbind.data.frame,
        split(x = full.frame$posterior, f = full.frame$subject))
    rownames(full.frame.mod) <- levels(full.frame$subject)
    names(full.frame.mod) <- paste("P", c(1:(dim(full.frame.mod)[2])), 
        sep = "")
    full.frame.mod$cn <- apply(full.frame.mod, FUN = which.max, 
        MARGIN = 1)
    full.frame.mod$subject <- row.names(full.frame.mod)
    full.frame <- subset(full.frame[, c("subject", "batch", "signal", 
        "trait")], full.frame$cn == 1)
    full.frame <- merge(full.frame, full.frame.mod)
    return(full.frame)
}

Try the CNVtools package in your browser

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

CNVtools documentation built on April 28, 2020, 6:06 p.m.