Skip to content

Instantly share code, notes, and snippets.

@wulingyun
Created June 19, 2016 10:42
Embed
What would you like to do?
Robust fold change
robust_fold_change <- function(case, control)
{
m <- dim(case)[2]
n <- dim(control)[2]
fc.raw <- matrix(nrow=dim(case)[1], ncol=m*n)
for (i in 1:m) {
for (j in 1:n) {
fc.raw[, (i-1)*m+j] <- case[,i] - control[,j]
}
}
min.abs <- function(x) x[which.min(abs(x))]
fc <- apply(fc.raw, 1, min.abs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment