The old simulation method is slow due to single_network_failure()
inpairs$age = rexp( length(inpairs[,1]), rate=lambda ) #exponential ages for pairs
inpairs$age = ifelse(inpairs$active > (1-p), inpairs$age, NA ) #if not active, intxn is excluded.
ModuleTb = data.frame(runningORFs) #buffer for module ages
#loop every essential genes to identify the module age
for (i in 1:length(runningORFs)) {
myORF = runningORFs[i]
pos1 = grep(myORF, inpairs$id1)
pos2 = grep(myORF, inpairs$id2) #id1,2 to ORF1,2 is a really bad choice.
if( length( c(pos1,pos2))>=1 ) {
ModuleTb$age.m[i] = max( inpairs$age[c(pos1,pos2)], na.rm=T ) #maximal intxn age -> module age
} else {
ModuleTb$age.m[i] = NA;
}
}
Basically, there were too much ifelse, matching, grep(). The grep() probably is the most expensive step.
I propose a new algorithm to calculate by Degree for each essential gene, thereby eliminating the grep() process.
No comments:
Post a Comment