diff --git a/R/twas_weights.R b/R/twas_weights.R index df0530a2..22ab4752 100644 --- a/R/twas_weights.R +++ b/R/twas_weights.R @@ -782,6 +782,10 @@ twas_weights_pipeline <- function(X, ) # Ensemble learning: learn optimal method combination via stacked regression + if (isTRUE(ensemble) && length(cv_weight_methods) <= 1) { + message("Ensemble model skipped: only ", length(cv_weight_methods), + " weight method provided (need >= 2 for ensemble learning).") + } if (isTRUE(ensemble) && length(cv_weight_methods) > 1) { if (!is.null(res$twas_cv_result$performance)) { # Extract R-squared for each method from CV performance table diff --git a/man/load_multitask_regional_data.Rd b/man/load_multitask_regional_data.Rd index 46134bef..585c2070 100644 --- a/man/load_multitask_regional_data.Rd +++ b/man/load_multitask_regional_data.Rd @@ -129,10 +129,10 @@ This function loads a mixture data sets for a specific region, including individ or summary statistics (sumstats, LD). Run \code{load_regional_univariate_data} and \code{load_rss_data} multiple times for different datasets } \section{Loading individual level data from multiple corhorts}{ - +NA } \section{Loading summary statistics from multiple corhorts or data set}{ - +NA } diff --git a/tests/testthat/test_ensemble_weights.R b/tests/testthat/test_ensemble_weights.R index ec641d72..2b1cf741 100644 --- a/tests/testthat/test_ensemble_weights.R +++ b/tests/testthat/test_ensemble_weights.R @@ -355,7 +355,8 @@ test_that("pipeline: ensemble=TRUE with only 1 method prints skip message", { ) ) - expect_true(any(grepl("at least 2 weight methods", msgs))) + # Should see the skip message + expect_true(any(grepl("Ensemble model skipped.*only 1 weight method provided", msgs))) # No ensemble result should be present expect_null(res$ensemble) @@ -385,7 +386,7 @@ test_that("pipeline: ensemble=TRUE skips when methods fail R^2 cutoff", { ) ) - expect_true(any(grepl("fewer than 2 methods passed the R.*cutoff", msgs))) + expect_true(any(grepl("Ensemble TWAS skipped", msgs))) expect_null(res$ensemble) expect_null(res$twas_weights$ensemble_weights) }) @@ -487,7 +488,7 @@ test_that("pipeline: ensemble_r2_threshold filters methods for ensemble", { ensemble_r2_threshold = 0.99 ) ) - expect_true(any(grepl("fewer than 2 methods passed", msgs_high))) + expect_true(any(grepl("Ensemble TWAS skipped", msgs_high))) expect_null(res_high$ensemble) })