Displaying 1 result from an estimated 1 matches for "ttfold".
Did you mean:
stfold
2006 Sep 26
2
Vectorise a for loop?
...h is a log2 value.
The calculation is different depending on whether the M value is
negative or positive. That is if the gene is down regulated the
reciprocal value has to be used to calculate a fold value.
Here is my clunky, not vectorised code :
# Function to add a fold column to the toptable
ttfold<-function(tt) {
fold<-NULL
for (i in 1:length(tt$M)) {
if (tt$M[i] < 0 ) {
fold[i]<-1/(2^tt$M[i])
} else {
fold[i]<-2^tt$M[i]
}
}
tt<-cbind(tt, fold)
}
# Add fold column to top tables
topa1<-ttfold(topa1)
Regards
J
---
John Seers...