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
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This repository contains a comprehensive testing framework for the [colocboost](
- `testthat/`: Directory containing test files
- `test_package.R`: Tests for basic package functionality
- `test_colocboost.R`: Tests for the main colocalization functions
- `test_inference.R`: Tests for the post inference functions
- `test_utils.R`: Tests for utility functions
- `test_model.R`: Tests for model fitting and prediction functions
- `.github/workflows/`: GitHub Actions workflow configurations
Expand Down
15 changes: 4 additions & 11 deletions tests/testthat/test_colocboost.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ test_data <- generate_test_data()

# Basic test for colocboost functionality with individual data
test_that("colocboost runs with individual data", {
skip_on_cran()

# Convert Y to list
Y_list <- list(test_data$Y[,1], test_data$Y[,2])
Expand Down Expand Up @@ -71,7 +70,6 @@ test_that("colocboost runs with individual data", {

# Test with summary statistics
test_that("colocboost runs with summary statistics", {
skip_on_cran()

# Generate summary statistics from the individual data
X <- test_data$X
Expand Down Expand Up @@ -120,7 +118,6 @@ test_that("colocboost runs with summary statistics", {

# Test focal outcome functionality
test_that("colocboost handles focal outcome correctly", {
skip_on_cran()

# Convert Y to list
Y_list <- list(test_data$Y[,1], test_data$Y[,2])
Expand All @@ -145,7 +142,6 @@ test_that("colocboost handles focal outcome correctly", {

# Test get_cos_summary functionality
test_that("get_cos_summary returns expected structure", {
skip_on_cran()

# Convert Y to list
Y_list <- list(test_data$Y[,1], test_data$Y[,2])
Expand Down Expand Up @@ -180,7 +176,6 @@ test_that("get_cos_summary returns expected structure", {

# Test colocboost_plot functionality (basic call should not error)
test_that("colocboost_plot runs without error", {
skip_on_cran()

# Convert Y to list
Y_list <- list(test_data$Y[,1], test_data$Y[,2])
Expand All @@ -199,9 +194,8 @@ test_that("colocboost_plot runs without error", {
expect_error(suppressWarnings(colocboost_plot(result)), NA)
})

# Test get_strong_colocalization functionality
test_that("get_strong_colocalization maintains colocboost structure", {
skip_on_cran()
# Test get_robust_colocalization functionality
test_that("get_robust_colocalization maintains colocboost structure", {

# Convert Y to list
Y_list <- list(test_data$Y[,1], test_data$Y[,2])
Expand All @@ -216,7 +210,7 @@ test_that("get_strong_colocalization maintains colocboost structure", {
)

# Run get_strong_colocalization
strong_result <- get_strong_colocalization(
strong_result <- get_robust_colocalization(
result,
cos_npc_cutoff = 0.2, # Lower threshold for testing
npc_outcome_cutoff = 0.1 # Lower threshold for testing
Expand All @@ -231,8 +225,7 @@ test_that("get_strong_colocalization maintains colocboost structure", {

# Test error handling with malformed input
test_that("colocboost handles missing/invalid inputs appropriately", {
skip_on_cran()


# Test missing both individual data and summary stats
expect_warning(colocboost(), "Error: No individual data")

Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test_inference.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ test_that("get_cos_summary handles different parameters", {
})

# Test for get_strong_colocalization
test_that("get_strong_colocalization filters results correctly", {
test_that("get_robust_colocalization filters results correctly", {

# Generate a test colocboost results
cb_res <- generate_test_result()

# Basic call
expect_error(get_strong_colocalization(cb_res), NA)
expect_error(get_robust_colocalization(cb_res), NA)

# With stricter thresholds
expect_error(get_strong_colocalization(cb_res, cos_npc_cutoff = 0.8), NA)
expect_error(get_robust_colocalization(cb_res, cos_npc_cutoff = 0.8), NA)

# With p-value threshold
expect_error(get_strong_colocalization(cb_res, pvalue_cutoff = 0.05), NA)
expect_error(get_robust_colocalization(cb_res, pvalue_cutoff = 0.05), NA)
})