Last active
August 29, 2015 14:10
-
-
Save Jfortin1/f3e5c3a0e029fcb4b539 to your computer and use it in GitHub Desktop.
Beta to M
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
BetaToM <- function(beta){ | |
matrix <- log2(beta) - log2(1-beta) | |
impute.matrix(matrix) | |
} | |
MToBeta <- function(mmatrix){ | |
matrix <- 2^mmatrix/(2^mmatrix+1) | |
impute.matrix(matrix) | |
} | |
impute.matrix <- function (matrix) { | |
missing <- which(is.na(matrix) | !is.finite(matrix), arr.ind=TRUE) | |
if (nrow(missing)!=0){ | |
for (j in 1:nrow(missing)){ | |
mean <- mean(matrix[missing[j,1],][is.finite(matrix[missing[j,1],])], na.rm=TRUE) | |
matrix[missing[j,1],missing[j,2]] <- mean | |
} | |
} | |
matrix | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment