Error when using tune.spls: Missing data in "X" or "Y" matrix

Hi mixOmics Team,

thank you for providing such a great tool for multilevel data analysis, I highly appreciate your work!
My goal is to do a multilevel sPLS analysis, though for simplicity, I decided to ignore the multilevel aspect in the beginning. My X matrix contains missing data, so for tuning my sPLS model with the perf-function I used nipals for imputation. I also tried tuning the same model with tune.spls, also using the nipals imputed data. This works fine. As described in the Help-Function of tune.spls in R, tune.spls can deal with missing data. So I wanted to tune my model with tune.spls using my original data (that contains NAs and is not imputed with nipals). This throws the following error message:
Fehler: BiocParallel errors
1 remote errors, element index: 1
87 unevaluated and other errors
first remote error:
Error: BiocParallel errors
1 remote errors, element index: 1
0 unevaluated and other errors
first remote error:
Error: missing data in ‘X’ and/or ‘Y’. Use ‘nipals’ for dealing with NAs.

The same error occurs when I use my data matrix that contains NAs in the withinVariation function that is made available here at the very bottom of the page. When I use your example code or a data matrix that has no NAs (after nipals imputation) the function works. But creating a random matrix that contains NAs lead to the error message as well.
Do you have any suggestions how to solve this issue? Are NAs an issue for the tuning function?
In case the error is connected to how I am using BiocParallel, this is how it was installed:

if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager") #press ENTER in console
# Install BiocParallel
BiocManager::install("BiocParallel") 
install.packages("devtools") # restart nein klicken
devtools::install_github("mixOmicsTeam/mixOmics")
#BiocManager::install("mixOmics")

library(mixOmics) # import the mixOmics library

This is the code that leads to the error message using a random matrix with NAs.

set.seed(123)

X <- matrix(runif(304 * 150), nrow = 304, ncol = 150)

# Randomly insert 50 NAs into matrix X
na_indices <- sample(length(X), 50)  
X[na_indices] <- NA

Y <- matrix(runif(304 * 200), nrow = 304, ncol = 200)

# create design matrix
table(X_impu[, 1])
repeat.indiv <- c(rep(1, 50), rep(2, 12), rep(3, 50), rep(4, 11), 
                  rep(5, 45), rep(6, 47), rep(7, 40), rep(8, 49))
design <- data.frame(sample = repeat.indiv)

ncomp <- 2
test.keepX = c(3:15)
test.keepY = c(5:15)

Xw <- withinVariation(X = X, design = design)
Yw <- withinVariation(X = Y, design = design)

tune.spls(Xw, Yw, 
          ncomp=ncomp, 
          test.keepX=test.keepX, test.keepY=test.keepY,
          validation = "loo",
          mode = "canonical",
          folds = 5,
          nrepeat = 2,
          measure = "cor",
          BPPARAM = BiocParallel::SnowParam(workers="3"))

I apologize in advance in case this is a basic and straightforward issue. Thank you for helping out!

Hello!

So I have had a look and found that tune.spls() internally calls another function, perf(), which does not allow for NAs and it is this internal function which is throwing the error “missing data in ‘X’ and/or ‘Y’. Use ‘nipals’ for dealing with NAs.”.

Therefore, I would advise using nipals imputation before tuning as you have done to get this to work. I will update the helps docs to correct them, thank you for pointing this out!

Cheers,
Eva