## First example: one-factor analysis with sPLS-DA
# -------------------
data(vac18)
X <- vac18$genes
Y <- vac18$stimulation
design <- data.frame(sample = vac18$sample,
stimul = vac18$stimulation)
vac18.splsda.multilevel <- multilevel(X, ncomp = 3, design = design,
method = "splsda", keepX = c(30, 137, 123))
# set up colors for pheatmap
col.samp <- c("lightgreen", "red", "lightblue", "darkorange",
"purple", "maroon", "blue", "chocolate", "turquoise",
"tomato1", "pink2", "aquamarine")
col.stimu <- c("darkblue", "purple", "green4","red3")
col.stimu <- col.stimu[as.numeric(Y)]
col.stimu <- unique(col.stimu)
pheatmap.multilevel(vac18.splsda.multilevel,
# colors:
col_sample = col.samp,
col_stimulation = col.stimu,
#labels:
label_annotation = c("Subject", "Stimulus"),
# scaling:
scale = 'row',
# distances and clutering
clustering_distance_rows = "euclidean",
clustering_distance_cols = "euclidean",
clustering_method = "complete",
# show col/row names and font
show_colnames = FALSE,
show_rownames = FALSE,
fontsize = 8,
fontsize_row = 3,
fontsize_col = 2,
border = FALSE,
width = 10)
## Second example: two-factor analysis with sPLS-DA
# --------------------
data(vac18.simulated) # on the simulated data this time
X <- vac18.simulated$genes
design <- data.frame(sample = vac18.simulated$sample,
stimul = vac18.simulated$stimulation,
time = vac18.simulated$time)
vac18.splsda2.multilevel <- multilevel(X, ncomp = 2, design = design,
keepX = c(200, 200), method = 'splsda')
# set up colors for each level of pheatmap
col.sample <- c("lightgreen", "red","lightblue","darkorange","purple","maroon") # 6 samples
col.time <- c("pink","lightblue1") # two time points
col.stimu <- c('green', 'black', 'red', 'blue') # 4 stimulations
# set up labels for the 2 levels in design matrix
label.stimu <- unique(design[, 2])
label.time <- unique(design$time)
pheatmap.multilevel(vac18.splsda2.multilevel,
# colors:
col_sample=col.sample,
col_stimulation=col.stimu,
col_time=col.time,
#labels for each level
label_color_stimulation=label.stimu,
label_color_time=label.time,
#clustering method
clustering_method="ward",
#show col/row names and font size
show_colnames = FALSE,
show_rownames = TRUE,
fontsize_row=2)
Run the code above in your browser using DataLab