### These are functions related to building an "Result Matrix" from a daCapo object. "buildRMatrix" <- function(dc,sumFun,...,whichLinkModels=1:length(dc$linkModels)) { ## We will create this object after the first call to FUN R <- NULL lmnames <- names(dc$linkModels[whichLinkModels]) ## Calculate total number of variables which will determine the ## total number of rows nrow <- do.call("sum",lapply(dc$linkModels[whichLinkModels],length)) irow <- 1 task <- character(0) EM <- character(0) observable <- character(0) for (alm in lmnames) { lmname <- splitlmn(alm) lmdat <- dc$linkModels[[alm]] task <- c(task,rep(lmname$task,length(lmdat))) EM <- c(EM,rep(lmname$EM,length(lmdat))) observable <- c(observable,getObservableVar(names(lmdat))) results <- t(sapply(lmdat,sumFun,...)) if (is.null(R)) { ## Shape results matrix based on first row R <- results } else { R <- rbind(R,results) } } result <- data.frame(task=I(task),EM=I(EM),observable=I(observable),R) result } ## Splits a link model name into two pieces, ## task name (accession number) and Evidence Model Name. "splitlmn" <- function(lmn) { sp1 <- regexpr("\\.[0-9]*_",lmn) sp1 <- sp1 + attr(sp1,"match.length") task <- substring(lmn,1,sp1-2) EM <- substring(lmn,sp1) list(task=task,EM=EM) } getObservableVar <- function(obsParName) { sub(".CondMultParam","", sub(".betaLogAlpha","", obsParName)) }