#############
# Example 1 #
#############
## Not run: ------------------------------------
# # Download the dataset's package at http://biodev.cea.fr/sgcca/.
# # --> gliomaData_0.4.tar.gz
#
# require(gliomaData)
# data(ge_cgh_locIGR)
#
# A <- ge_cgh_locIGR$multiblocks
# Loc <- factor(ge_cgh_locIGR$y) ; levels(Loc) <- colnames(ge_cgh_locIGR$multiblocks$y)
# C <- matrix(c(0, 0, 1, 0, 0, 1, 1, 1, 0), 3, 3)
# tau = c(1, 1, 0)
#
# # rgcca algorithm using the dual formulation for X1 and X2
# # and the dual formulation for X3
# A[[3]] = A[[3]][, -3]
# result.rgcca = rgcca(A, C, tau, ncomp = c(2, 2, 1), scheme = "factorial", verbose = TRUE)
# # sgcca algorithm
# result.sgcca = sgcca(A, C, c1 = c(.071,.2, 1), ncomp = c(2, 2, 1),
# scheme = "centroid", verbose = TRUE)
#
# ############################
# # plot(y1, y2) for (RGCCA) #
# ############################
# layout(t(1:2))
# plot(result.rgcca$Y[[1]][, 1], result.rgcca$Y[[2]][, 1], col = "white", xlab = "Y1 (GE)",
# ylab = "Y2 (CGH)", main = "Factorial plan of RGCCA")
# text(result.rgcca$Y[[1]][, 1], result.rgcca$Y[[2]][, 1], Loc, col = as.numeric(Loc), cex = .6)
# plot(result.rgcca$Y[[1]][, 1], result.rgcca$Y[[1]][, 2], col = "white", xlab = "Y1 (GE)",
# ylab = "Y2 (GE)", main = "Factorial plan of RGCCA")
# text(result.rgcca$Y[[1]][, 1], result.rgcca$Y[[1]][, 2], Loc, col = as.numeric(Loc), cex = .6)
#
# ############################
# # plot(y1, y2) for (SGCCA) #
# ############################
# layout(t(1:2))
# plot(result.sgcca$Y[[1]][, 1], result.sgcca$Y[[2]][, 1], col = "white", xlab = "Y1 (GE)",
# ylab = "Y2 (CGH)", main = "Factorial plan of SGCCA")
# text(result.sgcca$Y[[1]][, 1], result.sgcca$Y[[2]][, 1], Loc, col = as.numeric(Loc), cex = .6)
#
# plot(result.sgcca$Y[[1]][, 1], result.sgcca$Y[[1]][, 2], col = "white", xlab = "Y1 (GE)",
# ylab = "Y2 (GE)", main = "Factorial plan of SGCCA")
# text(result.sgcca$Y[[1]][, 1], result.sgcca$Y[[1]][, 2], Loc, col = as.numeric(Loc), cex = .6)
#
# # sgcca algorithm with multiple components and different L1 penalties for each components
# # (-> c1 is a matrix)
# init = "random"
# result.sgcca = sgcca(A, C, c1 = matrix(c(.071,.2, 1, 0.06, 0.15, 1), nrow = 2, byrow = TRUE),
# ncomp = c(2, 2, 1), scheme = "factorial", scale = TRUE, bias = TRUE,
# init = init, verbose = TRUE)
# # number of non zero elements per dimension
# apply(result.sgcca$a[[1]], 2, function(x) sum(x!=0))
# #(-> 145 non zero elements for a11 and 107 non zero elements for a12)
# apply(result.sgcca$a[[2]], 2, function(x) sum(x!=0))
# #(-> 85 non zero elements for a21 and 52 non zero elements for a22)
# init = "svd"
# result.sgcca = sgcca(A, C, c1 = matrix(c(.071,.2, 1, 0.06, 0.15, 1), nrow = 2, byrow = TRUE),
# ncomp = c(2, 2, 1), scheme = "factorial", scale = TRUE, bias = TRUE,
# init = init, verbose = TRUE)
## ---------------------------------------------
Run the code above in your browser using DataLab