# VSOLassoBag

# Variable-Selection Oriented Lasso Bagging Algorithm

## 1. Introduction

VSOLassoBag is a variable-selection oriented Lasso bagging algorithm for biomarker development in omics-based translational research, providing a bagging Lasso framework for selecting significant variables from multiple models. A main application of this package is to screen a limited number of variables that are less dependent to the training data sets. Basically, this package was initially developed to adjust Lasso selected results from bootstrapped sample sets. The variables with the highest frequency among several selected results were considered as the stable variables to discriminate different sample sets. However, it is usually difficult to determine the cut-off point in terms of frequency when applied in real data sets. In this package, we introduced several methods, namely (1) curve elbow point detection, (2) parametric statistical test to help determine the cut-off point for variable selection. The source code and documents are freely available through Github (https://github.com/likelet/VSOLassoBag).

### 1.1 Citation

If you find this tool useful, please cite:

> Liang J, Wang C, Zhang D, et al. VSOLassoBag: A variable-selection oriented LASSO bagging algorithm for biomarker discovery in omic-based translational research [published online ahead of print, 2023 Jan 3]. J Genet Genomics. 2023;S1673-8527(22)00285-5. doi:10.1016/j.jgg.2022.12.005

## 2. Installation

VSOLassoBag can run in both Windows system and most POSIX systems. To the latest version of this package, start R and enter:

    if (!requireNamespace("devtools", quietly = TRUE)) {
      install.packages("devtools")
    }
    devtools::install_github("likelet/VSOLassoBag")

VSOLassoBag.R

## 3. Prepare input data

To perform analysis with `VSOLassoBag` function, you need to provide:

- ExpressionData is an object constructed by SummarizedExperiment, including independent variables (e.g., expression matrix) and dependent/outcome variable(s). Please view the SummarizedExperiment doucumention for the construction of SummarizedExperiment objects.

- character indicating the type of dependent variables as input to the parameter `a.family`.

Note:

- `a.family` is determined entirely by the type of `dependent/outcome variable(s)`.

- You can also tune other parameters to better balance the performance and resource required for the analysis. Key parameters include `bootN` for bagging times, and `bagFreq.sigMethod` for the cut-off point decision method.

### 3.1 Independent variables

`Independent variables` is a matrix-like object with variables as rows and observations as columns, all the entries should be numeric. It can be obtained by `SummarizedExperiment::assay` function.

Example `Independent variables` matrix

              [,1]       [,2]       [,3]        [,4]        [,5]       [,6]
    X_1 -1.0059043 -0.5831154  0.5188620  0.08714558  0.45080348  0.1149953
    X_2  1.2907372 -0.1005391  0.3385391  0.28154759 -0.14453034  1.0213830
    X_3 -0.5321077  1.9809263  0.5795232  0.98104200 -0.02066287 -1.0550853
    X_4 -0.9984327  1.4455361  1.3130022  0.47038414 -1.23164279  2.3385465
    X_5 -0.2032319 -0.6088388 -1.3633668 -0.22835534  2.33349367  0.2281900
    X_6  2.4383744  0.7443007  1.7134854  0.62076548  0.07363745 -0.0915762

VSOLassoBag.R

### 3.2 dependent/outcome variable(s)

`dependent/outcome variable(s)` store sample information with the same rows as the samples in the independent variables matrix and can be invoked by `SummarizedExperiment::colData` function.

Example `out.mat` vector

    [1]  0.1580122  0.4223877  4.3253401  3.9309707  1.2470942 -0.4556825

VSOLassoBag.R

### 3.3 a.family

`a.family` is a character determined by the data type of `out.mat`, including binomial, gaussian, cox, multinomial, mgaussian, poisson.

## 4. Results

A list with:

1. `results`: a dataframe containing variables with selection frequency >= 1. If setting `bagFreq.sigMethod == "PST"`, the P.value and the P.adjust of each variable will be provided. If setting `bagFreq.sigMethod = "CEP"` or using the elbow point indicators, elbow point(s) will be marked with * and thresholds for each variable will be assigned.

2. `permutations`: the permutation test results.

3. `model`: the regression model built on LassoBag results.

## 5. Usage Example

For tutorial purpose, here we used two examples utilizing different cut-off point decision methods to exhibit how to interpret results. The data is simulated by Gaussian model and you can obtain it by `data(simulated_example)`

### 5.1 Using “CEP” cut-off point decision method

“CEP” (i.e. “Curve Elbow Point Detection”) is the default and recommended method for cut-off point decision. This method assumes that a sharp decrease of the observed frequency should separate important features from those unimportant ones, and based on this detects the elbow point(s) on the observed frequency curve. Finally the features with observed frequency higher than the elbow point are inferred as important features.

Note: There may be more than one elbow point detected on the curve when using loose threshold, therefore it is recommended to use a stricter threshold first (use a larger `kneedle.S`) and the algorithm will automatically loosen the S parameter in case no elbow point can be found.

      library(VSOLassoBag)
      data(ExpressionData)
      set.seed(19084)
      VSOLassoBag(ExpressionData = ExpressionData, outcomevariable = "y", bootN = 100, a.family = "gaussian", bagFreq.sigMethod = "PST", do.plot = FALSE)

VSOLassoBag.R

Results of important variables:

    Mon Sep  1 19:44:20 2025 -- INIT process completed, start analyzing
    Mon Sep  1 19:44:20 2025 -- start calculating observed frequency
    2025-09-01 19:44:42.380739--Bagging finished ...
    Mon Sep  1 19:44:42 2025 -- Using Non-permutation method to determine a cutoff point
    Using Parametric Statistical Test...
    Mon Sep  1 19:44:42 2025 -- Done
        variable Frequency       P.value      P.adjust
    3        X_3       100  0.000000e+00  0.000000e+00
    7        X_7       100  0.000000e+00  0.000000e+00
    2        X_2        99 3.872023e-116 3.071805e-114
    10      X_10        98 5.138189e-113 3.057222e-111
    6        X_6        97 3.375159e-110 1.606576e-108
    9        X_9        88  1.233395e-89  4.892466e-88
    5        X_5        87  1.214149e-87  4.128108e-86
    8        X_8        82  3.167383e-78  9.422964e-77
    4        X_4        62  4.736353e-47  1.252502e-45
    1        X_1        45  1.290263e-26  3.070827e-25
    59     X_108        28  2.930143e-11  6.339763e-10
    226    X_468        25  3.983529e-09  7.900667e-08
    86     X_169        21  1.372018e-06  2.511849e-05
    193    X_404        19  1.836787e-05  3.122538e-04

VSOLassoBag.R

CEP Observed Frequency Curve (generated by `do.plot = TRUE`):

### 5.2 Using “PST” cut-off point decision method

“PST” (i.e. “Parametric Statistical Test”) is one of the alternative methods for cut-off point decision, which is computed as fast and memory-efficient as “CEP”. It assumes the expected selection frequency of all variables follows a binomial distribution, so we can first model such a theoretical background distribution, and then obtain the statistical significance (p-value) of all variables.

      library(VSOLassoBag)
      data(ExpressionData)
      set.seed(19084)
      VSOLassoBag(ExpressionData = ExpressionData, outcomevariable = "y", bootN = 100, a.family = "gaussian", bagFreq.sigMethod = "CEP", do.plot = TRUE)

VSOLassoBag.R

Results of PST method

    Mon Sep  1 19:44:42 2025 -- INIT process completed, start analyzing
    Mon Sep  1 19:44:42 2025 -- start calculating observed frequency
    2025-09-01 19:45:05.208087--Bagging finished ...
    Mon Sep  1 19:45:05 2025 -- Using Non-permutation method to determine a cutoff point
    Detecting Elbow Points on the Observed Frequency Curve...
    Using S = 10 for elbow point dection.
    Mon Sep  1 19:45:05 2025 -- Done
        variable Frequency elbow.point Diff     Thres
    3        X_3       100                0  0.000000
    7        X_7       100                0  0.000000
    2        X_2        99                1  0.000000
    10      X_10        98                1  0.000000
    6        X_6        97                1  0.000000
    9        X_9        88           *    9  4.822785
    5        X_5        87                1  4.822785
    8        X_8        82                5  4.822785
    4        X_4        62           *   20 15.822785
    1        X_1        45               17 15.822785
    59     X_108        28               17 15.822785
    226    X_468        25                3 15.822785
    86     X_169        21                4 15.822785
    193    X_404        19                2 15.822785

VSOLassoBag.R

PST Observed Frequency Distribution (generated by `do.plot = TRUE`):

## 6. Session Info

    R version 4.3.2 (2023-10-31)
    Platform: aarch64-apple-darwin20 (64-bit)
    Running under: macOS Sonoma 14.4.1

    Matrix products: default
    BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
    LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

    locale:
    [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

    time zone: Asia/Shanghai
    tzcode source: internal

    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base

    other attached packages:
    [1] VSOLassoBag_1.0

    loaded via a namespace (and not attached):
     [1] SummarizedExperiment_1.32.0 gtable_0.3.4
     [3] shape_1.4.6                 xfun_0.52
     [5] bslib_0.6.1                 ggplot2_3.5.2
     [7] Biobase_2.62.0              lattice_0.21-9
     [9] vctrs_0.6.4                 tools_4.3.2
    [11] bitops_1.0-7                generics_0.1.3
    [13] stats4_4.3.2                parallel_4.3.2
    [15] tibble_3.2.1                fansi_1.0.5
    [17] pkgconfig_2.0.3             Matrix_1.6-5
    [19] S4Vectors_0.40.2            POT_1.1-11
    [21] lifecycle_1.0.4             GenomeInfoDbData_1.2.11
    [23] compiler_4.3.2              munsell_0.5.0
    [25] codetools_0.2-19            GenomeInfoDb_1.38.2
    [27] htmltools_0.5.7             sass_0.4.7
    [29] RCurl_1.98-1.13             yaml_2.3.7
    [31] glmnet_4.1-8                pillar_1.9.0
    [33] crayon_1.5.2                jquerylib_0.1.4
    [35] DelayedArray_0.28.0         cachem_1.0.8
    [37] iterators_1.0.14            abind_1.4-5
    [39] foreach_1.5.2               tidyselect_1.2.0
    [41] digest_0.6.33               dplyr_1.1.4
    [43] bookdown_0.43               rmdformats_1.0.4
    [45] splines_4.3.2               fastmap_1.1.1
    [47] grid_4.3.2                  colorspace_2.1-0
    [49] cli_3.6.1                   SparseArray_1.2.2
    [51] magrittr_2.0.3              S4Arrays_1.2.0
    [53] survival_3.5-7              utf8_1.2.4
    [55] scales_1.3.0                rmarkdown_2.25
    [57] XVector_0.42.0              matrixStats_1.2.0
    [59] pbapply_1.7-2               evaluate_0.23
    [61] knitr_1.45                  GenomicRanges_1.54.1
    [63] IRanges_2.36.0              rlang_1.1.2
    [65] Rcpp_1.0.11                 glue_1.6.2
    [67] BiocGenerics_0.48.1         rstudioapi_0.15.0
    [69] jsonlite_1.8.7              R6_2.5.1
    [71] MatrixGenerics_1.14.0       zlibbioc_1.48.0

VSOLassoBag.R

@ Copyright 2018-2022, Center of Bioinformatics, Sun Yat-sen University Cancer Center Revision 322baf5b.