# NOT RUN {
## First example: one-factor analysis with sPLS-DA
# }
# NOT RUN {
data(vac18.simulated) # simulated data
design <- data.frame(sample = vac18.simulated$sample)
result.ex1 = tune.multilevel(X = vac18.simulated$genes,
Y = vac18.simulated$stimulation,
multilevel = design,
ncomp=2,
test.keepX=c(5, 10, 15),
already.tested.X = c(50),
method = 'splsda',
dist = 'mahalanobis.dist',
validation = 'loo')
# overall error rate
result.ex1$error.rate
# classification error rate per class after 2 components
result.ex1$error.rate.class
# }
# NOT RUN {
## Second example: two-factor analysis with sPLS-DA
# }
# NOT RUN {
data(liver.toxicity)
dose <- as.factor(liver.toxicity$treatment$Dose.Group)
time <- as.factor(liver.toxicity$treatment$Time.Group)
# note: we made up those data, pretending they are repeated measurements
repeat.indiv <- c(1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 4, 3, 4, 3, 4, 4, 5, 6, 5, 5,
6, 5, 6, 7, 7, 8, 6, 7, 8, 7, 8, 8, 9, 10, 9, 10, 11, 9, 9,
10, 11, 12, 12, 10, 11, 12, 11, 12, 13, 14, 13, 14, 13, 14,
13, 14, 15, 16, 15, 16, 15, 16, 15, 16)
summary(as.factor(repeat.indiv)) # 16 rats, 4 measurements each
design <- data.frame(sample = repeat.indiv)
result.ex2 = tune.multilevel(liver.toxicity$gene,
Y = data.frame(dose, time),
multilevel = design,
ncomp=2,
test.keepX=c(5, 10, 15),
already.tested.X = c(50),
method = 'splsda',
dist = 'mahalanobis.dist')
result.ex2
# }
# NOT RUN {
## Third example: one-factor integrative analysis with sPLS
# }
# NOT RUN {
data(liver.toxicity)
# note: we made up those data, pretending they are repeated measurements
repeat.indiv <- c(1, 2, 1, 2, 1, 2, 1, 2, 3, 3, 4, 3, 4, 3, 4, 4, 5, 6, 5, 5,
6, 5, 6, 7, 7, 8, 6, 7, 8, 7, 8, 8, 9, 10, 9, 10, 11, 9, 9,
10, 11, 12, 12, 10, 11, 12, 11, 12, 13, 14, 13, 14, 13, 14,
13, 14, 15, 16, 15, 16, 15, 16, 15, 16)
summary(as.factor(repeat.indiv)) # 16 rats, 4 measurements each
# here we are only interested in a one level variation split since spls is an unsupervised method
design <- data.frame(sample = repeat.indiv)
result.ex3 = tune.multilevel(X = liver.toxicity$gene, Y = liver.toxicity$clinic,
multilevel = design,
mode = 'canonical',
ncomp=2,
test.keepX=c(5, 10, 15),
test.keepY=c(2,3),
already.tested.X = c(50), already.tested.Y = c(5),
method = 'spls')
result.ex3
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab