Tune.block.splsda error & tune.splsda

Hi, I would like to use the perf , tune.splsda and tune.block.splsda function, and I receive each time the following error: Error in dimnames(x) ← dn :
length of ‘dimnames’ [2] not equal to array extent

For perf and tune splsda I checked whether data is matrix + numeric, so that cannot be the problem:

M ← twin_merged$metab #matrix of metabolite abundances
[1] TRUE
[1] 438 213

Y ← twin_merged$meta$MD #class variable (8 categories)
[1] 438
tw.metab.plsda ← plsda(M, Y, ncomp=10)
tw.metab.perf ← perf(tw.metab.plsda, validation = “Mfold”, folds = 3, progressBar = FALSE, nrepeat = 30)
Error in dimnames(x) ← dn :
length of ‘dimnames’ [2] not equal to array extent


list.keepX ← c(5:10, seq(20, 100, 10))
tune.splsda.metab ← tune.splsda(M, Y, ncomp = 10, validation = ‘Mfold’, folds = 3, dist = ‘max.dist’, progressBar = TRUE, measure = “BER”, test.keepX = list.keepX, nrepeat = 20)

comp 1
|======= | 3%Error in dimnames(x) ← dn :
length of ‘dimnames’ [2] not equal to array extent

Similar error occurs for DIABLO where I do a multi-omics analysis on microbiome and metabolome data:

twin_merged$microb ← twin_merged$microb
twin_merged$metab ← twin_merged$metab

X ← list(microb = twin_merged$microb,

  •       metab = twin_merged$metab)  

Y ← as.character(twin_merged$meta$MD)
All AnxStress AnxStress_ED Depr_AnxStress Depr_ED Depression ED None
6 18 1 26 6 81 6 294
[1] TRUE
[1] TRUE

design = matrix(1, ncol = length(X), nrow = length(X), dimnames = list(names(X), names(X)))
diag(design) = 0

#Tuning on nr of variables per component.
test.keepX = list(microb=seq(5,30,10), metab=seq(5,30,10))
tune ← tune.block.splsda(X=X, Y=Y, ncomp= 7, test.keepX = test.keepX, nrepeat=20, design=design, progressBar = TRUE)
Design matrix has changed to include Y; each block will be
linked to Y.

You have provided a sequence of keepX of length: 3 for block microb and 3 for block metab.
This results in 9 models being fitted for each component and each nrepeat, this may take some time to run, be patient!

You can look into the ‘BPPARAM’ argument to speed up computation time.

tuning component 1
|== | 1%Error: BiocParallel errors
1 remote errors, element index: 1
19 unevaluated and other errors
first remote error: length of ‘dimnames’ [2] not equal to array extent

Which could cause this error? I checked everything over and over again and could not find where the error could be.
Thanks in advance!

After some time, I have been unable to reproduce this error whatsoever. I can’t see anything which immediately pops out to me about your code which may be causing this - but the formatting of the post makes this very difficult. How many missing values do you have in your dataset?