diff --git a/.Rbuildignore b/.Rbuildignore index 0adb8c4..a81b437 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -29,3 +29,7 @@ ^CODE_OF_CONDUCT\.md$ ^vignettes/.*_files$ +vignettes/.quarto/ +vignettes/*_cache/ +vignettes/*_files/ + diff --git a/.gitignore b/.gitignore index 7645182..65f0a13 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,8 @@ vignettes/*_files/ docs /doc/ /Meta/ -Makevars.omp \ No newline at end of file +Makevars.omp + +vignettes/.quarto/ +vignettes/*_cache/ +vignettes/*_files/ \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index d58d891..8fe628f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: resemble Type: Package Title: Similarity Retrieval and Local Learning for Spectral Chemometrics Version: 3.0.1 -Date: 2026-04-21 +Date: 2026-06-18 Authors@R: c( person(given = "Leonardo", family = "Ramirez-Lopez", @@ -23,9 +23,11 @@ Description: spectral data sets, including memory-based learning (MBL), optimal subset search and selection, and retrieval-based modelling with model libraries. Supports local learning, optimisation of spectral libraries, and - ensemble prediction from precomputed models. - Most of these functions are based on the methods presented in - Ramirez-Lopez et al. (2013) . + ensemble prediction from precomputed models. Most of these functions are + based on the methods presented in Ramirez-Lopez et al. (2013) + , Ramirez-Lopez et al. (2026a) + , and Ramirez-Lopez et al. (2026b) + . License: MIT + file LICENSE URL: https://l-ramirez-lopez.github.io/resemble/, https://github.com/l-ramirez-lopez/resemble Depends: @@ -52,7 +54,7 @@ VignetteBuilder: quarto NeedsCompilation: yes LazyData: true Repository: CRAN -RoxygenNote: 7.3.3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) Config/VersionName: tarragona +Config/roxygen2/version: 8.0.0 diff --git a/NAMESPACE b/NAMESPACE index 7f1f591..d5dd099 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ S3method(plot,ortho_projection) S3method(predict,gesearch) S3method(predict,liblex) S3method(predict,ortho_projection) +S3method(predict,plsr) S3method(predict,resemble_model) S3method(print,diss_correlation) S3method(print,diss_method) diff --git a/NEWS.md b/NEWS.md index b31ee94..5502126 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +# `resemble 3.0.1 (tarragona)` +=============== + +## Fixes + +- Fixed: An error was thrown when passing a categorical variable as side info in `diss_evaluate()`. + +- Vignettes appear now in the right order in CRAN. + # `resemble 3.0.0 (vertex)` =============== diff --git a/R/AAA.R b/R/AAA.R index 3b1309c..b12fd32 100644 --- a/R/AAA.R +++ b/R/AAA.R @@ -1,3 +1,10 @@ +.onLoad <- function(lib, pkg) { + n <- suppressWarnings(as.integer(Sys.getenv("OMP_NUM_THREADS", unset = NA_character_))) + if (!is.na(n) && n >= 1L) { + resemble_set_omp_threads(n) + } +} + .onAttach <- function(lib, pkg) { pkg_v <- pkg_info() diff --git a/R/RcppExports.R b/R/RcppExports.R index b9be50a..4c2e310 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1150,3 +1150,9 @@ ith_pred_cpp <- function(plslib, xscale, Xu, dxrxu = NULL) { .Call(`_resemble_ith_pred_cpp`, plslib, xscale, Xu, dxrxu) } +#' @keywords internal +#' @noRd +resemble_set_omp_threads <- function(n) { + invisible(.Call(`_resemble_resemble_set_omp_threads`, n)) +} + diff --git a/R/diss_evaluate.R b/R/diss_evaluate.R index 2dde779..bbb5d9f 100644 --- a/R/diss_evaluate.R +++ b/R/diss_evaluate.R @@ -110,18 +110,22 @@ diss_evaluate <- function(diss, side_info) { call. = FALSE ) } - side_info <- as.factor(side_info) - if (nlevels(side_info) < 2L) { + side_info_cat <- as.factor(side_info[, 1]) + if (nlevels(side_info_cat) < 2L) { stop( "'side_info' must have at least two categories.", call. = FALSE ) } - get_eval <- .eval_categorical + get_eval <- function(y, indices_closest) + .eval_categorical(as.matrix(as.factor(y[, 1])), indices_closest) } else { get_eval <- .eval_continuous } + + + if (any(colSums(!is.na(side_info)) < 4L)) { stop( "Each 'side_info' variable must have at least 4 non-missing values.", diff --git a/R/gesearch.R b/R/gesearch.R index 57591be..1b73268 100644 --- a/R/gesearch.R +++ b/R/gesearch.R @@ -196,11 +196,13 @@ #' of selectivity ratio plot. Chemometrics and Intelligent Laboratory Systems #' 95:35-48. #' -#' Ramirez-Lopez, L., Viscarra Rossel, R., Behrens, T., Orellano, C., -#' Perez-Fernandez, E., Kooijman, L., Wadoux, A. M. J.-C., Breure, T., -#' Summerauer, L., Safanelli, J. L., & Plans, M. (2026a). When spectral -#' libraries are too complex to search: Evolutionary subset selection for -#' domain-adaptive calibration. \emph{Analytica Chimica Acta}, under review. +#' Ramirez-Lopez, L., Viscarra Rossel, R., Orellano, C., +#' Kooijman, L., Perez-Fernandez, E., Wadoux, A. M. J.-C., +#' Plans, M., Breure, T., Summerauer, L., Safanelli, J. L., +#' Behrens, T., & Boqué, R. (2026a). When spectral libraries +#' are too complex to search: Evolutionary subset selection for +#' domain-adaptive calibration. \emph{Analytica Chimica Acta}, +#' 1412, 345651. \doi{10.1016/j.aca.2026.345651} #' #' @seealso #' \code{\link{fit_pls}}, \code{\link{gesearch_control}}, \code{\link{mbl}} @@ -995,8 +997,7 @@ gesearch.default <- function( #' @aliases gesearch -#' @importFrom stats quantile complete.cases diffinv na.pass model.extract -#' model.frame model.matrix +#' @importFrom stats quantile complete.cases diffinv na.pass model.extract model.frame model.matrix #' @export gesearch.formula <- function( formula, diff --git a/R/liblex.R b/R/liblex.R index e8cd293..43556b7 100644 --- a/R/liblex.R +++ b/R/liblex.R @@ -277,8 +277,8 @@ #' Ramirez-Lopez, L., Metz, M., Lesnoff, M., Orellano, C., #' Perez-Fernandez, E., Plans, M., Breure, T., Behrens, T., #' Viscarra Rossel, R., & Peng, Y. (2026b). Rethinking local spectral -#' modelling: From per-query refitting to model libraries. -#' \emph{Analytica Chimica Acta}, under review. +#' modelling: From per-query refitting to model libraries. +#' \emph{Analytica Chimica Acta}, 345682. \doi{10.1016/j.aca.2026.345682} #' #' Rajalahti, T., Arneberg, R., Berven, F.S., Myhr, K.M., Ulvik, R.J., #' Kvalheim, O.M. (2009). Biomarker discovery in mass spectral profiles by diff --git a/R/local_helpers.R b/R/local_helpers.R index aea1731..5bff023 100644 --- a/R/local_helpers.R +++ b/R/local_helpers.R @@ -1038,6 +1038,7 @@ get_plsr <- function( #' @author Leonardo Ramirez-Lopez #' @keywords internal #' @noRd +#' @export predict.plsr <- function(object, newdata, ncomp = NULL, ...) { if (!inherits(object, "plsr")) { stop("'object' must be of class 'plsr'", call. = FALSE) diff --git a/R/resemble.R b/R/resemble.R index f7db030..f26b928 100644 --- a/R/resemble.R +++ b/R/resemble.R @@ -75,17 +75,20 @@ #' @title Overview of the functions in the resemble package #' @references #' -#' Ramirez-Lopez, L., Viscarra Rossel, R., Behrens, T., Orellano, C., -#' Perez-Fernandez, E., Kooijman, L., Wadoux, A. M. J.-C., Breure, T., -#' Summerauer, L., Safanelli, J. L., & Plans, M. (2026a). When spectral -#' libraries are too complex to search: Evolutionary subset selection for -#' domain-adaptive calibration. \emph{Analytica Chimica Acta}, under review. +#' +#' Ramirez-Lopez, L., Viscarra Rossel, R., Orellano, C., +#' Kooijman, L., Perez-Fernandez, E., Wadoux, A. M. J.-C., +#' Plans, M., Breure, T., Summerauer, L., Safanelli, J. L., +#' Behrens, T., & Boqué, R. (2026a). When spectral libraries +#' are too complex to search: Evolutionary subset selection for +#' domain-adaptive calibration. \emph{Analytica Chimica Acta}, +#' 1412, 345651. \doi{10.1016/j.aca.2026.345651} #' #' Ramirez-Lopez, L., Metz, M., Lesnoff, M., Orellano, C., #' Perez-Fernandez, E., Plans, M., Breure, T., Behrens, T., #' Viscarra Rossel, R., & Peng, Y. (2026b). Rethinking local spectral -#' modelling: From per-query refitting to model libraries. -#' \emph{Analytica Chimica Acta}, under review. +#' modelling: From per-query refitting to model libraries. +#' \emph{Analytica Chimica Acta}, 345682. \doi{10.1016/j.aca.2026.345682} #' #' Ramirez-Lopez, L., Behrens, T., Schmidt, K., Stevens, A., Dematte, J.A.M., #' Scholten, T. (2013a). The spectrum-based learner: A new local approach for diff --git a/README.md b/README.md index c925428..ff6db0b 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ status](https://www.r-pkg.org/badges/version/resemble?v=2.png)](https://CRAN.R-p -*Last update: 2026-04-21* +*Last update: 2026-06-18* -Version: 3.0.0 – vortex +Version: 3.0.1 – tarragona

@@ -261,6 +261,24 @@ citation(package = "resemble") ## News: Memory-based learning and `resemble` +- **2026.04:** [Greenberg et al., + 2026](https://doi.org/10.1016/j.geoderma.2026.117829) + used `resemble` for MBL-PLSR modelling of portable X-ray fluorescence + (pXRF) spectra, showing improved soil property predictions relative to + global PLSR across in-situ and ex-situ measurement settings. + +- **2026.05:** [Ramirez-Lopez et al., + 2026](https://doi.org/10.1016/j.aca.2026.345682) introduced `liblex`, + a retrieval-gated modelling framework that converts spectral libraries + into libraries of precomputed local experts for scalable memory-based + learning. For this, `resemble` was used. + +- **2026.05:** [Ramirez-Lopez et al., + 2026](https://doi.org/10.1016/j.aca.2026.345651) introduced + `gesearch`, an evolutionary subset-selection method for identifying + target-domain-relevant samples from complex spectral libraries. For + this, `resemble` was used. + - **2026.05:** [van Leeuwen et al., 2026](https://doi.org/10.1016/j.geoderma.2026.117804) used `resemble` for principal component Mahalanobis nearest-neighbour diff --git a/README.qmd b/README.qmd index 8205d18..79da8c6 100644 --- a/README.qmd +++ b/README.qmd @@ -279,6 +279,14 @@ citation(package = "resemble") ## News: Memory-based learning and `resemble` +* **2026.04:** [Greenberg et al., 2026](https://doi.org/10.1016/j.geoderma.2026.117829) + used `resemble` for MBL-PLSR modelling of portable X-ray fluorescence (pXRF) spectra, showing improved soil property predictions relative to global PLSR across in-situ and ex-situ measurement settings. + +* **2026.05:** [Ramirez-Lopez et al., 2026](https://doi.org/10.1016/j.aca.2026.345682) + introduced `liblex`, a retrieval-gated modelling framework that converts spectral libraries into libraries of precomputed local experts for scalable memory-based learning. For this, `resemble` was used. + +* **2026.05:** [Ramirez-Lopez et al., 2026](https://doi.org/10.1016/j.aca.2026.345651) + introduced `gesearch`, an evolutionary subset-selection method for identifying target-domain-relevant samples from complex spectral libraries. For this, `resemble` was used. * **2026.05:** [van Leeuwen et al., 2026](https://doi.org/10.1016/j.geoderma.2026.117804) used `resemble` for principal component Mahalanobis nearest-neighbour search to extract spectrally similar samples from the KSSL library for MIR model calibration in Dutch soils. diff --git a/man/gesearch.Rd b/man/gesearch.Rd index 4527465..c5a0dbc 100644 --- a/man/gesearch.Rd +++ b/man/gesearch.Rd @@ -294,11 +294,13 @@ Kvalheim, O.M. 2009. Biomarker discovery in mass spectral profiles by means of selectivity ratio plot. Chemometrics and Intelligent Laboratory Systems 95:35-48. -Ramirez-Lopez, L., Viscarra Rossel, R., Behrens, T., Orellano, C., -Perez-Fernandez, E., Kooijman, L., Wadoux, A. M. J.-C., Breure, T., -Summerauer, L., Safanelli, J. L., & Plans, M. (2026a). When spectral -libraries are too complex to search: Evolutionary subset selection for -domain-adaptive calibration. \emph{Analytica Chimica Acta}, under review. +Ramirez-Lopez, L., Viscarra Rossel, R., Orellano, C., +Kooijman, L., Perez-Fernandez, E., Wadoux, A. M. J.-C., +Plans, M., Breure, T., Summerauer, L., Safanelli, J. L., +Behrens, T., & Boqué, R. (2026a). When spectral libraries +are too complex to search: Evolutionary subset selection for +domain-adaptive calibration. \emph{Analytica Chimica Acta}, +1412, 345651. \doi{10.1016/j.aca.2026.345651} } \seealso{ \code{\link{fit_pls}}, \code{\link{gesearch_control}}, \code{\link{mbl}} diff --git a/man/liblex.Rd b/man/liblex.Rd index ad242fe..a9cf939 100644 --- a/man/liblex.Rd +++ b/man/liblex.Rd @@ -404,7 +404,7 @@ Ramirez-Lopez, L., Metz, M., Lesnoff, M., Orellano, C., Perez-Fernandez, E., Plans, M., Breure, T., Behrens, T., Viscarra Rossel, R., & Peng, Y. (2026b). Rethinking local spectral modelling: From per-query refitting to model libraries. -\emph{Analytica Chimica Acta}, under review. +\emph{Analytica Chimica Acta}, 345682. \doi{10.1016/j.aca.2026.345682} Rajalahti, T., Arneberg, R., Berven, F.S., Myhr, K.M., Ulvik, R.J., Kvalheim, O.M. (2009). Biomarker discovery in mass spectral profiles by diff --git a/man/mbl.Rd b/man/mbl.Rd index 6616ffc..cbecb4c 100644 --- a/man/mbl.Rd +++ b/man/mbl.Rd @@ -55,7 +55,7 @@ side information (see \code{ncomp_by_opc}()). \item \code{\link{diss_correlation}()}: Correlation-based dissimilarity } A precomputed matrix can also be passed. When \code{diss_usage = - "predictors"}, it must be square with dimensions +"predictors"}, it must be square with dimensions \code{(nrow(Xr) + nrow(Xu))} and zeros on the diagonal. Otherwise, it must have \code{nrow(Xr)} rows and \code{nrow(Xu)} columns.} diff --git a/man/resemble-package.Rd b/man/resemble-package.Rd index 6fac176..334ed6f 100644 --- a/man/resemble-package.Rd +++ b/man/resemble-package.Rd @@ -61,17 +61,19 @@ The functions available for dimensionality reduction are: } } \references{ -Ramirez-Lopez, L., Viscarra Rossel, R., Behrens, T., Orellano, C., -Perez-Fernandez, E., Kooijman, L., Wadoux, A. M. J.-C., Breure, T., -Summerauer, L., Safanelli, J. L., & Plans, M. (2026a). When spectral -libraries are too complex to search: Evolutionary subset selection for -domain-adaptive calibration. \emph{Analytica Chimica Acta}, under review. +Ramirez-Lopez, L., Viscarra Rossel, R., Orellano, C., +Kooijman, L., Perez-Fernandez, E., Wadoux, A. M. J.-C., +Plans, M., Breure, T., Summerauer, L., Safanelli, J. L., +Behrens, T., & Boqué, R. (2026a). When spectral libraries +are too complex to search: Evolutionary subset selection for +domain-adaptive calibration. \emph{Analytica Chimica Acta}, +1412, 345651. \doi{10.1016/j.aca.2026.345651} Ramirez-Lopez, L., Metz, M., Lesnoff, M., Orellano, C., Perez-Fernandez, E., Plans, M., Breure, T., Behrens, T., Viscarra Rossel, R., & Peng, Y. (2026b). Rethinking local spectral modelling: From per-query refitting to model libraries. -\emph{Analytica Chimica Acta}, under review. +\emph{Analytica Chimica Acta}, 345682. \doi{10.1016/j.aca.2026.345682} Ramirez-Lopez, L., Behrens, T., Schmidt, K., Stevens, A., Dematte, J.A.M., Scholten, T. (2013a). The spectrum-based learner: A new local approach for diff --git a/my-comments.md b/my-comments.md index af0f0e0..71df333 100644 --- a/my-comments.md +++ b/my-comments.md @@ -1,3 +1,53 @@ +# version 3.0.1 + +Dear CRAN maintainers, + +This is a resubmission of resemble 3.0.1. The previous submission was held up +by two NOTEs about CPU/elapsed time ratio in tests and vignettes. Both have +been resolved by capping OpenMP threads via `OMP_THREAD_LIMIT` and +`OMP_NUM_THREADS` in `tests/testthat/setup.R` and in the affected vignette +setup chunks. + +## Test environments +- Ubuntu 24.04, R 4.5.3 (local) +- winbuilder R-release: 0 errors, 0 warnings, 0 notes +- winbuilder R-oldrelease: 0 errors, 0 warnings, 0 notes +- winbuilder R-devel: likely false positive ERROR — known incompatibility + between Rcpp 1.1.1 and R 4.6.0 RC (R_NamespaceRegistry removed from R API), + affecting all Rcpp-dependent packages. See: + https://github.com/RcppCore/Rcpp/issues/1473 + Debian R-devel passes with Status: OK. + +Best regards, +Leo + +The package was tested locally: + +devtools::check( + args = "--as-cran", + env_vars = c( + `_R_CHECK_CRAN_INCOMING_` = "true", + `_R_CHECK_CRAN_INCOMING_REMOTE_` = "true" + ) +) + +❯ checking compilation flags used ... NOTE + Compilation used the following non-portable flag(s): + ‘-mno-omit-leaf-frame-pointer’ + +0 errors ✔ | 0 warnings ✔ | 1 note ✖ + +The package was built using: + +devtools::install() + +devtools::build( + vignettes = TRUE, + manual = TRUE, + clean_doc = FALSE +) + + # version 3.0.0 Dear CRAN maintainers, diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png new file mode 100644 index 0000000..c83d46e Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-96x96.png b/pkgdown/favicon/favicon-96x96.png new file mode 100644 index 0000000..c3b9301 Binary files /dev/null and b/pkgdown/favicon/favicon-96x96.png differ diff --git a/pkgdown/favicon/favicon.ico b/pkgdown/favicon/favicon.ico new file mode 100644 index 0000000..b312669 Binary files /dev/null and b/pkgdown/favicon/favicon.ico differ diff --git a/pkgdown/favicon/favicon.svg b/pkgdown/favicon/favicon.svg new file mode 100644 index 0000000..149e860 --- /dev/null +++ b/pkgdown/favicon/favicon.svg @@ -0,0 +1 @@ +RealFaviconGeneratorhttps://realfavicongenerator.net \ No newline at end of file diff --git a/pkgdown/favicon/site.webmanifest b/pkgdown/favicon/site.webmanifest new file mode 100644 index 0000000..4ebda26 --- /dev/null +++ b/pkgdown/favicon/site.webmanifest @@ -0,0 +1,21 @@ +{ + "name": "", + "short_name": "", + "icons": [ + { + "src": "/web-app-manifest-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "/web-app-manifest-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +} \ No newline at end of file diff --git a/pkgdown/favicon/web-app-manifest-192x192.png b/pkgdown/favicon/web-app-manifest-192x192.png new file mode 100644 index 0000000..94407d3 Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-192x192.png differ diff --git a/pkgdown/favicon/web-app-manifest-512x512.png b/pkgdown/favicon/web-app-manifest-512x512.png new file mode 100644 index 0000000..aaf41d5 Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-512x512.png differ diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index d096d2b..53f5b41 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -566,6 +566,16 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// resemble_set_omp_threads +void resemble_set_omp_threads(int n); +RcppExport SEXP _resemble_resemble_set_omp_threads(SEXP nSEXP) { +BEGIN_RCPP + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< int >::type n(nSEXP); + resemble_set_omp_threads(n); + return R_NilValue; +END_RCPP +} static const R_CallMethodDef CallEntries[] = { {"_resemble_fast_diss", (DL_FUNC) &_resemble_fast_diss, 3}, @@ -605,6 +615,7 @@ static const R_CallMethodDef CallEntries[] = { {"_resemble_ith_local_fit", (DL_FUNC) &_resemble_ith_local_fit, 10}, {"_resemble_final_fits_cpp", (DL_FUNC) &_resemble_final_fits_cpp, 9}, {"_resemble_ith_pred_cpp", (DL_FUNC) &_resemble_ith_pred_cpp, 4}, + {"_resemble_resemble_set_omp_threads", (DL_FUNC) &_resemble_resemble_set_omp_threads, 1}, {NULL, NULL, 0} }; diff --git a/src/diss_helpers.cpp b/src/diss_helpers.cpp index 7df1e7a..aa09985 100644 --- a/src/diss_helpers.cpp +++ b/src/diss_helpers.cpp @@ -1253,6 +1253,21 @@ List top_k_neighbors( for (int j = 0; j < m; j++) { out[j] = wrap(results[j]); } - + return out; } + +//' Set the number of OpenMP threads +//' +//' Calls \code{omp_set_num_threads()} so that the limit takes effect for all +//' subsequent parallel regions, regardless of when \code{OMP_NUM_THREADS} was +//' set in the environment. +//' @param n Number of threads. +//' @keywords internal +//' @noRd +// [[Rcpp::export(visible = false)]] +void resemble_set_omp_threads(int n) { +#ifdef _OPENMP + omp_set_num_threads(n); +#endif +} diff --git a/tests/setup.R b/tests/setup.R new file mode 100644 index 0000000..6d04219 --- /dev/null +++ b/tests/setup.R @@ -0,0 +1,4 @@ +# to comply with CRAN's 2-core limit +Sys.setenv(OMP_NUM_THREADS = "2") +Sys.setenv(OMP_THREAD_LIMIT = "2") +options(mc.cores = 2) diff --git a/vignettes/aa-intro.qmd b/vignettes/aa-intro.qmd index dd99728..d175aac 100644 --- a/vignettes/aa-intro.qmd +++ b/vignettes/aa-intro.qmd @@ -24,6 +24,8 @@ vignette: > ```{r} #| echo: false Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) ``` :::: {.columns} @@ -47,7 +49,7 @@ The functions presented here are implemented based on the methods described in @ The main functionalities of `resemble` include: -- orthogonal projection of spectral data using principal component analyssis (PCA) and partial least squares (PLS) methods +- orthogonal projection of spectral data using principal component analysis (PCA) and partial least squares (PLS) methods - computation and evaluation of spectral dissimilarity measures diff --git a/vignettes/ab-dimensionality-reduction.qmd b/vignettes/ab-dimensionality-reduction.qmd index 47fd5ab..0fbfd41 100644 --- a/vignettes/ab-dimensionality-reduction.qmd +++ b/vignettes/ab-dimensionality-reduction.qmd @@ -24,6 +24,8 @@ vignette: > ```{r} #| echo: false Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) ``` diff --git a/vignettes/ac-estimating-dissimilarity-between-spectra.qmd b/vignettes/ac-estimating-dissimilarity-between-spectra.qmd index ffc3d49..c0d3164 100644 --- a/vignettes/ac-estimating-dissimilarity-between-spectra.qmd +++ b/vignettes/ac-estimating-dissimilarity-between-spectra.qmd @@ -24,6 +24,8 @@ vignette: > ```{r} #| echo: false Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) ``` diff --git a/vignettes/ad-nearest-neighbor-search.qmd b/vignettes/ad-nearest-neighbor-search.qmd index b820e8f..70e1f83 100644 --- a/vignettes/ad-nearest-neighbor-search.qmd +++ b/vignettes/ad-nearest-neighbor-search.qmd @@ -25,6 +25,8 @@ vignette: > ```{r} #| echo: false Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) ``` diff --git a/vignettes/ae-simple-global-models.qmd b/vignettes/ae-simple-global-models.qmd index 3f53626..0ccb3c3 100644 --- a/vignettes/ae-simple-global-models.qmd +++ b/vignettes/ae-simple-global-models.qmd @@ -28,6 +28,8 @@ vignette: > #| echo: false options(cli.num_colors = 1) Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) ``` :::: {.columns} diff --git a/vignettes/af-classical-mbl.qmd b/vignettes/af-classical-mbl.qmd index 341d664..6a7c0bc 100644 --- a/vignettes/af-classical-mbl.qmd +++ b/vignettes/af-classical-mbl.qmd @@ -29,6 +29,8 @@ vignette: > #| echo: false options(cli.num_colors = 1) Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) ``` :::: {.columns} diff --git a/vignettes/ag-evolutionary-subset-search.qmd b/vignettes/ag-evolutionary-subset-search.qmd index d7265d1..aa14827 100644 --- a/vignettes/ag-evolutionary-subset-search.qmd +++ b/vignettes/ag-evolutionary-subset-search.qmd @@ -34,8 +34,10 @@ vignette: > ```{r} #| message: false #| echo: false -library(resemble) Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) +library(resemble) ``` @@ -330,18 +332,18 @@ my_control <- gesearch_control( ```{r} #| eval: true -#| echo: false +#| echo: false gs <- gesearch( Xr = train_x[!is.na(train_y), ], # the spectra of the reference "set/library" Yr = train_y[!is.na(train_y)], # the response of the reference "set/library" Xu = test_x_ref, # the available target domain spectra Yu = test_y_ref, # the available target domain response (accepts NAs) - k = 50, b = 100, retain = 0.95, + k = 50, b = 20, retain = 0.95, target_size = 120, fit_method = fit_pls(ncomp = 20, method = "simpls", scale = TRUE), optimization = c("reconstruction", "similarity", "response"), control = my_control, - seed = 1124, + seed = 1124, verbose = FALSE ) ``` @@ -464,18 +466,18 @@ The search process can be conducted when no information on the response variable ```{r} #| eval: true -#| echo: false +#| echo: false gs_nr <- gesearch( Xr = train_x[!is.na(train_y), ], # the spectra of the reference "set/library" Yr = train_y[!is.na(train_y)], # the response of the reference "set/library" Xu = test_x_ref, # the available target domain spectra Yu = NULL, # NO available target domain response (accepts NAs) - k = 50, b = 80, retain = 0.98, + k = 50, b = 15, retain = 0.98, target_size = 160, fit_method = fit_pls(ncomp = 20, method = "simpls", scale = TRUE), optimization = c("reconstruction", "similarity"), control = my_control, - seed = 1124, + seed = 1124, verbose = FALSE ) ``` @@ -513,19 +515,19 @@ In some cases, the response values for the target set may not be available, but ```{r} #| eval: true -#| echo: false +#| echo: false gs_nr2 <- gesearch( Xr = train_x[!is.na(train_y), ], # the spectra of the reference "set/library" Yr = train_y[!is.na(train_y)], # the response of the reference "set/library" Xu = test_x_ref, # the available target domain spectra Yu = NULL, # NO available target domain response (accepts NAs) Yu_lims = c(0, 5), # the response range in the target domain - k = 50, b = 80, retain = 0.98, + k = 50, b = 15, retain = 0.98, target_size = 160, fit_method = fit_pls(ncomp = 20, method = "simpls", scale = TRUE), optimization = c("reconstruction", "similarity", "range"), control = my_control, - seed = 1124, + seed = 1124, verbose = FALSE ) ``` diff --git a/vignettes/ah-building-a-library-of-models-with-liblex.qmd b/vignettes/ah-building-a-library-of-models-with-liblex.qmd index c2a69b2..77f362d 100644 --- a/vignettes/ah-building-a-library-of-models-with-liblex.qmd +++ b/vignettes/ah-building-a-library-of-models-with-liblex.qmd @@ -24,9 +24,11 @@ vignette: > ```{r} #| message: false #| echo: false +Sys.setenv(OMP_NUM_THREADS = 2) +Sys.setenv(OMP_THREAD_LIMIT = 2) +options(mc.cores = 2) library(resemble) library(prospectr) -Sys.setenv(OMP_NUM_THREADS = 2) ``` :::: {.columns} @@ -232,7 +234,6 @@ ciso_lib_k ```{r} #| label: liblex-fixed-k -#| cache: true #| echo: false #| message: false #| warning: false @@ -275,7 +276,6 @@ The `k_min` and `k_max` arguments ensure reasonable neighborhood sizes: ```{r} #| label: liblex-threshold -#| cache: true #| echo: false ciso_lib_thr <- liblex( Xr = train_x, @@ -300,7 +300,6 @@ ciso_lib_thr ``` ```{r} -#| cache: true #| eval: false ciso_lib_thr <- liblex( Xr = train_x, @@ -481,7 +480,6 @@ cat("Selected", length(anchor_km), "anchors via k-means\n") ```{r} #| label: liblex-anchored -#| cache: true #| echo: false ciso_lib_anchored <- liblex( Xr = train_x, @@ -505,7 +503,6 @@ ciso_lib_anchored ```{r} -#| cache: true #| eval: false ciso_lib_anchored <- liblex( Xr = train_x,