Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions R/twas_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions man/load_multitask_regional_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions tests/testthat/test_ensemble_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
})

Expand Down