The noise is comming from the subset.mask, which is created above in a loop with the number of permutations. for (r in 1:nperm) { #L90 .... subset.mask[, r] <- as.numeric(c(subset.class1, subset.class2)) # L107 So by multiplying the random selection of subsets by the expression we get the "noise". Later on line 251 we get the ratio of noise/signal by dividing the signal from the contrast and the signal by the noise. Those transformation on the middle seem to come from normalizing the signal in order to be able to compare the resampling, but I don't fully understand why they do this. Also note that the R scripts are outdated and no longer maintained, so they can contain errors.