I have a suggestion for a quick fix: using an environment to pass gvals. this way it is not repeated one time per sample. And the code change is only minimal.
In my test with 600 samples this used 140MB instead of 10.4GB on argList.
gvals_env <- new.env(parent=baseenv())
assign("gvals", gvals, envir = gvals_env)
argList <- apply(ft,1,function(x) {
## Add only those samples which actually have NA in them
if (!any(is.na(gvals[,as.numeric(x["id"])]))) {
## nothing to do.
list()
} else {
list(file=x["file"],id=as.numeric(x["id"]),
params=list(method="chrom",
gvals=gvals_env,
prof=prof,
dataCorrection=object@dataCorrection,
polarity=object@polarity,
rtcor=object@rt$corrected[[as.numeric(x["id"])]],
peakrange=peakrange))
}
})
fillPeaksChromPar would then need to do:
gvals <- params$gvals$gvals
instead of
gvals <- params$gvals
I don't know if there is a away around this. Is this used by any other functions? if not it seems like a fast fix though my knowledge of environments are very limited so I don't know if this has any unforeseen consequences.