Entering edit mode
4.2 years ago
lamia_203
▴
100
Hi, I'm running quality control on 2 thousand samples and normalisation using the dasen function (from watermelon) - however it takes hours for this to run. I have attached the code below and want to parallelise the function to normalize.quantiles each type of probe at the same time on different clusters. I'm using R to parallelise it and I'm not sure where to start. Any help will be much appreciated.
dasen <- function(mns, uns, onetwo, alfa=100, MvalueConv=TRUE, ...){
mnsc <- dfsfit(mns, onetwo, ...)
unsc <- dfsfit(uns, onetwo, roco=NULL)
mnsc[onetwo=='I' ,] <- normalize.quantiles(mnsc[onetwo=='I', ])
unsc[onetwo=='I' ,] <- normalize.quantiles(unsc[onetwo=='I', ])
mnsc[onetwo=='II',] <- normalize.quantiles(mnsc[onetwo=='II',])
unsc[onetwo=='II',] <- normalize.quantiles(unsc[onetwo=='II',])
indexNegU <- which(!is.numeric(unsc), arr.ind=TRUE)
indexNegM <- which(!is.numeric(mnsc), arr.ind=TRUE)
if(length(indexNegU)>0 || length(indexNegM)>0){
cat("\tWarning: NA values introduced. Value is replaced by 0.\n")
unsc[indexNegU] <- 0
mnsc[indexNegM] <- 0
}
#check and "correct" for negative values
indexNegU <- which(unsc < 0, arr.ind=TRUE)
indexNegM <- which(mnsc < 0, arr.ind=TRUE)
unsc[indexNegU] <- 0
mnsc[indexNegM] <- 0
if(MvalueConv){
return(log2((mnsc+alfa)/(unsc + alfa)))
} else{
return(mnsc/( mnsc + unsc + alfa ))
}
}