tests/testthat/test_volcano_owas.R

# Test that owas works with a single var ----------------
test_that("volcano_owas works with a single var", {
  # Load Example Data
  data("example_data")
  
  # Get names of omics
  colnames_omic_fts <- colnames(example_data)[
    grep("feature_",
         colnames(example_data))][1:5]
  
  # Run function with continuous exposure as the variable of interest
  owas_out <- owas(df = example_data,
                        var = "exposure1",
                        omics = colnames_omic_fts,
                        covars = c("age", "sex"),
                        var_exposure_or_outcome = "exposure",
                        family = "gaussian")
  
  vp <- volcano_owas(owas_out)
  
  testthat::expect_equal(object = vp$data$threshold, 
                         expected = c("Significant", rep("Non-significant", 4)))
  
})

# Test that owas works with multiple vars ----------------
test_that("volcano_owas works with multiple vars", {
  
  # Load Example Data
  data("example_data")
  
  # Get names of omics
  colnames_omic_fts <- colnames(example_data)[
    grep("feature_",
         colnames(example_data))][1:5]
  
  # Run function with multiple exposures as the variable of interest
  expnms <- c("exposure1", "exposure2", "exposure3")
  
  # Continuous exposure, covars
  owas_multiple_vars <- owas(
    df = example_data,
    var = expnms,
    omics = colnames_omic_fts,
    covars = c("age", "sex"),
    var_exposure_or_outcome = "exposure",
    family = "gaussian")
  
  # Volcano plot
  vp <- volcano_owas(owas_multiple_vars, 
                     highlight_adj_p = FALSE)
  
  testthat::expect_equal(object = vp$data$threshold, 
                         expected = c("Significant", 
                                      rep("Non-significant", 14)))
 
})

Try the epiomics package in your browser

Any scripts or data that you put into this service are public.

epiomics documentation built on April 4, 2025, 1:42 a.m.