0.1 Load Data and Libraries

# Load Libraries
library(tidyverse)
library(tidyexposomics)

We will start off with our example dataset pulled from the ISGlobal Exposome Data Challenge 2021 (Maitre et al., 2022).

# Load example data
data("tidyexposomics_example")

# Create exposomic set object
expom <- create_exposomicset(
    codebook = tidyexposomics_example$annotated_cb,
    exposure = tidyexposomics_example$meta,
    omics = list(
        "Gene Expression" = tidyexposomics_example$exp_filt,
        "Methylation" = tidyexposomics_example$methyl_filt
    ),
    row_data = list(
        "Gene Expression" = tidyexposomics_example$exp_fdata,
        "Methylation" = tidyexposomics_example$methyl_fdata
    )
)
## Ensuring all omics datasets are matrices with column names.
## Creating SummarizedExperiment objects.
## Creating MultiAssayExperiment object.
## MultiAssayExperiment created successfully.

We will focus on a few exposure variable categories.

# Grab exposure variables
exp_vars <- tidyexposomics_example$annotated_cb |>
    filter(category %in% c(
        "aerosol",
        "main group molecular entity",
        "polyatomic entity"
    )) |>
    pull(variable) |>
    as.character()

1 Quality Control


As in the main vignette, we will impute exposure data using missforest.

# Impute missing values
expom <- run_impute_missing(
    exposomicset = expom,
    exposure_impute_method = "missforest",
    exposure_cols = exp_vars
)
## Imputing exposure data using method: missforest

And we will transform our exposure data to ensure it is more normally distributed using the boxcox_best method.

# Transform variables
expom <- transform_exposure(
    exposomicset = expom,
    transform_method = "boxcox_best",
    exposure_cols = exp_vars
)
## Applying the boxcox_best transformation.

1.1 Exposome Scores


We can calculate exposome scores, which are a summary measure of exposure. The run_exposome_score function is used to calculate the exposome score. The exposure_cols argument is used to set the columns to use for the exposome score. The score_type argument is used to set the type of score to calculate. Here we could use:

  • median: Calculates the median of the exposure variables.

  • mean: Calculates the mean of the exposure variables.

  • sum: Calculates the sum of the exposure variables.

  • pca: Calculates the first principal component of the exposure variables.

  • irt: Uses Item Response Theory to calculate the exposome score.

  • quantile: Calculates the quantile of the exposure variables.

  • var: Calculates the variance of the exposure variables.

The score_column_name argument is used to set the name of the column to store the exposome score in. Here we will define a score for aerosols using a variety of different methods and demonstrate their use in association with asthma status.

# determine which aerosol variables to use
aerosols <- c("h_pm25_ratio_preg_None", "h_pm10_ratio_preg_None")

# Create exposome scores
expom <- expom |>
    run_exposome_score(
        exposure_cols = aerosols,
        score_type = "median",
        score_column_name = "exposome_median_score"
    ) |>
    run_exposome_score(
        exposure_cols = aerosols,
        score_type = "pca",
        score_column_name = "exposome_pca_score"
    ) |>
    run_exposome_score(
        exposure_cols = aerosols,
        score_type = "quantile",
        score_column_name = "exposome_quantile_score"
    ) |>
    run_exposome_score(
        exposure_cols = aerosols,
        score_type = "var",
        score_column_name = "exposome_var_score"
    )
## Extracting exposure data...
## Extracting exposure data...
## Extracting exposure data...
## Extracting exposure data...
## Calculating median exposure scores...
## Calculating PCA exposure scores...
## Calculating quantile exposure scores...
## Calculating variance exposure scores...

We can then associate these exposome scores with asthma status using the run_association function, just like we did before. However, this time we specify our feature_set to be the exposome scores we just calculated.

# Associate exposome scores with outcome
expom <- run_association(
    exposomicset = expom,
    outcome = "hs_asthma",
    source = "exposures",
    feature_set = c(
        "exposome_median_score",
        "exposome_pca_score",
        "exposome_quantile_score",
        "exposome_var_score"
    ),
    action = "add",
    family = "binomial"
)
## Running GLMs.
# Plot the association forest plot
plot_association(
    exposomicset = expom,
    source = "exposures",
    terms = c(
        "exposome_median_score",
        "exposome_pca_score",
        "exposome_quantile_score",
        "exposome_var_score"
    ),
    filter_col = "p.value",
    filter_thresh = 0.05,
    r2_col = "r2"
)
Associations of aerosol exposome scores with asthma status. The variance-based score has the strongest association with asthma status.

Figure 1: Associations of aerosol exposome scores with asthma status
The variance-based score has the strongest association with asthma status.

1.2 Session Info

See Session Info


sessionInfo()
## R version 4.6.1 (2026-06-24)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.4 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.24-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] tidyexposomics_1.1.2        MultiAssayExperiment_1.39.0
##  [3] SummarizedExperiment_1.43.0 Biobase_2.73.2             
##  [5] GenomicRanges_1.65.1        Seqinfo_1.3.0              
##  [7] IRanges_2.47.2              S4Vectors_0.51.6           
##  [9] BiocGenerics_0.59.11        generics_0.1.4             
## [11] MatrixGenerics_1.25.0       matrixStats_1.5.0          
## [13] lubridate_1.9.5             forcats_1.0.1              
## [15] stringr_1.6.0               dplyr_1.2.1                
## [17] purrr_1.2.2                 readr_2.2.0                
## [19] tidyr_1.3.2                 tibble_3.3.1               
## [21] ggplot2_4.0.3               tidyverse_2.0.0            
## [23] BiocStyle_2.41.0           
## 
## loaded via a namespace (and not attached):
##   [1] splines_4.6.1        later_1.4.8          filelock_1.0.3      
##   [4] hardhat_1.4.3        pROC_1.19.0.1        rpart_4.1.27        
##   [7] factoextra_2.2.0     lifecycle_1.0.5      httr2_1.3.0         
##  [10] Rdpack_2.6.6         rstatix_1.1.0        globals_0.19.1      
##  [13] lattice_0.22-9       MASS_7.3-66          backports_1.5.1     
##  [16] magrittr_2.0.5       limma_3.69.2         Hmisc_5.2-6         
##  [19] sass_0.4.10          rmarkdown_2.31       jquerylib_0.1.4     
##  [22] yaml_2.3.12          httpuv_1.6.17        otel_0.2.0          
##  [25] doRNG_1.8.6.3        DBI_1.3.0            RColorBrewer_1.1-3  
##  [28] abind_1.4-8          itertools_0.1-3      nnet_7.3-21         
##  [31] ipred_0.9-15         lava_1.9.2           ggrepel_0.9.8       
##  [34] listenv_1.0.0        fenr_1.11.2          ellipse_0.5.0       
##  [37] missForest_1.6.1     RSpectra_0.16-2      parallelly_1.48.0   
##  [40] codetools_0.2-20     DelayedArray_0.39.4  DT_0.34.0           
##  [43] tidyselect_1.2.1     farver_2.1.2         BiocFileCache_3.3.0 
##  [46] base64enc_0.1-6      jsonlite_2.0.0       caret_7.0-1         
##  [49] Formula_1.2-6        survival_3.8-9       iterators_1.0.14    
##  [52] foreach_1.5.2        tools_4.6.1          Rcpp_1.1.2          
##  [55] glue_1.8.1           rARPACK_0.11-0       BiocBaseUtils_1.15.1
##  [58] prodlim_2026.03.11   gridExtra_2.3.1      SparseArray_1.13.2  
##  [61] ranger_0.18.0        xfun_0.60            mixOmics_6.37.0     
##  [64] withr_3.0.3          BiocManager_1.30.27  fastmap_1.2.0       
##  [67] digest_0.6.39        timechange_0.4.0     R6_2.6.1            
##  [70] mime_0.13            RGCCA_3.0.3          visdat_0.6.0        
##  [73] colorspace_2.1-3     dichromat_2.0-1      RSQLite_3.53.3      
##  [76] utf8_1.2.6           ggsci_5.2.0          data.table_1.18.4   
##  [79] recipes_1.3.3        corpcor_1.6.10       class_7.3-24        
##  [82] httr_1.4.8           htmlwidgets_1.6.4    S4Arrays_1.13.0     
##  [85] ModelMetrics_1.2.2.2 pkgconfig_2.0.3      gtable_0.3.6        
##  [88] timeDate_4052.112    blob_1.3.0           S7_0.2.2            
##  [91] XVector_0.53.0       htmltools_0.5.9      carData_3.0-6       
##  [94] bookdown_0.47        naniar_1.1.0         scales_1.4.0        
##  [97] gower_1.0.2          knitr_1.51           rstudioapi_0.19.0   
## [100] tzdb_0.5.0           reshape2_1.4.5       checkmate_2.3.4     
## [103] nlme_3.1-170         curl_7.1.0           cachem_1.1.0        
## [106] parallel_4.6.1       foreign_0.8-91       pillar_1.11.1       
## [109] grid_4.6.1           vctrs_0.7.3          randomForest_4.7-1.2
## [112] promises_1.5.0       ggpubr_1.0.0         car_3.1-5           
## [115] dbplyr_2.6.0         xtable_1.8-8         Deriv_4.3.0         
## [118] cluster_2.1.8.3      htmlTable_2.5.0      evaluate_1.0.5      
## [121] magick_2.9.1         tinytex_0.60         cli_3.6.6           
## [124] compiler_4.6.1       rngtools_1.5.2       rlang_1.3.0         
## [127] crayon_1.5.3         future.apply_1.20.2  ggsignif_0.6.4      
## [130] labeling_0.4.3       tidybulk_2.3.0       plyr_1.8.9          
## [133] stringi_1.8.9        BiocParallel_1.47.0  assertthat_0.2.1    
## [136] Matrix_1.7-6         patchwork_1.3.2      hms_1.1.4           
## [139] bit64_4.8.2          future_1.75.0        statmod_1.5.2       
## [142] shiny_1.14.0         rbibutils_2.4.1      igraph_2.3.3        
## [145] broom_1.0.13         memoise_2.0.1        bslib_0.12.0        
## [148] bit_4.6.0