Skip to content

Commit

Permalink
reverting memory allocation changes because the error was in the inpu…
Browse files Browse the repository at this point in the history
…t genotype data, i.e. duplicated samples names resulting in huge genotype matrices
  • Loading branch information
jeffersonfparil committed Jun 25, 2024
1 parent 79ba591 commit b04648f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
11 changes: 1 addition & 10 deletions R/cross_validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,6 @@ fn_cv_1 = function(i, list_merged, df_params, mat_idx_shuffle, vec_set_partition
#' using the sommer R package (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4894563/).
#' https://link.springer.com/protocol/10.1007/978-1-62703-447-0_13
#' @param max_mem_Gb maximum memory in gigabytes available for computation (Default=15)
#' @param bool_across_pop for across population cross-validation? This will use a data size multiplier of 40 if true,
#' otherwise a multiplier of 10 will be used for within population cross-validation (Default=TRUE)
#' @param verbose show cross-validation parameter preparation messages? (Default=FALSE)
#' @returns
#' - Ok:
Expand Down Expand Up @@ -356,7 +354,7 @@ fn_cv_1 = function(i, list_merged, df_params, mat_idx_shuffle, vec_set_partition
#' @export
fn_cross_validation_preparation = function(list_merged, cv_type=1, n_folds=10, n_reps=10,
vec_models_to_test=c("ridge","lasso","elastic_net","Bayes_A","Bayes_B","Bayes_C","gBLUP"),
max_mem_Gb=15, bool_across_pop=TRUE, verbose=FALSE)
max_mem_Gb=15, verbose=FALSE)
{
###################################################
### TEST
Expand Down Expand Up @@ -420,18 +418,12 @@ fn_cross_validation_preparation = function(list_merged, cv_type=1, n_folds=10, n
df_params = df_params[order(df_params$rep), ]
df_params = df_params[order(df_params$fold), ]
### Estimate the maximum number of threads which can be used without running out of memory
if (bool_across_pop) {
memory_multiplier = 40
} else {
memory_multiplier = 10
}
list_mem = fn_estimate_memory_footprint(
X=list_merged,
n_models=length(vec_models_to_test),
n_folds=n_folds,
n_reps=n_reps,
memory_requested_Gb=max_mem_Gb,
memory_multiplier=memory_multiplier,
verbose=verbose)
} else if (cv_type == 2) {
############################################
Expand Down Expand Up @@ -701,7 +693,6 @@ fn_cross_validation_within_population = function(list_merged, n_folds=10, n_reps
n_reps=n_reps,
vec_models_to_test=vec_models_to_test,
max_mem_Gb=max_mem_Gb,
bool_across_pop=FALSE,
verbose=verbose)
if (methods::is(list_cv_params, "gpError")) {
error = chain(list_cv_params, methods::new("gpError",
Expand Down
1 change: 0 additions & 1 deletion R/io.R
Original file line number Diff line number Diff line change
Expand Up @@ -2376,7 +2376,6 @@ fn_estimate_memory_footprint = function(X, n_models=7, n_folds=10, n_reps=10,
size_total = size_X * n_models * n_folds * n_reps * memory_multiplier
n_threads = floor(as.numeric(gsub(" bytes", "", size_RAM / (size_X * memory_multiplier))))
if (verbose) {
print(paste0("Dimensions of G: = ", paste(dim(X$G), collapse=" x ")))
print(paste0("Size of X: = ", format(size_X, units="b")))
print(paste0("n_models = ", n_models, "; n_folds = ", n_folds, "; n_reps = ", n_reps))
print(paste0("Total memory requested = ",
Expand Down

0 comments on commit b04648f

Please sign in to comment.