The t-test between two samples/biological conditions is still one of the most common statistical tests used for the detection of differentially expressed genes in microarray studies, even if a lot of specialized tests have been developed during the past 10 years. However, something that many people don’t do, either because it is not covered in several microarray data analysis tutorials, or because it rarely affects the results, but still is the correct way to do, is the F-test to check for the equality of variances within samples to be compared, prior to the t-test. This is because the formula for the t-statistic changes if the variances are not assumed equal (Welch’s t-test). Thus, if someone wants to be 100% correct when applying this particular test, he/she has to perform an F-test prior to the t-test, and according to the result of the F-test, choose between the traditional t-test or the Welch’s t-test. Here is a way to do it easily in R:

# Very naive sample data, consisting of two conditions with 3 replicates each my.data <- matrix(runif(30000),nrow=5000,ncol=6) # Do the combined t-test and F-test var.sig.level <- 0.05 p.values <- apply(my.data,1,function(x,s) { if (var.test(x[1:3],x[4:6])$p.value < s) return(t.test(x[1:2],x[3:6])$p.value) else return(t.test(x[1:2],x[3:6],var.equal=TRUE)$p.value) },var.sig.level ) adj.p.values <- p.adjust(p.values,"BH")