From 07fe20ffbb95f13d216c9e0ebce9ad18db5021d5 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:16:36 +1000 Subject: [PATCH 01/18] fix: checck_entry function not handling missing Y value correctly, threw error during examples when running cran checks --- R/check_entry.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/check_entry.R b/R/check_entry.R index 417ab1ae..b5f9189c 100644 --- a/R/check_entry.R +++ b/R/check_entry.R @@ -202,8 +202,8 @@ Check.entry.pls = function(X, Y, ncomp, keepX, keepY, test.keepX, test.keepY, if (!(logratio %in% c("none", "CLR"))) stop("Choose one of the two following logratio transformation: none or CLR") - # if DA and the unmapped Y has rows without associated class - if (DA) { + # if DA and the unmapped Y has rows without associated class, only run this check if Y is not null (ie multilevel) + if (DA && !is.null(Y)) { if (length(which(rowSums(Y)==0)) != 0) { stop("Unmapped Y contains samples with no associated class. May be caused by NAs in input Y vector") } From 2fa2c1edfbce9989224209cf0b24ec2c7c734665 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:33:49 +1000 Subject: [PATCH 02/18] fix github action: only push to dockerhub on linux runner --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 5ce30af0..72f62b8f 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -208,7 +208,7 @@ jobs: shell: bash - name: Push to DockerHub 📦 - if: needs.versions.outputs.dockerise == 'true' && !contains(github.event.head_commit.message, 'skip-docker') + if: runner.os == 'Linux' && needs.versions.outputs.dockerise == 'true' && !contains(github.event.head_commit.message, 'skip-docker') uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} From d8b5a0f8360d7c4750586c6749f7bd2f44972b34 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:41:04 +1000 Subject: [PATCH 03/18] github action: force schedule run to check CRAN rcmdchecks --- .github/workflows/actions.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 72f62b8f..81192d63 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -6,7 +6,8 @@ on: branches: - master schedule: - - cron: '0 8 * * 4' + - cron: '44 23 * * *' + #- cron: '0 8 * * 4' name: R-CMD-check From 56a703a664a3dff0b14d13d4c0b9aa03dcd74fee Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:45:15 +1000 Subject: [PATCH 04/18] fix error in network examples during rcmdcheck cran: interactive plot should only be made in interactive session --- examples/network-examples.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/network-examples.R b/examples/network-examples.R index ff8dfb38..815c2448 100644 --- a/examples/network-examples.R +++ b/examples/network-examples.R @@ -26,10 +26,12 @@ show.edge.labels = FALSE) dev.off() -## interactive 'cutoff' - -network(nutri.res, comp = 1:3, cutoff = 0.55, interactive = TRUE) -## select the 'cutoff' and "see" the new network +## interactive 'cutoff' - select the 'cutoff' and "see" the new network +## only run this during an interactive session +if (interactive()) { + network(nutri.res, comp = 1:3, cutoff = 0.55, interactive = TRUE) +} +dev.off() ## network representation for objects of class 'spls' data(liver.toxicity) From 51a7002db64b7ad5451bdbe88e8bc5b3b253a4dc Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:46:48 +1000 Subject: [PATCH 05/18] force schedule actions in 3 mins --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 81192d63..75dae63b 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -6,7 +6,7 @@ on: branches: - master schedule: - - cron: '44 23 * * *' + - cron: '49 0 * * *' #- cron: '0 8 * * 4' name: R-CMD-check From f624703a7713285c93cecca6d1cd8f5ddcc55ea9 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:03:35 +1000 Subject: [PATCH 06/18] edit github actions so can trigger a scheduled action automatically for checking purposes --- .github/workflows/actions.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 75dae63b..a66b5988 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -5,9 +5,9 @@ on: pull_request: branches: - master + workflow_dispatch: # Allow manual triggers schedule: - - cron: '49 0 * * *' - #- cron: '0 8 * * 4' + - cron: '0 8 * * 4' name: R-CMD-check @@ -181,7 +181,7 @@ jobs: shell: Rscript {0} - name: Check --as-cran ✅ ✅ - if: github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics' + if: (github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics') || (github.event_name == 'workflow_dispatch' && github.repository == 'mixOmicsTeam/mixOmics') env: _R_CHECK_CRAN_INCOMING_: false run: | @@ -219,7 +219,7 @@ jobs: build_args: BIOC_VERSION=${{ needs.versions.outputs.bioc }} - name: Test coverage 🔍 - if: github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics' + if: (github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics') || (github.event_name == 'workflow_dispatch' && github.repository == 'mixOmicsTeam/mixOmics') # the commands between 'set +e' and 'set -e' are run without throwing any error run: | set +e From 8496ee769ef1830cd6d9a86e4575a6d7b5b5bead Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:57:00 +1000 Subject: [PATCH 07/18] fix example error plotting type --- R/S3methods-plot.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/S3methods-plot.R b/R/S3methods-plot.R index d01704f5..56c0df3f 100644 --- a/R/S3methods-plot.R +++ b/R/S3methods-plot.R @@ -54,10 +54,10 @@ plot.pca <- function(x, #' nutri.res <- rcc(X, Y, lambda1 = 0.064, lambda2 = 0.008) #' #' ## 'pointplot' type scree -#' plot(nutri.res) #(default) +#' plot(nutri.res, type = "point") #(default) #' #' \dontrun{ -#' plot(nutri.res, pch = 19, cex = 1.2, +#' plot(nutri.res, type = "point", pch = 19, cex = 1.2, #' col = c(rep("red", 3), rep("darkblue", 18))) #' #' ## 'barplot' type scree From 96e2f216749a7c1c1f9544ff392933bf6da76f87 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:39:02 +1000 Subject: [PATCH 08/18] updated docs --- man/network.Rd | 10 ++++++---- man/plot.rcc.Rd | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/man/network.Rd b/man/network.Rd index 61eb04ab..4e53afa1 100644 --- a/man/network.Rd +++ b/man/network.Rd @@ -252,10 +252,12 @@ show.edge.labels = FALSE) dev.off() -## interactive 'cutoff' - -network(nutri.res, comp = 1:3, cutoff = 0.55, interactive = TRUE) -## select the 'cutoff' and "see" the new network +## interactive 'cutoff' - select the 'cutoff' and "see" the new network +## only run this during an interactive session +if (interactive()) { + network(nutri.res, comp = 1:3, cutoff = 0.55, interactive = TRUE) +} +dev.off() ## network representation for objects of class 'spls' data(liver.toxicity) diff --git a/man/plot.rcc.Rd b/man/plot.rcc.Rd index a73f7ccb..71e57d02 100644 --- a/man/plot.rcc.Rd +++ b/man/plot.rcc.Rd @@ -26,10 +26,10 @@ Y <- nutrimouse$gene nutri.res <- rcc(X, Y, lambda1 = 0.064, lambda2 = 0.008) ## 'pointplot' type scree -plot(nutri.res) #(default) +plot(nutri.res, type = "point") #(default) \dontrun{ -plot(nutri.res, pch = 19, cex = 1.2, +plot(nutri.res, type = "point", pch = 19, cex = 1.2, col = c(rep("red", 3), rep("darkblue", 18))) ## 'barplot' type scree From e89f2799cd28f75bfe4d872ce444a3842a8c2293 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:39:21 +1000 Subject: [PATCH 09/18] rgl required package due for 3D plots --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c0c9882d..b66a96c2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,13 +25,13 @@ Imports: ggrepel, BiocParallel, utils, - gsignal + gsignal, + rgl Suggests: BiocStyle, knitr, rmarkdown, testthat, - rgl, microbenchmark, magick Authors@R: From 5571abf26ba791eabd8fa19e457b0430f4301391 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:39:58 +1000 Subject: [PATCH 10/18] fixed util function used inside tune.block.splda which threw incorrect indY error --- R/utils.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index 02e75921..3859fb39 100644 --- a/R/utils.R +++ b/R/utils.R @@ -472,9 +472,9 @@ nearZeroVar = function (x, freqCut = 95/5, uniqueCut = 10) if (!all(is.list(X) && length(unique(names(X))) == length(X))) stop("'X' must be a named list. See documentation.", call. = FALSE) - if ((missing(indY) || is.null(indY)) ) { + if ( missing(indY) || is.null(indY) || isTRUE(tryCatch(is.integer(as.integer(indY)) && indY > length(X))) ){ indY <- length(X) + 1 - X <- c(X, list(Y = matrix())) ## just so we have Y in X for design + X <- c(X, list(Y = matrix())) ## just so we have Y in X for design, indY may be > X as has already been used to extract Y in wrapper function e.g. in tune.block.splda } blocks <- names(X) From a9cdf10c1e358bffc4616934ade2421a8a1718b9 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:41:01 +1000 Subject: [PATCH 11/18] removed typo --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 3859fb39..028cbd62 100644 --- a/R/utils.R +++ b/R/utils.R @@ -474,7 +474,7 @@ nearZeroVar = function (x, freqCut = 95/5, uniqueCut = 10) if ( missing(indY) || is.null(indY) || isTRUE(tryCatch(is.integer(as.integer(indY)) && indY > length(X))) ){ indY <- length(X) + 1 - X <- c(X, list(Y = matrix())) ## just so we have Y in X for design, indY may be > X as has already been used to extract Y in wrapper function e.g. in tune.block.splda + X <- c(X, list(Y = matrix())) ## just so we have Y in X for design, ind } blocks <- names(X) From 6bb2173f845b3143178500424d37f0761bde88e9 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:38:52 +1000 Subject: [PATCH 12/18] fixed error with plotloading when plot set to FALSE --- R/plotLoadings.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/plotLoadings.R b/R/plotLoadings.R index 137a9d70..ee85a46b 100644 --- a/R/plotLoadings.R +++ b/R/plotLoadings.R @@ -466,9 +466,8 @@ plotLoadings.mixo_plsda <- title = paste(legend.title), cex = size.legend) } - - contrib.df <- c(contrib.df, list(df)) } # end if plot + contrib.df <- c(contrib.df, list(df)) } names(contrib.df) <- block From fd81e9f53982b9cc107bf6fe25a6fc21802cec03 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:46:27 +1000 Subject: [PATCH 13/18] error in plotloading example code, as outputted plotloadings is a list of df (one per block) --- examples/plotLoadings-examples.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/plotLoadings-examples.R b/examples/plotLoadings-examples.R index 79669a69..a785c5ea 100644 --- a/examples/plotLoadings-examples.R +++ b/examples/plotLoadings-examples.R @@ -58,7 +58,7 @@ name.var = name.var, size.name = 0.5,complete.name.var=TRUE, contrib = "max") # look at the contribution (median) for each variable plot.contrib = plotLoadings(splsda.liver, comp = 2, method = 'median', plot = FALSE, contrib = "max") -head(plot.contrib[,1:4]) +head(plot.contrib[[1]][,1:4]) # change the title of the legend and title name plotLoadings(splsda.liver, comp = 2, method = 'median', legend.title = 'Time', title = 'Contribution plot', contrib = "max") From 20e1a4e0fc92dbf2f03d0472b2f30acbd3abb0b7 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:52:13 +1000 Subject: [PATCH 14/18] plot loadings example description --- man/plotLoadings.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/plotLoadings.Rd b/man/plotLoadings.Rd index 729a6bcd..318d85c1 100644 --- a/man/plotLoadings.Rd +++ b/man/plotLoadings.Rd @@ -482,7 +482,7 @@ name.var = name.var, size.name = 0.5,complete.name.var=TRUE, contrib = "max") # look at the contribution (median) for each variable plot.contrib = plotLoadings(splsda.liver, comp = 2, method = 'median', plot = FALSE, contrib = "max") -head(plot.contrib[,1:4]) +head(plot.contrib[[1]][,1:4]) # change the title of the legend and title name plotLoadings(splsda.liver, comp = 2, method = 'median', legend.title = 'Time', title = 'Contribution plot', contrib = "max") From d26fec5c7f63cbaaed38bfd15eb54e7c39321f9b Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:54:25 +1000 Subject: [PATCH 15/18] fix error data not loaded in splsda example --- examples/splsda-examples.R | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/splsda-examples.R b/examples/splsda-examples.R index 47744e9b..ac8ccca3 100644 --- a/examples/splsda-examples.R +++ b/examples/splsda-examples.R @@ -67,6 +67,7 @@ plotIndiv(splsda.liver, ind.names = Y, ellipse = TRUE, legend = TRUE) ## Fifth example: 16S data with multilevel decomposion and log ratio transformation # ------------------------------------------------ +data(diverse.16S) splsda.16S = splsda( X = diverse.16S$data.TSS, # TSS normalised data Y = diverse.16S$bodysite, From 27c20377b27ba1c04bae947c9d8d1b4739efd670 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:10:55 +1000 Subject: [PATCH 16/18] doc loading data in splsda example --- man/splsda.Rd | 1 + 1 file changed, 1 insertion(+) diff --git a/man/splsda.Rd b/man/splsda.Rd index c199bd6e..56752a62 100644 --- a/man/splsda.Rd +++ b/man/splsda.Rd @@ -170,6 +170,7 @@ plotIndiv(splsda.liver, ind.names = Y, ellipse = TRUE, legend = TRUE) ## Fifth example: 16S data with multilevel decomposion and log ratio transformation # ------------------------------------------------ +data(diverse.16S) splsda.16S = splsda( X = diverse.16S$data.TSS, # TSS normalised data Y = diverse.16S$bodysite, From c508c19726159dfb9012217a6b3ee1bd10f79350 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:11:26 +1000 Subject: [PATCH 17/18] for examples using parallelisation, set up so rcmdcheck limit on number of cores is respected --- examples/tune.block.splsda-examples.R | 7 +++++-- examples/tune.spca-examples.R | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/tune.block.splsda-examples.R b/examples/tune.block.splsda-examples.R index 96f0bc51..67ce833a 100644 --- a/examples/tune.block.splsda-examples.R +++ b/examples/tune.block.splsda-examples.R @@ -28,8 +28,11 @@ subset <- mixOmics:::stratified.subsampling(breast.TCGA$data.train$subtype, fold data <- lapply(data, function(omic) omic[subset,]) Y <- breast.TCGA$data.train$subtype[subset] ## ---- run -## setup cluster - use SnowParam() on Widnows -BPPARAM <- BiocParallel::MulticoreParam(workers = parallel::detectCores()-1) +# Check if the environment variable exists (during R CMD check) and limit cores accordingly +max_cores <- if (Sys.getenv("_R_CHECK_LIMIT_CORES_") != "") 2 else parallel::detectCores() - 1 +# Setup the parallel backend with the appropriate number of workers +BPPARAM <- BiocParallel::MulticoreParam(workers = max_cores) + tune <- tune.block.splsda( X = data, Y = Y, diff --git a/examples/tune.spca-examples.R b/examples/tune.spca-examples.R index 2e35ad19..9ca88fd2 100644 --- a/examples/tune.spca-examples.R +++ b/examples/tune.spca-examples.R @@ -12,9 +12,10 @@ tune.spca.res plot(tune.spca.res) \dontrun{ ## parallel processing using BiocParallel on repeats with more workers (cpus) -## You can use BiocParallel::MulticoreParam() on non_Windows machines -## for faster computation -BPPARAM <- BiocParallel::SnowParam(workers = max(parallel::detectCores()-1, 2)) +# Check if the environment variable exists (during R CMD check) and limit cores accordingly +max_cores <- if (Sys.getenv("_R_CHECK_LIMIT_CORES_") != "") 2 else parallel::detectCores() - 1 +# Setup the parallel backend with the appropriate number of workers +BPPARAM <- BiocParallel::MulticoreParam(workers = max_cores) tune.spca.res <- tune.spca( X = nutrimouse$lipid, ncomp = 2, From df14c296dfd0e5984700d7441531882ba8f5999b Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:27:28 +1000 Subject: [PATCH 18/18] documentation for updated examples --- man/tune.block.splsda.Rd | 7 +++++-- man/tune.spca.Rd | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/man/tune.block.splsda.Rd b/man/tune.block.splsda.Rd index 03818481..7381b228 100644 --- a/man/tune.block.splsda.Rd +++ b/man/tune.block.splsda.Rd @@ -206,8 +206,11 @@ subset <- mixOmics:::stratified.subsampling(breast.TCGA$data.train$subtype, fold data <- lapply(data, function(omic) omic[subset,]) Y <- breast.TCGA$data.train$subtype[subset] ## ---- run -## setup cluster - use SnowParam() on Widnows -BPPARAM <- BiocParallel::MulticoreParam(workers = parallel::detectCores()-1) +# Check if the environment variable exists (during R CMD check) and limit cores accordingly +max_cores <- if (Sys.getenv("_R_CHECK_LIMIT_CORES_") != "") 2 else parallel::detectCores() - 1 +# Setup the parallel backend with the appropriate number of workers +BPPARAM <- BiocParallel::MulticoreParam(workers = max_cores) + tune <- tune.block.splsda( X = data, Y = Y, diff --git a/man/tune.spca.Rd b/man/tune.spca.Rd index 9856cf2b..9ec18317 100644 --- a/man/tune.spca.Rd +++ b/man/tune.spca.Rd @@ -88,9 +88,10 @@ tune.spca.res plot(tune.spca.res) \dontrun{ ## parallel processing using BiocParallel on repeats with more workers (cpus) -## You can use BiocParallel::MulticoreParam() on non_Windows machines -## for faster computation -BPPARAM <- BiocParallel::SnowParam(workers = max(parallel::detectCores()-1, 2)) +# Check if the environment variable exists (during R CMD check) and limit cores accordingly +max_cores <- if (Sys.getenv("_R_CHECK_LIMIT_CORES_") != "") 2 else parallel::detectCores() - 1 +# Setup the parallel backend with the appropriate number of workers +BPPARAM <- BiocParallel::MulticoreParam(workers = max_cores) tune.spca.res <- tune.spca( X = nutrimouse$lipid, ncomp = 2,