This file contains hidden or 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
local({ | |
# modify as needed | |
modules = c("git", "git-lfs", "gcc") | |
capt = system2("./capture_module_environment.sh", modules, stdout = TRUE) | |
split = strsplit(capt, '=', fixed = TRUE) | |
out = lapply(split, function(v){ | |
do.call(Sys.setenv, stats::setNames(list(v[2]), v[1])) | |
}) | |
message("Added environment variables for ", paste(modules, collapse = ', ')) | |
}) |
This file contains hidden or 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
# function to fold data into k folds. this returns a list of matrices where | |
# the 1st column in each is the response and all other columns are predictors | |
fold <- function(y, X, k){ | |
n <- length(y) | |
lapply(0:(k-1)*n/k + 1, function(i){ | |
cbind(y, X)[seq(from=i, length.out=n/k),] | |
}) | |
} | |
# function to compute MSE for datasets with different numbers of folds |
This file contains hidden or 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
# EXAMPLE USAGE | |
# example of colsidecolors rowsidecolors (single column, single row) | |
mat <- matrix(1:100, byrow=T, nrow=10) | |
column_annotation <- sample(c("red", "blue", "green"), 10, replace=T) | |
column_annotation <- as.matrix(column_annotation) | |
colnames(column_annotation) <- c("Variable X") | |
row_annotation <- sample(c("red", "blue", "green"), 10, replace=T) | |
row_annotation <- as.matrix(t(row_annotation)) |