Created
June 19, 2016 10:42
-
-
Save wulingyun/0c5ae1ad55bdf1394d409bfe5a2cc610 to your computer and use it in GitHub Desktop.
Robust fold change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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