So let's say I did an experiment comparing mutated samples vs non mutated where I have an unequal number of samples (100s (non mutated) vs 5-10 (mutated)). I think the groups might have different variances so I could do a welch t-test to address that issue. But a colleague thinks doing permutation testing and drawing sample size equal to the smallest group would be better. While I think in some cases permutations are great but in this case I'm not so sure. Also looking at his R code I'm not sure it's correct.. shouldn't you be sampling from each group independently rather than pooling them
# groupA is mutated samples and groupB is non mutated samples
groupA <- which(samples[,i] == "mutated")
groupB <- which(samples[,i] == "non_mutated")
sample.size <- length(groupA)
groupAB <- c(groupA,groupB)
for(j in seq(1:length(colnames(results))))
{
actual.med.diff <- median(na.omit(results[groupA,j])) - median(na.omit(results[groupB,j]))
for(k in 1:1000)
{
index <- sample(1:length(groupAB), size=sample.size, replace=FALSE)
perm.groupA <- groupAB[index]
perm.groupB <- groupAB[-index]
perm.med.diffs[k] <- median(na.omit(results[perm.groupA,j])) median(na.omit(results[perm.groupB,j]))
}
median.perm.pval <- length(which(perm.med.diffs <= actual.med.diff)) / 1000
}