## First example: one-factor analysis with sPLS-DA
data(vac18) # vac18 study
X <- vac18$genes
Y <- vac18$stimulation
res <- multilevel(X, cond = Y, ncomp = 3,
tab.prob.gene = vac18$tab.prob.gene,
sample = vac18$sample, method = "splsda",
keepX = c(30, 137, 123))
# color for plot3dIndiv
col_stim <- c("darkblue", "purple", "green4","red3")
cols <- Y
levels(cols) <- col_stim
cols <- as.character(cols)
plot3dIndiv(res, ind.names = Y, col = cols,
cex = 0.3, axes.box = "both")
## Second example: two-factor analysis with sPLS-DA
data(data.simu) # simulated data
time = factor(rep(c(rep('t1', 6), rep('t2', 6)), 4))
stimu.time = data.frame(cbind(as.character(data.simu$stimu),
as.character(time)))
repeat.simu2 = rep(c(1:6), 8)
res.2level <- multilevel(data.simu$X, cond = stimu.time,
sample = repeat.simu2, ncomp = 2,
keepX = c(200, 200), tab.prob.gene = NULL,
method = 'splsda')
# color for plotIndiv
col.stimu = as.numeric(data.simu$stimu)
# pch for plots
pch.time = rep(20, 48)
pch.time[time == 't2'] = 4
plotIndiv(res.2level, col = col.stimu, pch = pch.time, ind.names = FALSE)
legend('bottomright', col = unique(col.stimu),
legend = levels(data.simu$stimu), pch = 20, cex = 0.8)
legend('topright', col = 'black', legend = levels(time),
pch = unique(pch.time), cex = 0.8)
## Third example: one-factor integrative analysis with sPLS
data(liver.toxicity)
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)
result.rat <- multilevel(X = liver.toxicity$gene, Y=liver.toxicity$clinic,
cond = liver.toxicity$treatment$Dose.Group,
sample = repeat.indiv, ncomp = 2, keepX = c(50, 50),
keepY = c(5, 5), method = 'spls')
# variable plots
plotVar(result.rat, comp = 1:2, X.label = TRUE, Y.label = TRUE,
cex = c(0.5, 0.9))
CIM <- cim(result.rat, comp = 1:2, xlab = "genes", ylab = "clinic var",
margins = c(5, 6), zoom = FALSE)
network(result.rat, comp = 1:2, threshold = 0.8,
Y.names = NULL, keep.var = TRUE,
color.node = c( "lightcyan","mistyrose"),
shape.node = c("circle", "rectangle"),
color.edge = c("red", "green"),
lty.edge = c("solid", "solid"), lwd.edge = c(1, 1),
show.edge.labels = FALSE, interactive = FALSE)
Run the code above in your browser using DataLab