Dear Team,
I’m trying to use multilevel PLSDA for paired data and get an error on ‘rowSums’ every time I add the multilevel argument. Simple PLSDA works fine. Kindly help me!
Below is the error reproduced using the mixOmics package example. I try to use the R version R 4.3.2 or R 4.2.3 ,both could got the same error. (mixOmics version 6.26.0.)
##data: 24col* 10row dataframe: the first column named “sample” is the different samples (5 samples totally: 1,2,3,4,5,1,2,3,4,5. Same sample figure means the data from the same sample but different timepoint. The fisrt 1-5 are from timepoint1, the second 1-5 are from timepoint2). The second column named Timepoint include two timepoints: T1,T1,T1,T1,T1,T2,T2,T2,T2,T2. The rest 22coloun are the different markers. (some have NA)
Code:
delete<-c(1,2)
X<- final.data[, -delete]
Y<- as.factor(data$Timepoint)
pls<- plsda(X, Y, multilevel = data$sample, ncomp = 2)
Error in rowSums(Y) : ‘x’ must be an array of at least two dimensions
And I also wander these code I write instead are right or not:
delete<-c(1,2)
X<- data[, -delete]
Y<- as.factor(data$Timepoint)
design<-data.frame(sample=data$sample)
Xw ← withinVariation(X, design)
pls<- plsda(Xw, Y, ncomp = 2)
Thank you so much. I would appreciate your valuable feedback.