Skip to content

Instantly share code, notes, and snippets.

@wulingyun
Created June 19, 2016 10:42
Show Gist options
  • Save wulingyun/0c5ae1ad55bdf1394d409bfe5a2cc610 to your computer and use it in GitHub Desktop.
Save wulingyun/0c5ae1ad55bdf1394d409bfe5a2cc610 to your computer and use it in GitHub Desktop.
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