# NOT RUN {
# block.splsda
# -------------
data("breast.TCGA")
# this is the X data as a list of mRNA, miRNA and proteins
data = list(mrna = breast.TCGA$data.train$mrna, mirna = breast.TCGA$data.train$mirna,
protein = breast.TCGA$data.train$protein)
# set up a full design where every block is connected
design = matrix(1, ncol = length(data), nrow = length(data),
dimnames = list(names(data), names(data)))
diag(design) = 0
design
# set number of component per data set
ncomp = c(2)
# set number of variables to select, per component and per data set (this is set arbitrarily)
list.keepX = list(mrna = rep(20, 2), mirna = rep(10,2), protein = rep(10, 2))
TCGA.block.splsda = block.splsda(X = data, Y = breast.TCGA$data.train$subtype,
ncomp = ncomp, keepX = list.keepX, design = design)
TCGA.block.splsda
plotIndiv(TCGA.block.splsda, ind.names = FALSE)
# illustrates coefficient weights in each block
plotLoadings(TCGA.block.splsda, ncomp = 1, contrib = 'max')
plotVar(TCGA.block.splsda, style = 'graphics', legend = TRUE)
# block.splsda constraint
# -------------
# using the data and design from example above
## we force the first PLS-component of X to be built with only a few variables
# selected in the earlier example
constraint.mrna.comp1 = c("EPHB3", "CBR1", "BSPRY")
constraint.mirna.comp1 = c("hsa-mir-128-2", "hsa-mir-196b")
constraint.prot.comp1 = c("Paxillin")
TCGA.block.splsda.constraint = block.splsda(X = data, Y = breast.TCGA$data.train$subtype, ncomp = 2,
keepX = list(mrna = 20, mirna = 20, protein = 10),
keepX.constraint = list(mrna = list(constraint.mrna.comp1), mirna = list(constraint.mirna.comp1),
protein = list(constraint.prot.comp1)))
# see if that subset contraint on comp 1 affected the variables selected in comp 2:
intersect(selectVar(TCGA.block.splsda.constraint, comp = 2)$mrna$name,
selectVar(TCGA.block.splsda, comp = 2)$mrna$name)
# indices of the constraint variables on the first component
TCGA.block.splsda.constraint$keepX.constraint
# }
Run the code above in your browser using DataLab