BiocParallel error when running perf() on PLS2

Hi!

I am running PL2 between microbiome abundance data and metabolic pathways data. The pls() runs perfectly fine but when I get to cross-validation with perf() on the model I get the following error:

Error: BiocParallel errors
1 remote errors, element index: 1
4 unevaluated and other errors
first remote error:

Error in X.test %*% a.cv: non-conformable arguments

Pca works fine on both X and Y and even spls fits with no errors or warnings. I found another post where the response that NAs are not accepted, but I checked and I have no NA values in either matrix.

Here is the output from reprex (it requires lots of code because I am reading in data, so sorry..):

library(tidyverse)


## This is same as in genomics2 drive, just moved local to avoid VPN issues at home
file <- "pathabundance.community.relab10.cleaned.csv"

meta <- read.csv("MetaMerge.csv") %>% arrange(Subject.Number) %>% select(Subject.Number,BMI) %>% rename(Subject=Subject.Number)


dt <- read.csv(file) %>%
  arrange(Subject,Visit,Site) %>% select(-c(X))

dt <- merge(y=dt,x=meta,by="Subject",all.y=TRUE)



pw <- dt %>%
  mutate(BMI2=ifelse(BMI<30,"Normal","Unhealthy"),HormoneCont=ifelse(HormoneCont=="Y","Hormonal","Non-Hormonal / None"),
         BV=ifelse(BV=="P","Positive","Negative"),.before=9) %>% 
  rename(BC=HormoneCont) %>%
  mutate(Subject=as.factor(Subject),
         BMICat=as.factor(BMICat),
         BV=as.factor(BV),
         BC=as.factor(BC),
         Visit=as.factor(Visit),
         Ethnicity=as.factor(Ethnicity)) %>% 
  
  mutate(BMI2=as.factor(BMI2)) %>% 
  mutate(Site=case_when(
    Site==1 ~ "Mons Pubis",
    
    Site==2 ~ "Bikini",
    Site==3 ~ "L Majora",
    Site==4 ~ "L Minora",
    Site==5 ~ "Perineum",
    Site==6 ~ "Perianal",
    Site==7 ~ "Introitus",
    Site==8 ~ "Vagina",
    
    
  )) %>% mutate(ID=paste0(Subject,"_",Visit,"_",Site),.before=1) %>% mutate(Site=factor(Site,levels=c("Vagina","Introitus","L Minora","L Majora","Bikini","Mons Pubis","Perineum","Perianal"))) %>% arrange(ID)



file <- "AllIntimateSkin.metaphlan4.7.RA.cleaned.csv"

mb <- read.csv(file) %>% 
  mutate(BMI2=ifelse(BMI<30,"Normal","Unhealthy"),.before=12) %>% 
  mutate(BC=ifelse(BirthControl %in% c("N","IUDCOPPER"),"Non-Hormonal / None","Hormonal"),
         Ethnicity=ifelse(Ethnicity=="Hispanic", "Hispanic","Not Hispanic"),
         BV=ifelse(BV=="BV","Positive","Negative"),.before=13) %>%
  mutate(Subject=as.factor(Subject),
         BMICat=as.factor(BMICat),
         BV=as.factor(BV),
         BaselineOdor=as.factor(BaselineOdor),
         BC=as.factor(BC),
         Visit=as.factor(Visit),
         Ethnicity=as.factor(Ethnicity)) %>% rename(Site=SiteLocation) %>%
  mutate(BMI2=as.factor(BMI2)) %>%
  mutate(Site=case_when(
    Site=="Introitus"~"Introitus",
    Site=="Vaginal"~"Vagina",
    Site=="OutLabiaMajora"~"L Majora",
    Site=="OutLabiaMinora"~"L Minora",
    Site=="BikiniLegCrease"~"Bikini",
    Site=="MonsPubis"~"Mons Pubis",
    Site=="Perineum"~"Perineum",
    Site=="Perianal"~"Perianal")) %>% mutate(Site=factor(Site,levels=c("Vagina","Introitus","L Minora","L Majora","Bikini","Mons Pubis","Perineum","Perianal"))) %>% 
  mutate(ID=paste0(Subject,"_",Visit,"_",Site),.before=1) %>% arrange(ID)

PWDF <- pw %>% select(X1CMET2.PWY..folate.transformations.III..E..coli.:VALSYN.PWY..L.valine.biosynthesis)
MBDF <- mb %>% select(Methanobrevibacter_smithii:Malassezia_restricta)

meta <- mb %>% dplyr::select(-c(Methanobrevibacter_smithii:Malassezia_restricta))

X <- MBDF %>% as.matrix()
Y <- PWDF %>% as.matrix()

library(mixOmics)
#> Loading required package: MASS
#> 
#> Attaching package: 'MASS'
#> The following object is masked from 'package:dplyr':
#> 
#>     select
#> Loading required package: lattice
#> 
#> Loaded mixOmics 6.32.0
#> Thank you for using mixOmics!
#> Tutorials: http://mixomics.org
#> Bookdown vignette: https://mixomicsteam.github.io/Bookdown
#> Questions, issues: Follow the prompts at http://mixomics.org/contact-us
#> Cite us:  citation('mixOmics')
#> 
#> Attaching package: 'mixOmics'
#> The following object is masked from 'package:purrr':
#> 
#>     map

plsm <- spls(X=X,Y=Y,ncomp = 3,mode='regression')

tune <- perf(plsm,validation = "Mfold",folds = 10,nrepeat = 5)
#> Error: BiocParallel errors
#>   1 remote errors, element index: 1
#>   4 unevaluated and other errors
#>   first remote error:
#> Error in X.test %*% a.cv: non-conformable arguments

Created on 2025-09-18 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> Warning in system2("quarto", "-V", stdout = TRUE, env = paste0("TMPDIR=", :
#> running command '"quarto"
#> TMPDIR=C:/Users/dennis.tm.1/AppData/Local/Temp/RtmpOoUvMC/file6f3c30ee21e8 -V'
#> had status 1
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.1 (2025-06-13 ucrt)
#>  os       Windows 11 x64 (build 22631)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/New_York
#>  date     2025-09-18
#>  pandoc   3.4 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>  quarto   NA @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\quarto.exe
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version date (UTC) lib source
#>  BiocParallel   1.42.1  2025-05-29 [1] Bioconductor 3.21 (R 4.5.0)
#>  cli            3.6.5   2025-04-23 [1] CRAN (R 4.5.1)
#>  codetools      0.2-20  2024-03-31 [2] CRAN (R 4.5.1)
#>  corpcor        1.6.10  2021-09-16 [1] CRAN (R 4.5.0)
#>  digest         0.6.37  2024-08-19 [1] CRAN (R 4.5.1)
#>  dplyr        * 1.1.4   2023-11-17 [1] CRAN (R 4.5.1)
#>  ellipse        0.5.0   2023-07-20 [1] CRAN (R 4.5.1)
#>  evaluate       1.0.4   2025-06-18 [1] CRAN (R 4.5.1)
#>  farver         2.1.2   2024-05-13 [1] CRAN (R 4.5.1)
#>  fastmap        1.2.0   2024-05-15 [1] CRAN (R 4.5.1)
#>  forcats      * 1.0.0   2023-01-29 [1] CRAN (R 4.5.1)
#>  fs             1.6.6   2025-04-12 [1] CRAN (R 4.5.1)
#>  generics       0.1.4   2025-05-09 [1] CRAN (R 4.5.1)
#>  ggplot2      * 3.5.2   2025-04-09 [1] CRAN (R 4.5.1)
#>  ggrepel        0.9.6   2024-09-07 [1] CRAN (R 4.5.1)
#>  glue           1.8.0   2024-09-30 [1] CRAN (R 4.5.1)
#>  gridExtra      2.3     2017-09-09 [1] CRAN (R 4.5.1)
#>  gtable         0.3.6   2024-10-25 [1] CRAN (R 4.5.1)
#>  hms            1.1.3   2023-03-21 [1] CRAN (R 4.5.1)
#>  htmltools      0.5.8.1 2024-04-04 [1] CRAN (R 4.5.1)
#>  igraph         2.1.4   2025-01-23 [1] CRAN (R 4.5.1)
#>  knitr          1.50    2025-03-16 [1] CRAN (R 4.5.1)
#>  lattice      * 0.22-7  2025-04-02 [2] CRAN (R 4.5.1)
#>  lifecycle      1.0.4   2023-11-07 [1] CRAN (R 4.5.1)
#>  lubridate    * 1.9.4   2024-12-08 [1] CRAN (R 4.5.1)
#>  magrittr       2.0.3   2022-03-30 [1] CRAN (R 4.5.1)
#>  MASS         * 7.3-65  2025-02-28 [2] CRAN (R 4.5.1)
#>  Matrix         1.7-3   2025-03-11 [2] CRAN (R 4.5.1)
#>  matrixStats    1.5.0   2025-01-07 [1] CRAN (R 4.5.1)
#>  mixOmics     * 6.32.0  2025-08-20 [1] Github (mixOmicsTeam/mixOmics@ad47493)
#>  pillar         1.11.0  2025-07-04 [1] CRAN (R 4.5.1)
#>  pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.5.1)
#>  plyr           1.8.9   2023-10-02 [1] CRAN (R 4.5.1)
#>  purrr        * 1.1.0   2025-07-10 [1] CRAN (R 4.5.1)
#>  R6             2.6.1   2025-02-15 [1] CRAN (R 4.5.1)
#>  rARPACK        0.11-0  2016-03-10 [1] CRAN (R 4.5.1)
#>  RColorBrewer   1.1-3   2022-04-03 [1] CRAN (R 4.5.0)
#>  Rcpp           1.1.0   2025-07-02 [1] CRAN (R 4.5.1)
#>  readr        * 2.1.5   2024-01-10 [1] CRAN (R 4.5.1)
#>  reprex         2.1.1   2024-07-06 [1] CRAN (R 4.5.1)
#>  reshape2       1.4.4   2020-04-09 [1] CRAN (R 4.5.1)
#>  rlang          1.1.6   2025-04-11 [1] CRAN (R 4.5.1)
#>  rmarkdown      2.29    2024-11-04 [1] CRAN (R 4.5.1)
#>  RSpectra       0.16-2  2024-07-18 [1] CRAN (R 4.5.1)
#>  rstudioapi     0.17.1  2024-10-22 [1] CRAN (R 4.5.1)
#>  scales         1.4.0   2025-04-24 [1] CRAN (R 4.5.1)
#>  sessioninfo    1.2.3   2025-02-05 [1] CRAN (R 4.5.1)
#>  stringi        1.8.7   2025-03-27 [1] CRAN (R 4.5.0)
#>  stringr      * 1.5.1   2023-11-14 [1] CRAN (R 4.5.1)
#>  tibble       * 3.3.0   2025-06-08 [1] CRAN (R 4.5.1)
#>  tidyr        * 1.3.1   2024-01-24 [1] CRAN (R 4.5.1)
#>  tidyselect     1.2.1   2024-03-11 [1] CRAN (R 4.5.1)
#>  tidyverse    * 2.0.0   2023-02-22 [1] CRAN (R 4.5.1)
#>  timechange     0.3.0   2024-01-18 [1] CRAN (R 4.5.1)
#>  tzdb           0.5.0   2025-03-15 [1] CRAN (R 4.5.1)
#>  vctrs          0.6.5   2023-12-01 [1] CRAN (R 4.5.1)
#>  withr          3.0.2   2024-10-28 [1] CRAN (R 4.5.1)
#>  xfun           0.53    2025-08-19 [1] CRAN (R 4.5.1)
#>  yaml           2.3.10  2024-07-26 [1] CRAN (R 4.5.0)
#> 
#>  [1] C:/Users/dennis.tm.1/AppData/Local/R/win-library/4.5
#>  [2] C:/Program Files/R/R-4.5.1/library
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Hi @dennist2,

It would be hard to tell from the code, but my impression is that the error comes either from the CV folds (too large for the number of samples) or the number of components, or a combination of both.

Try folds = 5 instead, and maybe comp = 2 if that does not work.

Kim-Anh

Hi Kim,

I tried ncomp 1 and 2 with the number of folds all the way down to 2 and got the same error. There are 1200 observations so I think I have enough data. There are 600 columns in X and 300 columns in Y.

If anything comes to mind please let me know cause this is the main analysis from mixOmics that would be of interest for my data at hand.

Trent,