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
is.matrix(M)
[1] TRUE
dim(M)
[1] 438 213Y ← twin_merged$meta$MD #class variable (8 categories)
is.matrix(Y)
[1] FALSE
length(Y)
[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
then:
list.keepX ← c(5:10, seq(20, 100, 10))
set.seed(30)
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$metabX ← list(microb = twin_merged$microb,
-
metab = twin_merged$metab)
Y ← as.character(twin_merged$meta$MD)
summary(as.factor(Y))
All AnxStress AnxStress_ED Depr_AnxStress Depr_ED Depression ED None
6 18 1 26 6 81 6 294
is.matrix(X$microb)
[1] TRUE
is.matrix(X$metab)
[1] TRUEdesign = 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!